A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Best way to create a non-tile-based scrolling platformer?

  1. #1
    Member
    Join Date
    Apr 2006
    Posts
    37

    Best way to create a non-tile-based scrolling platformer?

    I currently know of two ways to do this:

    1.) Make a huge movie clip containing the shape of the level boundary, and have your hero hitTestPoint against the whole thing. I'm pretty sure this method has crazy performance issues, but it sure is easy to code.

    2.) Make a bunch of boundary movie clips on the stage, dump them into an array upon start-up, and have your hero hitTestObject against each one. I think this way works best when optimized.

    Speaking of optimization...
    - Is it easy to hitTestObject only what appears on-screen?
    - Is disabling items/enemies off-screen as simple as using a for loop every frame?
    - Does HitTestObject vs diagonal boundaries have to be as messy as I think it is? (I have a book on this where you have to reset the object's coordinates based on the rotation).

    Any tips would be appreciated. I probably don't need code examples.

  2. #2
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    Your "1" solution can be thrown in the dump unless you are aiming for a serious crappy performance along with a load of other issues like image size restriction in flash to be the least. Your "2" solution, with optimizations, is tile-based design in it's essence.

    Tile based design doesn't mean level design with blocky bitmap images and a lot of code dealing with the level data. Tile based design, simply means breaking your entire display area, in this case the level, into manageable chunks so as to improve performance and have certain other benefits like easy A*, boid and other AI algorithm implementations.



    Now, hitTestPoint and Object are kind of both cpu hogs, and aren't really very important normally, you can get away with distance testing and such, since flash doesn't really test the actual shape anyway. However, if you are doing everything with movieclips, visually, then you would be better off with hitTestObject, the point based hittest is useful when you work with bitmapData, and in that scenario it is better for the performance.


    Just disabling something or removing them from stage doesn't remove them from memory, and they will keep affecting your performance, unless you clean them up and their references properly. Read up on garbage collection in flash to know more.


    The hittesting with diagonal boundaries can be quite...umm...complicated depending on what kind of effect you want exactly, but frankly, there are a lot more complicated things in a platformer than a diagonal boundary or simple-slopes.
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  3. #3
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    You can also make a BitmapData engine and check the color of the pixel to see if its solid
    I guess thats how the latest nitrome game works

  4. #4
    Member
    Join Date
    Apr 2006
    Posts
    37
    Hey guys, thanks for the responses. Just gotta ask one follow up question.

    If I go with the brute force method of hitTesting all the platform objects... is there a way to like, not do that? I thought about reorganizing the platform array based on their X positions, then stopping the loop once I detect a hit. Of course, this won't do anything if I'm at the end of the stage. I've seen some interesting grouping variations out there, but they're used to test ALL the objects against one another. I don't need to check platforms against other platforms.

    Again, I'm just doing something really simple, but aligned to no type of grid. I don't want to do something mathematically ridiculous just to get a couple more frames per second, but I would like it to run somewhat smoothly.

  5. #5
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Quote Originally Posted by Sub Tank View Post

    If I go with the brute force method of hitTesting all the platform objects... is there a way to like, not do that?
    Yes
    http://lab.polygonal.de/2007/09/09/q...demonstration/

  6. #6
    Member
    Join Date
    Apr 2006
    Posts
    37
    Oh cool, I was looking for that link.

    I feel like a grid tree system would totally screw with how I plan to lay down platforms for stages. RDC might be more like what I need, although I'll have to figure out how to reprogram that so platforms don't perform collision detections with other platforms.

  7. #7
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    You can also just divide your space into zones like big big tiles and put your platforms inside
    Then each frame just check what zone the guy is and hitTest him against the platforms inside

  8. #8
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Incrue: you essentially described the Supertile approach. He didn't want to use tiles.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  9. #9
    Funkalicious TOdorus's Avatar
    Join Date
    Nov 2006
    Location
    Nijmegen, Netherlands
    Posts
    697
    Quote Originally Posted by ImprisonedPride View Post
    Incrue: you essentially described the Supertile approach. He didn't want to use tiles.
    Isn't that like calling a 3D game that uses a quadtree to eliminate collisionchecks and unnecessary polygon rendering tilebased?

    I agree with Incrue. If you want to eliminate checks the easiest way is to use some form of spatial indexing.

  10. #10
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Quote Originally Posted by TOdorus View Post
    Isn't that like calling a 3D game that uses a quadtree to eliminate collisionchecks and unnecessary polygon rendering tilebased?
    No more so than using repeating quadrilaterals as "spacial-indexing" and calling it non-tile based hit-testing.
    Last edited by ImprisonedPride; 07-11-2010 at 12:21 AM.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  11. #11
    Funkalicious TOdorus's Avatar
    Join Date
    Nov 2006
    Location
    Nijmegen, Netherlands
    Posts
    697
    Quote Originally Posted by ImprisonedPride View Post
    No more so than using repeating quadrilaterals as "spacial-indexing" and calling it non-tile based hit-testing.
    I dare to do so

  12. #12
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    Well I am not going to argue on what's tile-based and whats not, but as I said before, to me, the concept of tile based approach is in splitting the entire game world into smaller, manageable pieces to increase performance. Whether you use quad-tree or some spatial indexing, the basic concept is the same......and though it is the best approach in this scenario, I think the topic's creator was originally aiming to avoid it.
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  13. #13
    Senior Member
    Join Date
    Jan 2010
    Posts
    126
    A tile based game is a game that uses tiles for the whole pipeline, level design, rendering etc.

    Even 3D games use spatial grids as a collision broadphase, it doesn't make it a tile based game.

  14. #14
    Funkalicious TOdorus's Avatar
    Join Date
    Nov 2006
    Location
    Nijmegen, Netherlands
    Posts
    697
    Glad you said that rumblesushi. It would've come of a little biased from my side Supertiles is a bit of a unlucky name for the concept.

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