A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Metroid game speed issue help!!!!

  1. #1
    Senior Member
    Join Date
    Nov 2007
    Location
    California
    Posts
    118

    Unhappy Metroid game speed issue help!!!!

    http://megaswf.com/view/7199acb694d7...202507138.html


    Thanks for the feedback from before everyone!! I took the recommendations and put them into effect but... It runs crazy slow ^up there^. I read up on caching bitmaps and copyPixel functions but it looks REALLY complicated and I would most likely have to redo everything to go into that type of engine. Is there a simpler way to combine some of my art base AS and the caching of the background or will i have to try and overt to super crazy tile based actionscripting?

    Any help? I know everyone says "performance is an issue" but games like http://www.2dplay.com/metroid-elemen...ments-play.htm are very simplified and seem pretty half assed (no offense). It does run faster but is not as complicated and does not use a lot of the things i put into the game. Help?

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    some suggestions:
    a.) _quality="LOW"; boosts alot. You can cache aliased fonts and other vector graphics ahead using cacheAsBitmap or the BitmapData.draw(); method to store it into a bitmap ahead and then display inside a Bitmap object. (Flash 8+).

    b.) scrollRect in combination with sprite sheets. Its supposed to be very fast- far quicker than gotoAndStop(x);

    c.) as suggested earlier, movieClip.cacheAsBitmap = true;. This works best on composed movieClips or vector graphics inside movieClips that do not alter.

    d.) use as less EnterFrame events as possible and also rather avoid the Flash5 style onClipEvent(enterFrame){ but better just one_root.onEnterFrame = function(); the _root level.

    e.) In the main frame loop use as less for() loops as possible. So if you have objects to loop through (e.g to check for collisions) - try to reduce them as much as possible.
    Also if possible try to prepare as much as possible in the initialization state. Usually things that can be prepared are static sprites, objects or triggers that do not change within the gameplay - some devs also like to compile their levels and prepare stuff when exporting the level (e.g shadow map, AI - paths,...). Try to do similar things in your engine if possible.

    f.) you might check out some of the general collections of little Actionscript performance optimizitions , like
    http://www.visualharmonics.co.uk/act...optimizations/
    http://iliketoplay.dk/blog/archives/71

    g.) start learning AS3 - usually things run like 10x faster. Though if you use of course a plain artBased engine its not something that can really benefit of it - because of the brute- force nature of it. But if you have loops and bitmap intense stuff it will defentily run alot faster.

    I am not sure if I posted some of these tutorials on that prior thread before but they might be worth a read for you:

    strille and his super tile concept (so you can quicker pick out tiles out of a complex and massive map.
    http://www.strille.net/tutorials/part1_scrolling.php

    my own attempt on minimalistic tile- scrolling
    http://board.flashkit.com/board/showthread.php?t=743951
    and used in a demo (better to demonstrate the effect):
    http://www.renderhjs.net/bbs/flashkit/tank_move/demo14/

    outside of society - in the flash 5 days a very good source for developing tile- based engines
    http://oos.moxiecode.com/

    tonypa's tile tutorials
    http://www.tonypa.pri.ee/tbw/start.html

  3. #3
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    if you could explain in depth the scrolling method you are using we could try and break down the flaws *if any.

    Its hard to know what you are doing.

    Maybe a brief explanation of a single pass of your game loop would help a lot.
    lather yourself up with soap - soap arcade

  4. #4
    Senior Member
    Join Date
    Nov 2007
    Location
    California
    Posts
    118
    Heres a snippet of my scrolling code from an onClipEvent placed on the main character.
    PHP Code:
    } else {
            if (!
    _root.bg.hitTest(_x-_global.barvar-(_width/2), _y-35true) and (!_root.bg.hitTest(_x-_global.barvar-(_width/2), _y-40true)) and (!_root.bg.hitTest(_x-_global.barvar-(_width/2), _y-30true))) {
                if(
    _root.bg._x <= _global.left_scroll and _root.watermelon_whole._x <= 160){
                
    _root.fly._x -= _global.speed;
                
    _root.bg3._x -= _global.speed;
                
    _root.bg2._x -= (_global.speed /2);
                
    _root.bg._x -= _global.speed;
                
    _root.floater._x -= _global.speed;
                
    _root.bg_block._x -= _global.speed;
                
    _root.hornoad._x -= _global.speed;
                
    _root.robo._x -= _global.speed;
                
    _root.owtch._x -= _global.speed;
                
    _root.waver._x -= _global.speed;
                
    _root.reo._x -= _global.speed;
                
    _root.sidehopper._x -= _global.speed;
                
    _root.spires._x -= _global.speed;
                
    _root.spirem._x -= _global.speed;
                }else{
                    
    _root.watermelon_whole._x += _global.speed;
                }
            }
        } 
    I also use hittesting for ceilings the same way for example
    PHP Code:
    if (_root.bg.hitTest(_x_y-50true)) {
            
    _global.yvel 10;
        }
        if (
    _root.bg.hitTest(_x+_global.barvar+(_width/2), _y-30true)) {
            
    _global.speed *= 0;
        } 
    and so on. I tried looking and implementing tonypa's tile based stuff but i started from scratch and its a pain in the bum to understand. I like my clipevent coding because i can define stuff so much easier but i would also like to find a way to generate tiles but keep the coding on the main character. Any way to do so? Or is there more code needed?

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center