Project 3: Getting a working jump

by samscaife on Monday 16 January 2012

I have decided to build my game in a method similar to the web design process of progressive enhancement where I get the basics working then build up from there as far as I can get. The first thing I have done is to create a platform class and a player class.

This is a still of how far I have gotten, you can play it here.



I have gotten the player to be controllable using the left and right keys however I was having issues with the jump. Currently you can jump once but as soon as your land it breaks because of how I have set up my code. Seb has created a section of the website where we can post our wip files for feedback and support, so I put my game up there and seb has advised me to do the following:



You shouldn't mess around with spacePressed other than to poll if the space is pressed :) 

So when you check spacePressed, you also need to check whether it's possible for the player to jump at that time. And it's possible for the player to jump only if he is currently on a platform. So I would create a boolean for that within the player object. 

I followed Seb's advice I managed to get it working however the jump was not going up smoothly into the air, instead it would just teleport upwards equal to the value of my jumpheight variable. I decided to leave it and start work on building some of the other parts of the game as I could not figure out the issue.

Leave your comment