×

Discussion Board

Results 1 to 6 of 6

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    83

    Question Loading Resources in Game

    Hi,

    I want to ask about loading resource(s)in game.
    As per now I have two ideas of loading resource(s)
    1. To load all the resources(sound & images) before the game starts.
    2. Or to load and unload images depending upon state of game . For example main menu background should be unloaded while entering to game and game background should be unloaded while entering main menu.

    Which of the above two ways can optimize the game play more. And are there another ways to do resource loading ?

    My another question is that I am testing a game developed by me on phones like MOTO V3i, but the game hangs and after compressing the images, I can run the game but game play is very slow, compared with other phones like K810, N70.
    but when I install other online available games on V3i, whose game play is similar to my game, these games run faster than my game.
    what might be the problem which makes my game slow?

    Thank you for you time to read my post and looking forward for replies.

    Kai

  2. #2
    Registered User
    Join Date
    Jun 2009
    Posts
    1

    Re: Loading Resources in Game

    here,this are the way to make a game loading screen:
    Usually we do it in 2 different ways for showing a realistic progress bar.
    1) If we have 50 images to be loaded for every level, we increase the progress by 2 after loading every image successfully. This is the simplest way you can do it and its the most efficient way doing it though not exactly a realistic one.
    2) You can create a separate thread for showing the progress bar and use different thread for loading the resources. After every resource is loaded you have to increase the progress according to the size of resources loaded. This is not recommended as threading is always an issue in many devices. And knowing the percentage of a single resource loaded cannot be determined using J2ME.
    ___________
    Børnetøj
    sexy lingerie

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Loading Resources in Game

    Quote Originally Posted by kai_buki View Post
    I want to ask about loading resource(s)in game.
    As per now I have two ideas of loading resource(s)
    1. To load all the resources(sound & images) before the game starts.
    2. Or to load and unload images depending upon state of game . For example main menu background should be unloaded while entering to game and game background should be unloaded while entering main menu.

    Which of the above two ways can optimize the game play more. And are there another ways to do resource loading ?
    This is not just a matter of "optimization". Many phones will not have enough memory to load all the images at the same time. Yes, you should load the images you need for the given state. States would include "splash screen", "menu", "game level 1", "game level 2" (for games that use different images in different levels).

    Quote Originally Posted by kai_buki View Post
    My another question is that I am testing a game developed by me on phones like MOTO V3i, but the game hangs and after compressing the images, I can run the game but game play is very slow, compared with other phones like K810, N70.
    but when I install other online available games on V3i, whose game play is similar to my game, these games run faster than my game.
    what might be the problem which makes my game slow?
    The V3i has much less memory and much less cpu performance than the K810 or N70.

    Nokia Series 60s make a very bad choice for game development, if you hope to run your game on a wide range of devices. They are fast, and they have much more memory than other devices. The V3i is actually quite a good choice, because it has limited performance and memory. If your game runs OK on a V3i, it will run well almost anywhere! :)

    Without knowing much about your game, or the games you're comparing it with, it's hard to say why yours is slower. A game on a V3i should be able to run at around 10 to 15 frames per second. Possibly, you are making too many calls to drawImage(). It is usually faster to draw a small number of large images, than a large number of small images.

    Graham.

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Loading Resources in Game

    Hi,
    And Grahm,He must check that images are creating in the loop.If you will create the images in a loop then I am more then sure that it will hang the game.Please check that you are not loading the any resource in loop.

    AFA then drawing is concern,you must not call the repaint() in a infinite loop,if not required,then call the repaint() on the keypressed().This is also a critical factor for the frame rate of the game.

    Please check that whether you are not doing this.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Loading Resources in Game

    Hmmm... not sure what you mean by not doing work in loops... if he's using the "two thread" model, then I'd everything I possibly can inside a loop.

    Code:
    public void run() {
        while (state != STATE_EXIT) {
            long startTime = System.currentTimeMillis();
    
            // game logic
            int nextState;
            switch (state) {
            case STATE_LOADING_PLAYER_IMAGE:
                playerImage = loadImage("/player.png");
                nextState = STATE_LOADING_ENEMY_IMAGES;
                break;
            }
    
            // allow screen to update
            repaint();
            serviceRepaints();
    
            state = nextState;
    
            // regulate frame rate
            long endTime = System.currentTimeMillis();
            long elapsed = endTime - startTime;
            long sleepTime = FRAME_DURATION - elapsedTime;
            if (sleepTime < MIN_SLEEP) {
                sleepTime = MIN_SLEEP;
            }
            try {
                Thread.sleep(sleepTime);
            } catch (InterruptedException e) {
                // ignore: doesn't happen on CLDC-1.0 anyway
            }
        }
    }
    In this model, putting repaint(), or any game logic, inside the keyPressed() method means you will have two threads updating the game state in parallel, and screen updates occuring while the game state is only half updated. I have seen many games with game logic in the keyPressed() method, and they always prove problematic in porting, even though they may behave fine on the original device (usually a Nokia) they were written for.

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Loading Resources in Game

    Hi,
    By the loop I mean to say that images are not created in the method gets infinite calls.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Game loading bar
    By kai_buki in forum Mobile Java Games
    Replies: 9
    Last Post: 2009-06-15, 05:23
  2. MBM image is not found
    By tamhanna in forum Symbian
    Replies: 14
    Last Post: 2009-04-20, 12:44
  3. Loading to the Game Folder, 3650
    By fumes in forum Mobile Java General
    Replies: 3
    Last Post: 2003-09-08, 23:40
  4. How to show loading screen before game start??
    By icq98hk in forum Mobile Java General
    Replies: 2
    Last Post: 2003-07-08, 09:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×