I am following "RazorGameDev"'s tutorial on youtube. But instead of using all the code he made, i tried implementing other libraries i know better. I now use Bump.lua for collision, and the hump camera as the camera. Works fine. Except that my player can jump repeatedly up against a wall. Here's my code:
Code: Select all
self.x, self.y, collisions = world:move(self, self.x + self.xvel, self.y + self.yvel)
if keyDown("space") and self.canJump then
self.canJump = false
self.yvel = -15.5
elseif #collisions >= 1 and self.yvel > 0 then
self.canJump = true
end
I am aware that the reason he jumps is that nothing in the code prevents him from jumping. But how would I? My best bet would be to find out which side of the player was colliding. This way i see could if the player is on the ground, or has the side to a wall. It would look somthing like:
Code: Select all
if self.bottom.isColliding then
self.yvel = -15.5
end
But i have no idea how to achieve this...