Platformer Collision and Proper Animation in Game Maker



I'm very new to Game Maker, but was interested in trying to learn it after I heard my school was offering a 20$/hour summer job teaching ten year olds how to make their own games using it. This morning I tried to make a platformer, and was pleased once I could make a little man run and jump around the screen, but I realized it had two major flaws.

1)The collision, while collide-y and stuff, wasn't really what I wanted. Sure, I was able to create collision between the player and a wall, which was just an invisible square, I wanted to make "one way" collision, where the player object would only check if the wall object was hit from above, allowing for better platforming (like in N! You know the one way platforms in N?). And the collision was horrible in general; running around, the player would get stuck in many different ways on the terrain. I suspect it is because of the changing animations...

2)Speaking of changing animations, I have a simple event set up that when the player is running the sprite switches to a running animation, and when the player is jumping, it switches to a sprite of a jumping man.
But lots of problems ensued just because of the multiple animations. Upon landing, the jump sprite wouldn't change properly back to a running one if the player was moving left or right at the same time as they jumped. What's more, switching directions was difficult. Moving left then turning right turned into a hassle because whenever the player changed directions without stopping their initial one, the sprite would just be that of the man standing still.

How can I remedy the bad platforming collision and the broken movement animation? Is there a good guide for either? I hate to be a bother, but could you guys help me out?

Download the game in its current form

Download the game's .gmk for editing and help

I suggest you take a look at the grandma engine for game maker.  It's a pretty solid approach to platformer collision detection that's similar to the methods I use myself.

edit:  I was going to look at the gmk, but it turns out I dont have game maker 8 installed, and I don't own a copy of game maker 8.1 and don't want to buy one, and I can't find anywhere to download game maker 8 from, and I can't find my stupid softwrap code or whatever.

Okay so I'm looking at your gmk and it turns out your using the drag and drop code which I can't really offer any tips on.  If you really want to make a super tight and good feeling platform engine, I think that using the GML scripting is something you'd want to look into.

Well, one good place to begin is by changing your collision masks to something relatively consistent. Given your sprite style, I'd suggest using either the rectangle or the circle (if you want some graphical leeway in taking hits). You'll want to make the boundaries in your player sprites relatively consistent too (focus on the main body width, don't worry so much about protruding limbs), so that your collision box doesn't do changes that might result in you getting yourself clipped into a wall.

You're going to want to make an unsprited, non-solid parent object called "ground" or something to that effect, and duplicate/modify your gravity code to check for a collision BELOW YOU ONLY, and to treat it as solid ground in such cases. Point your one-way grounds (each of them) towards your parent object, and make sure their collision boxes are only a pixel or two high (you don't want your character to treat the entire tile like it's ground, right? Just the top...); and make sure your "check" for it is a range that works with your maximum vspeed (in which case, move to contact, set vspeed = 0 & gravity = 0).

As far as animating goes? I'm still working on that myself. I have a flipping/rolling animation I play when jumping or rolling, and it continues even after I release the buttons, even though it's coded NOT to do that. The key thing to do is make your player characters based entirely on the collision mask intended, and then make "child" objects to reflect the animation changes. Although personally, I'm hoping I can eventually code together something that allows index_image arrays to be dynamically displayed, like:

runright = 1 (2 3 4 5) = image_index plays frame 1, then loops 2-5 until a different command is entered. There'll probably be a direction/angle variable in there, too.

Also note: "pressing nothing" can be mapped as a command with effects, too. So can "releasing something." This may be key in helping with that.

 :shrug2: Beyond that, ya got me.


[0] Message Index