Right. Despite my not having any experience whatsoever in making a platformer, I’ve cobbled together satisfactory movement – left, right, jump, run-jump and all that – with working collisions and gravity; in short, the essence of a platformer.
My initial problem was with collision – I would run up against the wall, press the other direction and whoops – the player sprite ended up with one foot jammed in the wall.
This was entirely due to the sprite’s centering. I Game Maker, you can set the center of each sprite as it’s point of origin. In my case, I use a variety of sprites – the left running animation, the left standing still sprite, and the right run and the right standstill. The torso shifts. Naturally.
My problem: the arm is an independent obect which points to the mouse cursor, Abuse-style. So, to anchor the arm to the body, I had instructed it to attach itself to player_object.x, player_object.y at all times. I the then point of origin of the left and right sprites to *slightly [about 3 pixels difference]* different x-coordinates to make sure that the player’s arm, is perfectly aligned with the shifted torso. Unfortunately, due to this 3-pixel origin difference the player’s foot would shift imperceptibly into walls and the collision code would freeze the player.
Headache. Yes, the tutorials would have helped, but I refuse to look at them. For now. Part of the fun is figuring out the solution.
Setting the x-value to the center of the sprite solved the issue, but had the arm hanging onto empty air because the player’s torso shifted about when changing directions. So . . . simple enough: I left the arm as it was and, depending on which sprite was used, I made the player object draw three fine lines from itself to the arm. Now it looks awesome! When trying to run against a wall, the arm extends; since the lines are drawn, it looks exactly like the arm is still attached and the player is “pushing” at the wall.
I messed about with it a bit and turned off the gravity for the arm. The guy now looks like a mini-Mr-elastic when jumping; the arm stretches and zap! pops back into place. Not bad 😀
One MASSIVE problem I’m having, is that whenever I jump and land while holding the left / right arrow key, the player actually runs on a 1-2 pixel wide layer ABOVE the floor. Let go of the button, or tap it again, or press another button, and the player descends to the floor again. I’ve tried setting gravity on Key Press – doesn’t work.
Hmm . . .
I’ll figure it out.
Oh, and I made a new background.