gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Anyone know how to make a good platform engine?

#468 - darkcloud - Tue Jan 07, 2003 11:59 pm

I am trying to build a platform engine but I keep running into bugs with my collision. Does anyone have any platform resources I can learn from? Or has anyone coded a platform game that I can look at the code too?
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#474 - ampz - Wed Jan 08, 2003 1:11 am

There are different types of collision detection...
Do you want tilebased (super mario style) or pixel based (worms style) collision detection?
I did a game where the map changes (colisionmap has to change too) with pixelbased collisiondetection, filled almost the entire extram with just the collisionmap..

#475 - darkcloud - Wed Jan 08, 2003 1:16 am

I could use either. I actually have a collision detection system I use in another demo I made but something seems to go wrong when I try to implement it in a side scroller/platform game.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#530 - Lord Graga - Wed Jan 08, 2003 2:46 pm

Haven't you learned anything from my demo and the source?.[/u]

#542 - darkcloud - Wed Jan 08, 2003 4:40 pm

Yea i tried to use your method but it wasnt working so good so I tried a different way.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#543 - darkcloud - Wed Jan 08, 2003 4:43 pm

I actually solved my platform engine problem yesterday, but it still has a few bugs. The character can keep jumping while in air.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#630 - squeakytoy - Thu Jan 09, 2003 5:47 am

Are you implementing your jump using velocity? I do, I make y velocity < 0 to jump, y velocity > 0 to fall, and ignore the jump button when y velocity is not 0 to prevent mid air jumps.

#642 - Lord Graga - Thu Jan 09, 2003 10:05 am

To make hi unable to jump in the air do this:
Code:

y++; //add 1 to his y (+1 is down)
if(map[(x/8)+((y/8)*32)==1] //if the map is blocking at that point
     AbleToJump = 1; //Horray!
else
     AbleToJump = 0; //You can't jump
y--; //set y to the old y so he doesn't go bananas and falls down all time.

Now got to the KEY_A check.
Code:

if(!(*KEYS & KEY_A)
{
      if(AbleToJump)
      {
           //Jumping code
      }
}


Are you happy now?

#690 - jenswa - Thu Jan 09, 2003 7:17 pm

Is there somewhere a tutorial about making platform games
for the gba and collision detection with the background,
some very simple stuff, that i can understand?

bye

JJ
_________________
It seems this wasn't lost after all.

#762 - AnthC - Fri Jan 10, 2003 1:24 pm

Hi
The way I do it to get more accuracy is have a bounding box for the sprite
and bounding box(s) for the map collision tile (this could mean one box or many box's for more accuracy)
I get the area that the sprite covers on the map (call this x1 y1 x2 y2)
Then for each box in the collision tile i just call a box check routine that returns 1/0 if theres collision or not

Here's how I split the 8x8's up
11
11 one box to test
01
11 3 box's to test (or 2 if you are clever)

00
01 1 box

etc...