Creating a cache for a game?

Hi, i'm creating (trying) a game. Now i've been thinking about everything goes and i came with the question about how i to load data about maps, objects etc. It is a 2d game using tiles
So i know runescape uses a cache to store their data about these.
But i've NO idea how i could make it?
Someone told me i this:
"use dataOutputStream to create a data cache along with an index file being the offsets and lengths of the required data."
- I know we use dataOutputStream to load/save.
- I know how to encrypt (this is not important atm)
- I don't know how i define a tile for an x or y (*)
- I don't know how i've to make a data cache ?
- I don't understand what he means by an index file with the offsets and lengths?
(*) How do 2d games load it? They use xml? or just text files ? like
// x -tab- y -tab- floor
0  -tab- 0  -tab- 1 so the above says on x = 0 and y = 0 floor = 1 (grass for example)
Please if anyone could give me an example of this it would be great !!!
This is really important!
Thanks in advance!
Edited by: Kolarius on Feb 7, 2009 1:39 AM
Edited by: Kolarius on Feb 7, 2009 1:41 AM
Edited by: Kolarius on Feb 7, 2009 1:55 AM

What you're asking is a bit like this: "I want to build a house, what is the best way to make a roof?". I mean, you should first create a foundation, on that foundation you build your walls and on top of that, you can eventually build a roof.
First get a decent grip on the language Java: [http://java.sun.com/docs/books/tutorial/java/index.html]
Then delve into some more specific graphic stuff with Java: [http://java.sun.com/docs/books/tutorial/2d/index.html]
And only then proceed to creating your own game: [http://www.gamedev.net/reference/articles/article1262.asp]
If you get stuck anywhere along the lines, feel free to post a specific question in the relevant part of this forum (there's a 2D section, a Game section and this section can be used to ask general Java questions). The question you now posted is nowhere near specific enough: it just can't be answered in a few lines of code or a (fairly) short explanation.

Similar Messages

  • Create a cache for external map source - Error in parsing xml request.

    When doing the following:
    Create a cache for external map source
    I get "error in parsing xml request" when setting the following
    Map service Url:
    http://neowms.sci.gsfc.nasa.gov/wms/wms?version=1.3.0&service=WMS&request=GetCapabilities
    It looks like it is breaking on "&". Any suggestions?
    Rob

    Hi Chris,
    thanks for your reply!
    I've tried to add the following into persistence.xml (although I've read that eclipseLink uses L2 cache by default..):
    <shared-cache-mode>ALL</shared-cache-mode>
    Then I replaced the Cache bean with a stateless bean which has methods like
    Genre findGenreCreateIfAbsent(String genreName){
    Genre genre = genreDAO.findByName(genreName);
    if (genre!=null){
    return genre;
    genre = //Build new genre object
    genreDAO.persist(genre);
    return genre;
    As far as I undestood, the shared cache should automatically store the genre and avoid querying the DB multiple times for the same genre, but unfortunately this is not the case: if I use a FINE logging level, I see really a lot of SELECT queries, which I didn't see with my "home made" Cache...
    I am really confused.. :(
    Thanks again for helping + bye

  • How to create a cache for JPA Entities using an EJB

    Hello everybody! I have recently got started with JPA 2.0 (I use eclipseLink) and EJB 3.1 and have a problem to figure out how to best implement a cache for my JPA Entities using an EJB.
    In the following I try to describe my problem.. I know it is a bit verbose, but hope somebody will help me.. (I highlighted in bold the core of my problem, in case you want to first decide if you can/want help and in the case spend another couple of minutes to understand the domain)
    I have the following JPA Entities:
    @Entity Genre{
    private String name;
    @OneToMany(mappedBy = "genre", cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Collection<Novel> novels;
    @Entity
    class Novel{
    @ManyToOne(cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Genre genre;
    private String titleUnique;
    @OneToMany(mappedBy="novel", cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Collection<NovelEdition> editions;
    @Entity
    class NovelEdition{
    private String publisherNameUnique;
    private String year;
    @ManyToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
    private Novel novel;
    @ManyToOne(optional=false, cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Catalog appearsInCatalog;
    @Entity
    class Catalog{
    private String name;
    @OneToMany(mappedBy = "appearsInCatalog", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
    private Collection<NovelEdition> novelsInCatalog;
    The idea is to have several Novels, belonging each to a specific Genre, for which can exist more than an edition (different publisher, year, etc). For semplicity a NovelEdition can belong to just one Catalog, being such a Catalog represented by such a text file:
    FILE 1:
    Catalog: Name Of Catalog 1
    "Title of Novel 1", "Genre1 name","Publisher1 Name", 2009
    "Title of Novel 2", "Genre1 name","Pulisher2 Name", 2010
    FILE 2:
    Catalog: Name Of Catalog 2
    "Title of Novel 1", "Genre1 name","Publisher2 Name", 2011
    "Title of Novel 2", "Genre1 name","Pulisher1 Name", 2011
    Each entity has associated a Stateless EJB that acts as a DAO, using a Transaction Scoped EntityManager. For example:
    @Stateless
    public class NovelDAO extends AbstractDAO<Novel> {
    @PersistenceContext(unitName = "XXX")
    private EntityManager em;
    protected EntityManager getEntityManager() {
    return em;
    public NovelDAO() {
    super(Novel.class);
    //NovelDAO Specific methods
    I am interested at when the catalog files are parsed and the corresponding entities are built (I usually read a whole batch of Catalogs at a time).
    Being the parsing a String-driven procedure, I don't want to repeat actions like novelDAO.getByName("Title of Novel 1") so I would like to use a centralized cache for mappings of type String-Identifier->Entity object.
    Currently I use +3 Objects+:
    1) The file parser, which does something like:
    final CatalogBuilder catalogBuilder = //JNDI Lookup
    //for each file:
    String catalogName = parseCatalogName(file);
    catalogBuilder.setCatalogName(catalogName);
    //For each novel edition
    String title= parseNovelTitle();
    String genre= parseGenre();
    catalogBuilder.addNovelEdition(title, genre, publisher, year);
    //End foreach
    catalogBuilder.build();
    2) The CatalogBuilder is a Stateful EJB which uses the Cache and gets re-initialized every time a new Catalog file is parsed and gets "removed" after a catalog is persisted.
    @Stateful
    public class CatalogBuilder {
    @PersistenceContext(unitName = "XXX", type = PersistenceContextType.EXTENDED)
    private EntityManager em;
    @EJB
    private Cache cache;
    private Catalog catalog;
    @PostConstruct
    public void initialize() {
    catalog = new Catalog();
    catalog.setNovelsInCatalog(new ArrayList<NovelEdition>());
    public void addNovelEdition(String title, String genreStr, String publisher, String year){
    Genre genre = cache.findGenreCreateIfAbsent(genreStr);//##
    Novel novel = cache.findNovelCreateIfAbsent(title, genre);//##
    NovelEdition novEd = new NovelEdition();
    novEd.setNovel(novel);
    //novEd.set publisher year catalog
    catalog.getNovelsInCatalog().add();
    public void setCatalogName(String name) {
    catalog.setName(name);
    @Remove
    public void build(){
    em.merge(catalog);
    3) Finally, the problematic bean: Cache. For CatalogBuilder I used an EXTENDED persistence context (which I need as the Parser executes several succesive transactions) together with a Stateful EJB; but in this case I am not really sure what I need. In fact, the cache:
    Should stay in memory until the parser is finished with its job, but not longer (should not be a singleton) as the parsing is just a very particular activity which happens rarely.
    Should keep all of the entities in context, and should return managed entities form mehtods marked with ##, otherwise the attempt to persist the catalog should fail (duplicated INSERTs)..
    Should use the same persistence context as the CatalogBuilder.
    What I have now is :
    @Stateful
    public class Cache {
    @PersistenceContext(unitName = "XXX", type = PersistenceContextType.EXTENDED)
    private EntityManager em;
    @EJB
    private sessionbean.GenreDAO genreDAO;
    //DAOs for other cached entities
    Map<String, Genre> genreName2Object=new TreeMap<String, Genre>();
    @PostConstruct
    public void initialize(){
    for (Genre g: genreDAO.findAll()) {
    genreName2Object.put(g.getName(), em.merge(g));
    public Genre findGenreCreateIfAbsent(String genreName){
    if (genreName2Object.containsKey(genreName){
    return genreName2Object.get(genreName);
    Genre g = new Genre();
    g.setName();
    g.setNovels(new ArrayList<Novel>());
    genreDAO.persist(t);
    genreName2Object.put(t.getIdentifier(), em.merge(t));
    return t;
    But honestly I couldn't find a solution which satisfies these 3 points at the same time. For example, using another stateful bean with an extended persistence context (PC) would work for the 1st parsed file, but I have no idea what should happen from the 2nd file on.. Indeed, for the 1st file the PC will be created and propagated from CatalogBuilder to Cache, which will then use the same PC. But after build() returns, the PC of CatalogBuilder should (I guess) be removed and re-created during the succesive parsing, although the PC of Cache should stay "alive": shouldn't in this case an exception being thrown? Another problem is what to do when the Cache bean is passivated. Currently I get the exception:
    "passivateEJB(), Exception caught ->
    java.io.IOException: java.io.IOException
    at com.sun.ejb.base.io.IOUtils.serializeObject(IOUtils.java:101)
    at com.sun.ejb.containers.util.cache.LruSessionCache.saveStateToStore(LruSessionCache.java:501)"
    Hence, I have no Idea how to implement my cache.. Can you please tell me how would you solve the problem?
    Many thanks!
    Bye

    Hi Chris,
    thanks for your reply!
    I've tried to add the following into persistence.xml (although I've read that eclipseLink uses L2 cache by default..):
    <shared-cache-mode>ALL</shared-cache-mode>
    Then I replaced the Cache bean with a stateless bean which has methods like
    Genre findGenreCreateIfAbsent(String genreName){
    Genre genre = genreDAO.findByName(genreName);
    if (genre!=null){
    return genre;
    genre = //Build new genre object
    genreDAO.persist(genre);
    return genre;
    As far as I undestood, the shared cache should automatically store the genre and avoid querying the DB multiple times for the same genre, but unfortunately this is not the case: if I use a FINE logging level, I see really a lot of SELECT queries, which I didn't see with my "home made" Cache...
    I am really confused.. :(
    Thanks again for helping + bye

  • Help! How to Create Wall Barrier for Maze Game

    Hi - I'm working on a simple maze program that has ball which is controlled by the up, down. left, right arrow keys.  I made a maze image in Photoshop and brought it into the Flash CS6 and CC (AS3). I made one wall barrier called wallDet1_mc to test before creating other wall barriers. It doesn't work. The ball goes through the wall everytime I test it.  Any help on this would be greatly appreciated.  If anyone has a basic maze with arrow keys control where their object do not cross over the wall please let me know how to do this. Thanks.

    Still doesn't work, and I was working on it and I cannot get the object (carP_mc) to not go through the wall. There has to be a code or math equation to stop it from doing this.  If the wall detection picks up the car at the wall then it should keep it away by the same amount of pixels.  What do you think?  Below is a revamped program and thanks again for your help:
    import flash.events.KeyboardEvent;
    stop();
    /* Move with Keyboard Arrows
    Allows the specified symbol instance to be moved with the keyboard arrows.
    Instructions:
    1. To increase or decrease the amount of movement, replace the number 5 below with the number of pixels you want the symbol instance to move with each key press.
    Note the number 5 appears four times in the code below.
    wallDet1_mc.enabled= false;
    var upPressed:Boolean = false;
    var downPressed:Boolean = false;
    var leftPressed:Boolean = false;
    var rightPressed:Boolean = false;
    carP_mc.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey_3);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_3);
    stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_3);
    stage.addEventListener(Event.ENTER_FRAME, everyFrame);
    function fl_MoveInDirectionOfKey_3(event:Event)
        if (upPressed)
            carP_mc.y -= 5;
        if (downPressed)
            carP_mc.y += 5;
        if (leftPressed)
            carP_mc.x -= 5;
        if (rightPressed)
            carP_mc.x += 5;
    function fl_SetKeyPressed_3(event:KeyboardEvent):void
        switch (event.keyCode)
            case Keyboard.UP:
                upPressed = true;
                break;
            case Keyboard.DOWN:
                downPressed = true;
                break;
            case Keyboard.LEFT:
                leftPressed = true;
                break;
            case Keyboard.RIGHT:
                rightPressed = true;
                break;
    function fl_UnsetKeyPressed_3(event:KeyboardEvent):void
        switch (event.keyCode)
            case Keyboard.UP:
                upPressed = false;
                break;
            case Keyboard.DOWN:
                downPressed = false;
                break;
            case Keyboard.LEFT:
                leftPressed = false;
                break;
            case Keyboard.RIGHT:
                rightPressed = false;
                break;
    function everyFrame(event:Event):void {
    var mazehit:Boolean = false;
    if (upPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.y -= 5;
    mazehit = true;
    //break;
    if (downPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.y += 5;
    mazehit = true;
    //break;
    if (leftPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.x -= 5;
    mazehit = true;
    //break;
    if (rightPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.x += 5;
    mazehit = true;
    //break;
    //End of program. Not using the codes below
    /**onClipEvent(enterFrame){
        if(this.hitArea(carP_mc._x,carP_mc._y, true)){                   
            carP_mc._x=carP_mc._x;
            carP_mc._y=carP_mc._y;
    //Keyboard Listener on stage
    //stage.addEventListener(KeyboardEvent.KEY_DOWN, theKeysDown);
    //stage.addEventListener(KeyboardEvent.KEY_UP, theKeysUp);
    //Makes MazeArt follow the movement of the path_mc
    /*addEventListener(Event.ENTER_FRAME, onNewFrame01);
    function onNewFrame01(e:Event):void{
        maze_mc.x=wallDet1_mc.x;
        maze_mc.y=wallDet1_mc.y
    function Car_P(e:KeyboardEvent):void
        //maze_mc.addEventListener(KeyboardEvent, wallDet1_mc);
        //wallDet1_mc.addEventListener(KeyboardEvent.KEY_DOWN, maze_mc);

  • Creating cache for multiple property files run time/dynamically.

    Hi,
    I have a requirement, where in I need to create cache for each property file present in a folder at server side or in the lib or resources directory. Please help me how I can do this?
    Thanks.

    ok thank you.
    I follwed this method implementation:
    static HashMap<String, HashMap<Object, String>> cacheHolder = new HashMap<String, HashMap<Object, String>>();
         static HashMap<Object, String>[] cache = new HashMap[2];
         static Integer fileCount = 0;
         static int incrementSize = 2;
    public method1(Map<Object,String>map){
    File file = new File((new StringBuilder(
                             "ABC/XYZ/")).append(value)
                             .toString()); // where value is the file name returned from the external method
                   int newSize = existingMapLength+incrementSize;
                   if (someVal== null) {                    
                        synchronized (fileCount) {
                             int oldSize = cache.length;
                             if(fileCount==cache.length){
                                  HashMap[] oldData = new HashMap[oldSize];
                                  oldData = cache;                              
                                  cache = new HashMap[newSize];
                                  LOGGER.info("New Size added:==>"+cache.length);
                                  for(int i=0;i<oldSize;i++){                                   
                                       cache[i] = oldData;
                                  cache[fileCount] = readExternalPropertiesFile(file); // external method which returns the properties of the file in hashmap
                                  cacheHolder.put(value, cache[fileCount]);                    
                                  keys = cache[fileCount].keySet();
                             else{                         
                             cache[fileCount] = readPropertiesFile(file);
                             cacheHolder.put(value, cache[fileCount]);                    
                             keys = cache[fileCount].keySet();
                             someVal= cache[fileCount];
    fileCount = fileCount + 1;
    Please let me know if any improvemnets are possible.

  • XCE129 The IPO-Step to create a cached authentication config-node for is no

    After installing B1i on a Windows SERVER 2008, and setting the B1i Server address field on SAP Business One client as:
    http://localhost:8080/B1iXcellerator/exec/ipo/vP.001sap0004.in_HCSX/com.sap.b1i.vplatform.runtime/INB_HT_CALL_SYNC_XPT/INB_HT_CALL_SYNC_XPT.ipo/proc
    i receive the following error:
    XCE129 The IPO-Step to create a cached authentication config-node for is not known: /vP.001sap0004.in_HCSX/com.sap.b1i.vplatform.runtime/INB_HT_CALL_SYNC_XPT/INB_HT_CALL_SYNC_XPT.ipo/proc
    Any suggestion?
    Thanks

    Roberto,
    Please see the B1iC troubleshooting guide ...
    [Guide Deleted 31 OCT 2011 - Contained Out of Date Information]
    Eddy
    Edited by: Jason Lax on Oct 31, 2011 10:45 AM

  • How do I create a "command-line-interface" for a game?

    Hey people,
    For a game I need to make a DOS-like command-line-interface where the user has at least 3 options to answer with, does anyone know how to go about this?
    Hope someone here can help me out!
    Kind regards,
    Angela

    I'm not sure what part of this you are having difficulty with. Imagine for a moment that instead of asking for your end user to type something into a text-entry field and to monitor what they type (perhaps when the ENTER key is pressed), that instead you provide 3 buttons on your stage. Responding to a button press in this scenario is much the same as responding to typed user input - your movie does something based on user interaction. Going back to the user entered text scenario, a text or field sprite can detect the ENTER key being pressed and examine the string the user has entered, something like:
    on keyDown me
      if _key.keyCode = 36 then
        stopEvent
        sText = sprite(me.spriteNum).member.text
        case sText of
          "hack": -- do whatever you need to here
          "research":
          "wait":
          otherwise:
        end case
      else
        pass
      end if
    end

  • K9N neo - F, Stuttering / harddrive over reading / caching noticeable in games.

    I've been experiencing a really strange issue, my hard drive seems to be over reading / caching , It's mostly noticeable in BF2, and in world of warcraft, it sputters for a split second then the game goes back into smooth game play. It happens every 20 seconds or so really irritating lol. My settings for the games are medium detail levels nothing to taxing on the ram, the system I had previously 3000+ w/ DDR 400 1 gig and a 9800 pro I had no issues and it actually loaded maps faster under the same graphic settings. One harddrive is a sata samsung 160 gig, the other is an IDE 120 gig western digital. Both 7200 rpm 8 megs cache. The previous system I had ran these games fine with no issue under the same graphic settings, so it's really odd.
    Some of the things I've tired:
    I tried using a totally different hard drive with the OS / games and it does the same thing
    I've ran a diag tool on both harddrives and they check outfine
    I've checked out the ram specs and tried setting them manually, 5 5 5 12, and using auto (thinking it may be something with the ram possibly.)
    I've disabled SMART in bios which didn't do anything.
    I've messed around with disabling spredspectrum which didn't do anything
    I tired using on board sound and ditching the audigy thinking mabey the sound was causing lag issues, cause when it sputtered the sound would lag for a split second, unfornately didn't do anything.
    Any suggestions would be greatly appericated, it's a really strange issue that I haven't encountered before, tried everything I could think of. Thanks.

    Not sure about it. Have you tried to benchmarks for the HDD? Did you do any bios flashing recently? Have you tried reset the bios? If increased the PCI-X bus to 104MhZ is there any different?    
    Quote from: slicksickwilly on 22-August-06, 11:47:07
    I also play WoW.. I get the stuttering too. I cant completely get rid of it but i got it down to a minimum. If i read your post right you have 1gig of ram.. Same here. WoW runs best on 2 gigs. When you hearth into IF or ride the gryphon there are so many new items/textures loading that your pagefile is working overtime hence the hard drive light is in contant flicker. The best solution as i said is to get 2 gigs of ram.. Another solution that i used that seemed to help is to set my pagefile to a diff hard drive. I run 2 Seagates 8meg cache 7200 rpm and disabled pagefile on drive c and put it on drive f. By putting it on another drive it will run faster with less hickups as you utilize both drives for better performance instead of one. If you want to try it let me know ill tell you how..
    Please create your own rig and post it in details including the PSU and Bios revision so others can help you!! Not sure if your HDD need to update the firmware from the Seagate if you're using the SATAII. Gd luck.

  • Error ACLContainer: 65315 does NOT EXIST in  the Object Cache for parentID:

    Expert,
    I did the following steps to upgrade the OWB repository from 10g to 11g
    • Created a dummy workspace in the 11.2 repository
    • Created users in the destination environment
    • Run Repository Assistant against the 11.1 source database
    • Then selected *“Export entire repository to a file”* and selected the MDL(10g) to import
    After 99% of completing I have got the below error
    Error ACLContainer: 65315 does NOT EXIST in  the Object Cache for parentID: 65314
    Please let me know the solution.
    Thanks,
    Balaa...

    Hi I had the same error and worked on it for almost a week with no success but there is few work around for this try it it might work for you.
    Step 1>Run a health check on OWB 10.2 enviroment(make sure you clone your OWB 10.2 enviroment and then do this healthcheck ,these checks are tricky )
    refer
    Note 559542.1 Health Check of the Oracle Warehouse Builder 10.2 Metadata Repository
    This will give you info about your missing ACL
    Step 2> download these two scripts fixLostACLContainer.sql ,fixAllACLContainers.sql
    please refer :
    Note 559542.1 Health Check of the Oracle Warehouse Builder 10.2 Metadata Repository
    OWB 10.2 - Internal ERROR: Can not find the ACL container for object (Doc ID 460411.1)
    Note 754763.1 Repository Cleanup Script for OWB 10.2 and OWB 11.1
    Note 460411.1 Opening Map Returns Cannot find ACL Containter for Object
    Note 1165068.1 Internal Error: Can Not Find The ACL Containter For for object:CMPPhysical Object
    It might resolve this ACL issue but it did not work for me.
    If none of these work then
    Perform export from design center of OWB 10.2 and import through design center of OWB 11.2.(ONLY OPTION)
    It worked for me.
    Varun

  • Use Redis Cache for Multiple Applications

    Hi,
    I did some searches and could not come up with a straight forward answer so I am hoping someone here can clarify this for me.
    We have two different products that we have built in .NET that we host in Azure as websites. For each of these two products we have multiple clients. Each product and client pair has its own SQL database and its own website setup in Azure.
    We would like to start using Redis Cache for the session of these products. Do I need to:
    1) Create 1 Redis Cache and use it for all clients / products?
    2) Create 2 Redis Caches and use one per product (redis caches needed = # of products)?
    3) Create an individual Redis cache for each client / product pair (redis caches needed = # of products x # of clients)?

    You can do either of the above. It would really depend on how much load are you expecting on the Cache
    For separation and load balancing it might be better to have a Cache per Website
    For a Cache to be useful it should be closer to the Web tier, so ensure that you provision the Cache in the same region as the Website.

  • Where can I find a good tutorial for mobile game developement with J2ME ?

    Hi All,
    I'm completely new to J2ME programming. But I have past experience on J2SE developement. Now I would like to know that where can I find a good tutorial for mobile game developement with J2ME ?
    I'll be very greatful if I can find a useful step-by-step tutorial (eg. "The Java Tutorial" for J2SE)
    Please point me ot the direction.
    Thanks
    ZuriJAckshoT

    ibook-widgets.com    have a free tutorial book in the iBooks store.  Search for "Create your first interactive book using iBooks Author"   they also  sell widgets.
    I  dont have any connection - I  found their eBook in the store long ago  and used it to learn more about iBA.
    The best advice though, is be patient,  go back over the process step by step, I cannot  access the Help files for some reason.. but i am sure its in their.

  • Creating a texture for a rounded window

    Hi.
    I'm creating a simple gui on a game framework based on lwjgl and I have a problem.
    Almost every window has a solid black texture as a background. I came up with a idea to make corners rounded. At the beginning I created gif picture of a rounded square and used it as a background texture. But it wasn't a good idea, because the corners had different sizes depends on windows sizes (and how much texture was stretched). I've decided that I have to create a texture dynamically every time a window is created.
    public void makeBackground() {
            // the texture size must be multiply of 2
            int tWidth = 2;
            while (tWidth < getWidth()) {
                tWidth *= 2;
            int tHeight = 2;
            while (tHeight < getHeight()) {
                tHeight *= 2;
            Texture t = new Texture(getWidth(), getHeight()); // new texture is created with width and height same as the window size
            int px, py, ox, oy; // some variables
            final int pw = getWidth(),  ph = getHeight(),  hww = tWidth; // as above
            ByteBuffer bb = t.getData(); // blank texture is converted to a byte buffer
            Utils.startStoper(); // start timer (for a benchmark)
            try {
                for (int p = 0;; p++) {
                    px = p % hww; // get the X of the pixel
                    py = p / hww; // get the Y of the pixel
                    ox = ROUND_ANGLE - Math.min(px + 1, pw - px + 1); //  ox = <0, 32> if near corners
                    oy = ROUND_ANGLE - Math.min(py + 1, ph - py + 1); //  as above
                    bb.put((byte) 0); // r = 0
                    bb.put((byte) 0); // g = 0
                    bb.put((byte) 0); // b = 0
                    if (ox > 0 && oy > 0) {  // if near corners
                        double hypot = Math.hypot(ox, oy);
                        if (hypot > ROUND_ANGLE) { // if outside the corner
                            bb.put((byte) 0); // apha = 0
                        } else if (hypot > ROUND_ANGLE - 1) { // if on the corner edge
                            bb.put((byte) Math.round(
                                    (ROUND_ANGLE - hypot) * 200));
                        } else {
                            bb.put((byte) 200);  // if inside the corner (200 is a max value cause the whole window is a bit transparent)
                    } else {
                        bb.put((byte) 200); // inside the window
            } catch (BufferOverflowException ex) {
            Utils.stopStoper();  // stop timer
            t.setData(bb);   // set data for a texture
            super.setImage(t);  // set texture as a background
        }And here we have a problem. The whole method takes about 70ms for a window 200x200.
    I can do it in another way: create a pictures of a rounded corner and a black box. The box would be the window inside and the corner would loaded 4 times each time rotated. Only the box would be stretched then. But I would have to override all methods of a window (setX, setY, setXY, some more).
    Any ideas?
    Thanks.
    Edited by: tom_ex on 2009-02-17 16:58

    Hi Tom,
    I haven't used lwjgl, so hope the following helps:
    1- What does it matter if it takes 70ms. Your windows will be created once. At that point juste create the texture for that window and store it until you destroy the window. The penalty hit is 70ms but only at the initialization.
    2- You are drawing a pixel at a time for everything. Why don't you calculate the area of the corners and only draw the corners a pixel at a time. For the rest, draw some filled polygons.
    3- The java Graphics object has method fill methode that can take any Shape object. Why don't you use that?
    I would use a combination of 3 and 1.
    Hope that helps.
    Ekram
    Edited by: ekram_rashid on Feb 18, 2009 2:21 PM

  • Using disk images for learning games?

    Hello, I've 2 g3 imacs running 9.2.2, and they are for the grandkids to use learning games on.
    The kids are very hard on the software disks. When I found out about disk images I made them up, now to install them properly. The games are installed, but where to store the disk images? The desk top icons for the games will work after the disk images have been double clicked and the mounted disk image appears on the desktop, but when the imacs are turned off the mounted disk image is lost. How or where does one put the disk images in a safe place so the kids don't get at them, and the disks are mounted every time, without actually starting, when the Mac is started? Start up menu?
    I'm planning on multiple accounts with them having a standard account with game privileges so they don't mess the whole thing up. If their accounts get too messed up for me to repair I figured on maybe deleting the account and opening up a new one? Any Ideas are very welcome.
    Thank you,
    EZ

    Hi, EZ -
    You're quite welcome.
    I had a thought with regard to the disk image files. Are they in a .smi format, or are they in a .img format?
    The .img format requires the assistance of the Disk Copy utility in order to mount the image. This is the standard format generated by the user version of Disk Copy. It requires that Disk Copy be available to Finder to act as a helper app in order to mount the image.
    The .smi format does not - .smi stands for Self-Mounting Image. The user version of Disk Copy can not make this format; but I have seen a utility to convert .img format to .smi format. The slight advantage with this format is that Disk Copy does not need to be available to Finder.
    In both cases the default is to run a checksum verification before the image is finally mounted. The delay caused by this verification can be inconvenient - verification is intended to confirm the integrity of the image after it has been copied, transported, or downloaded, but is usually not necessary when the image resides on a hard drive.
    The checksum verification for .img file types can be removed. With the image not mounted, open Disk Copy. In Disk Copy's Preferences (Edit menu), uncheck the Verify Checksum item. Save the Preferences window. Then select Convert Image from the Image menu, navigate to the disk imge file from which you want to remove the verifiaction, select it and click the Open button. A new window will appear, similar to a Save As type window. Leave everything in that window untouched (unless you want to change the base name of the file - the extension .img should be left intact) and click the Save button. The image will be mounted, the original disk image file will be deleted, and a new disk image file created. Unfortunately creating the new image file takes quite a while since it is creating a new one, not actually modifying the old one - but it does get rid of the intrusion of the checksum verification requirement.
    I verified on my G4/500 running OS 9.1 that a .img file (one I had made from a game CD years ago) dropped into the Startup Items folder will be mounted automatically at the end of the startup sequence. I also tested with an alias to the .img file, and it, too, worked fine - the disk image was mounted automatically at the conclusion of the startup sequence.
    When you make the alias to the disk image file (the .img one), be sure you are placing it into the Startup Items folder, and not the Startup Items (disabled) folder.
    If you have the machine set to use Simple Finder (which removes Finder's keyboard commands and many menu options for Finder), that may interfere with items in the Startup Items folder being run at startup. Or, it may not - I have not checked that.
    *** Edit ***
    I have verified that the alias to a .img file will mount the disk image even when the machine is booted using Simple Finder.
    Another thought, related to Multiple Users - if you do decide to set up Multiple Users, and the disk images are of type .img, be sure to authorize Disk Copy for each of the accounts for which the disk images are to be mounted. If you have the disk image files in a .smi format, since Finder views that file type as being an application, you would need to authorize each of those disk image files for each account which is to have access to them.

  • Seeding the cache for all users

    We are facing some performance issues (even after using aggregate tables) and are looking into seeding the cache for all users so that the dashboard pops up immediately.
    So far I couldn't make it work. As Administrator I created an iBot to run a report for 1 month (dashboard has a dashboard prompt on the period) with Data Visibility set to 'Personalized (individual data visibility)' as I understood from the manual this is the way to seed the cache for all users. Now when I log on with my personal userid and set the prompt value to that specific period it is not using the cache.
    Obviously destination was set to 'Oracle BI Server Cache' and cache has been turned on.
    Does anyone have any suggestions ?

    We are facing some performance issues (even after using aggregate tables) and are looking into seeding the cache for all users so that the dashboard pops up immediately.
    So far I couldn't make it work. As Administrator I created an iBot to run a report for 1 month (dashboard has a dashboard prompt on the period) with Data Visibility set to 'Personalized (individual data visibility)' as I understood from the manual this is the way to seed the cache for all users. Now when I log on with my personal userid and set the prompt value to that specific period it is not using the cache.
    Obviously destination was set to 'Oracle BI Server Cache' and cache has been turned on.
    Does anyone have any suggestions ?

  • Usage of Object Cache for Java in J2EE apps

    Hi,
    we are investigating on whether we can use the Object Cache for Java
    (OCS4J) for our requirements. The question we have come across is:
    What is the designated way of integration for the Object cache to fit
    into the J2EE environment? Unfortunately, although the current manuals
    group OCS4J into the "Oracle Containers for J2EE Services Guide" and the
    suggested package name for the whole thing in JSR 107 seems to be
    javax.util.jcache, there is very little documentation on how the
    designers would like J2EE programmers to use the cache from within a
    J2EE app and all examples given are not from within a J2EE environment.
    We are in particular thinking about a hierarchy of several cache
    "compartments" (Region->Subregion->group) for different topics and using
    the hierarchical name of the cache (region.subregion.group) as the
    primary key for BMP Entity beans, each of them having their own
    CacheAccess object. Then we would have an API of stateless Session beans
    on top of that, which would be determining the cache "compartment", get
    the appropriate Entity Bean with the Cache Access object and then do the
    required operations on the cache.
    But then we immediately run into the question of how the mapping between
    Cache Objects and CacheAccess objects will be done etc.
    So is there anybody that can give us any hints how to use the OCS4J in
    an EJB scenario?
    Thanks in advance for any help!
    Andreas Loew
    [email protected]

    We have Java client requesting over HTTP to application server. We would like to cache some of the objects created by the servlet while serving the request. Can I use the OCS4J for caching the Java objects. Do I require any software or just copying the JAR file and importing the class would serve the purpose?
    Regards
    Arun

Maybe you are looking for

  • How to get coordinates of a ROI in an image in Labview

    Hi, I have a question regarding image processing in NI-IMAQ. I have Ni-IMAQ module available, soon I may acquire NI-Vision too. I have an image file and I would like to draw a rectangle as Region of Interest (ROI) and be able to get the coordinates o

  • TS1717 error message New itunes library

    I hit the itunes icon on my home screen and the small error message box opens up and says "New itunes Library" with a "ok" tab..nothing else happens I'm running windows 7.  It worked less than one week ago, now nothing!

  • Stateless Release mode and the Commit issue

    What are the implications of setting all the application modules to Stateless Release mode rather than Stateful? I've read the documentation about this, but I need hands on expert's opinions Specially for a Web Application that a lot of public users

  • Burning files across multiple CDs or DVDs

    I have 5GB of files in one folder on 2 DVDs (Can only put 4GB on one DVD) without breaking them apart. Is there a way to do this in OSX? Maybe a script or 3rd party application? Right now I used Stuffit Deluxe to make 4GB archives. Wondering if there

  • Buying a factory unlocked iphone from US(Apple Store) to use in india.

    Hi one of my friend is bringing me an iphone 5s to India.. yayy it would be factory unlocked and will be purchased from apple store. my primary concerns are do i need to activate iphone via itunes(or is it ready to use). And do i need to have a backu