A player character
The player character will be doing simple things such as killing the enemy, jumping, and walking towards the left or right, making it spawn, and also colliding with the platform.
---set the player's collider box left, Right and height spaces playerCollideboxL = 8 playerCollideboxR = 8 playerCollideboxY = 4
The player spawn function binds the collider with the player's left
, right
, and height
space parameters. Our player is size 32:
function PlayerSpawn(x,y) local left = x + playerCollideboxL local right = 32 local height = 32 - playerCollideboxY
Create a table to hold all the player's necessary properties:
player = {} player.name="player" ---player left player.l=x --player bottom space player.t=y+playerCollideboxY --player right space player.w=right --player height player.h=height --current layer's velocity (vY) in the Y axis player.vY=0 --player's current direction player.dir=1
Add
player
tobump
, so the player can collide too:bump.add(player) --where...