A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: [SHOW] platform engine

  1. #1
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188

    [SHOW] platform engine

    I like making platform games... So now I'm taking a break from my rpg to work on my ultimate (=reusable) platform engine. Here's what I've got after a couple of hours of work :

    http://www.crossconscious.com/platformer/

    Not much game-wise, the camera movement is very basic at the moment, but you can jump, double jump, float (keep jump pressed), and jump down (press down on the gray platforms).

    No vector math was used, because I suck at vector math. It uses a grid of seperate "invisible" bitmaps to check for collision, ie you can walk through white pixels, but not through black pixels, and gray pixels you can walk/jump through, but you can also stand on them. With this system, almost any shape is possible. (In the demo, the actual tiles are the same, but they don't have to be).

    Comments on the overall feel are welcome, and let me know if you find any bugs.

    Next up will be moving platforms and a finite statemachine system with pathfinding for enemy AI. That will be a challenge I imagine, I know how to do it in a topdown game, but for a platform game it doesn't seem so easy.

    Also, anyone know where I can find a free platform tileset, with a variety of tile shapes (slopes, etc)? A rip would be ok, it's just for use during development.

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    so a cheating engine aka art based engine? not sure if I understand the collision checking but wouldn´t vector math be way faster with bigger maps and more complex scenes?

  3. #3
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    No it's completely tile based. You have the display-tiles, and a grid of invisible shapes (which, in this demo, would look the same as the display if you would display it). It's just a 2d array of bitmaps, and if I need to know if a point hits something, I only have to check one bitmap - divide the coordinates by 32 (or whatever) to find the right tile, and then check the bitmapdata with getPixel. So I think that's pretty performant even for big maps. I've done something similar with AS2 in a few games, and it ran smoothly, so in AS3 it won't be a problem at all.

    Off course, the "physics" are more complex than that. Basically, I move my character down the amount of DY, and while one of his bottom points (I use 3 here, but two is enough if you don't have spike-shaped land) hits something, I move it back up until it doesn't hit anymore. Well, that's the jist of it, it uses a lot more logic than that (checking for walls or when bumping with the top, etc), but I can't explain the entire engine.

  4. #4
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    The principles behind ai should be the same as top-down. Just consider your level in the same way as a top-down map, but with restrictions on movement - ie gravity. If its path based, your paths move along platforms and through jump and fall points at the end of platforms.

    Nice engine, btw. Looks very art-based, but thats only because my best attempts have been.

    Btw, art-based is incredibly re-usable - designers can go in and change the level assets easily. If you're targeting it at other developers then disregard this point.

  5. #5
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    It's smooth, I have to say that. Very nice scrolling. 2 bits of error:

    Your angle collision on slopes wrong based on TonyPA's projections of realistic slope collision. (The character's bottom center point should touch the ground, not the corner.)

    Also, when jumping sideways into a platform (a black one that isn't a "cloud"), the character was able to go right through it and "glided" to the ground.

    It's a start, at least.
    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

  6. #6
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Thanks for the comments! I've updated it a bit, upward slopes now slow you down a bit, whereas downward slopes go faster, and you glide down them just a bit.

    The principles behind ai should be the same as top-down. Just consider your level in the same way as a top-down map, but with restrictions on movement - ie gravity. If its path based, your paths move along platforms and through jump and fall points at the end of platforms.
    Thanks. I was thinking along similar lines. The only problem I'm having is that if a certain enemy can't jump as high as others, hed have to (try to) find a different path sometimes. But I'm sure I'll come up with something.

    Btw, art-based is incredibly re-usable - designers can go in and change the level assets easily. If you're targeting it at other developers then disregard this point.
    It uses a tileset image (or more than one per level), and levels are made with Tiled, so it'll be pretty easy to create a new game with it.


    It's smooth, I have to say that. Very nice scrolling.
    It uses my new and improved scrolling engine. It works fairly well, but could still be improved.

    Your angle collision on slopes wrong based on TonyPA's projections of realistic slope collision. (The character's bottom center point should touch the ground, not the corner.)
    Yeah... But I can fix that without changing the code. I use a collision tileset, and I just have to move the slopes down a bit, without changing the displayed tiles.

    Also, when jumping sideways into a platform (a black one that isn't a "cloud"), the character was able to go right through it and "glided" to the ground.
    Damn, I've tested it a lot and haven't seen this happen. It's always hard to fix errors you can't reproduce... Thanks for bringing it to my attention though.

  7. #7
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Actually I misspoke myself, it was suppose to say "a gray one that is a cloud". The glide error still happens, but that's when you hold UP after jumping, which I presume to be a matter of not checking for button held down after initial jump.
    Last edited by ImprisonedPride; 04-15-2008 at 04:43 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

  8. #8
    Trainee coder Viza's Avatar
    Join Date
    Sep 2006
    Location
    Melbourne, Down under
    Posts
    513
    I get the same thing as IP. I'm not sure if it's becaus you tried to incorperate some kind o double jump feature pr something, but you may want to fix it.

    Otherwise good work. Is it going to be open-source?

    Viza.

    EDIT: Ah, I just read your first post properly and apparently this glide 'feature' is caused from your double jump code... You should limit a double jump to occur only once, and also only when the velocity is a certain value (to stop it from occuring too early so it's noticable).
    Last edited by Viza; 04-15-2008 at 06:48 AM.

  9. #9
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    You should limit a double jump to occur only once, and also only when the velocity is a certain value
    I already do that. The gliding has nothing to do with the double jumping. It's a seperate feature, kind of like in Ratchet and Clank when you have the helicopter extension thingie. But it can be turned off easily.

    Is it going to be open-source?
    I think I'll do at least one complete game with it first, but after that, chances are I will. But I wouldn't want to release it as open source before I used it myself, and then have to compete with other platformers that use my code

  10. #10
    Trainee coder Viza's Avatar
    Join Date
    Sep 2006
    Location
    Melbourne, Down under
    Posts
    513
    Quote Originally Posted by Fall_X
    I already do that. The gliding has nothing to do with the double jumping. It's a seperate feature, kind of like in Ratchet and Clank when you have the helicopter extension thingie. But it can be turned off easily.
    Oh, I see. That's a pretty neat idea, but you might want to make this obvious to players by representing it graphicaly.

    I still think the double-jumping needs work though, because it's really hard to time it right (I can only double jump when the player is just about to start falling back down ??).

    Viza.

  11. #11
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Oh, I see. That's a pretty neat idea, but you might want to make this obvious to players by representing it graphicaly.
    Yeah, in one game I used this same feature in, flames came out of the robot's booster thingies, and in another I had a character with a cape, so it was also clear what was going on. Now off course, here we have just a placeholder block, so it's not very obvious.

    I still think the double-jumping needs work though, because it's really hard to time it right (I can only double jump when the player is just about to start falling back down ??).
    Double jumping is currently limited when dy (the vertical movement) is between 5 and -5, but this is easy to change.

    Thanks for the comments.

  12. #12
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Small update : now you can climb ladders. There's still a small bug/glitch in that, but I doubt anyone will notice But do let me know if you come across anything odd.

  13. #13
    Zombie Coder EvilKris's Avatar
    Join Date
    Jun 2006
    Location
    Fukuoka, Japan.
    Posts
    796
    That's awesome. If that's tile based you should definitely write a tutorial dude, or at least illustrate somewhere how you did the slope collision testing part. Probably one of the best tile-engines I've seen on FlashKit so far. I'm wondering if it can deal with collision sweeping yet?if an object hits the wall at high velocity can it handle that?

  14. #14
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    It works very well so far

    That's funny, over the past few days I was working on exactely the same kind of engine (although I needed several days of work compared to your "several hours").

    [EDIT]
    if an object hits the wall at high velocity can it handle that?
    HA! That's a common "bug" in the tile based engines - or just an intended omission to gain some speed (by removing checks).
    Personnaly my engine was handling that (heck, you could even have a speed of 1'000, it was working :P ), but since the tiles are 32x32, I removed it and the max speeds are set to 32; it's enough for me, 32 is already a very fast speed.
    Last edited by marmotte; 04-15-2008 at 09:45 PM.

  15. #15
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Updated, I think the climbing is now perfect. I also added a larger climbing area in there.
    That's awesome. If that's tile based you should definitely write a tutorial dude, or at least illustrate somewhere how you did the slope collision testing part. Probably one of the best tile - engines I've seen on FlashKit so far.
    Thanks for the compliment. As for the tutorial, well, it's all a bit hard to explain for me, especially since English isn't my native language, but I might give it a go. Either that, or just share the code.
    I'm wondering if it can deal with collision sweeping yet?if an object hits the wall at high velocity can it handle that?
    See Marmotte's reply. I could implement it, wouldn't be too hard, but I'm not sure if it's worth it.
    That's funny, over the past few days I was working on exactely the same kind of engine (although I needed several days of work compared to your "several hours").
    Damn, I guess that means you won't be interested in making a platformer together? The several hours is relative, I'm never sure how long I work on things like this because I do it on train rides and whenever I find some spare time. Could be 5 hours, could be 20, could be more. Plus, I already had the scrolling engine.

  16. #16
    The Cheeze to Your Macaroni ColbyCheeze's Avatar
    Join Date
    Dec 2007
    Location
    Texas
    Posts
    244
    I like platform games but there are some things I'd like to see more often:

    acceleration based running (like mario 3 / sonic)
    less jumpy jumping...slow it down a bit or something

    could you get the actor to face at the same angle as the slope he is on?
    maybe add some fun extra stuff like wall jumping etc..

    I know your engine is early, I'm eager to see how it comes along! Keep up the good work.

  17. #17
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    acceleration based running (like mario 3 / sonic)
    It is acceleration based, but it accelerates to the maximum speed very quickly - but that's all parameterized (if that's a word).
    less jumpy jumping...slow it down a bit or something
    Also easy to change, just a few numbers... It depends on the game, how far you can jump, etc.
    could you get the actor to face at the same angle as the slope he is on?
    Not with this engine I think... I didn't use vectors because a) I've made a couple of platformers using this technique in the past, and it always works pretty well, b) I didn't want to learn vector math and c) I want to be able to design levels without having to define them as vectors, but without vectors I think the angle would be difficult to calculate. It's something I can do without though.
    maybe add some fun extra stuff like wall jumping etc..
    Yeah that was one of the thing I had planned, as well as hanging on edges (and swining around/climbing up), platforms that cave in, etc. But I think with what I have so far, I can start making a game out of it already.

  18. #18
    Senior Member Alluvian's Avatar
    Join Date
    Jun 2006
    Posts
    967
    Why would the angle be hard to calculate? Wouldn't it just be a collision check at the front and the back of the actor/avatar? Not sure how this tile engine is doing collision though. It would also let you do jumping at an angle when on slopes as opposed to always jumping straight up even when on a slop.

  19. #19
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    That's not possible because when you're on a slope, usually only one point would hit the floor. I could try dropping the other one(s) a bit until it/they hit the floor as well, but I'm not sure if that would work, and how performant it would be, and since it's not a feature I really want (at this point), I probably won't bother

  20. #20
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    Quote Originally Posted by Fall_X
    Damn, I guess that means you won't be interested in making a platformer together?
    Haha, are you serious?
    Well, my plan was to develop another personal project (like I did with Bubble Islands), and it's either a fighting game (Street Fighter-like) or an adventure-platform game (like 2D Metroid, an open world that you can explore fully only if you get the proper items). Or another game, I have soo many more original game ideas that I still never tried.
    Anyway, since I'm really busy with works, I don't have that much time to work on those, but maybe in 4 years something will be released :P

    What's your platform game is about?

    Also, I don't think that calculating the angle of the tile is that hard...? Since you probably stored the slope values of each tile somewhere...
    In my engine, the slope only affects the player to it's center (like IP said: "The character's bottom center point should touch the ground, not the corner"). So it's quite easy to detect the angle directly (even though I'm not interested in that). In that case, there are several options I guess:

    1) Assign to your tile an angle value, so you don't need to calculate it in real-time.
    2) Calculate it in real-time, for example check the values at your left/right extremity, and make a medium, then calculate the angle thanks to that

    (oh btw, I'm crap with maths )

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