Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sprite = {}
- sprite["right"] = {}
- sprite["left"] = {}
- for i = 1, 3 do
- sprite["left"][i] = image.load("img/sprites/zombies/left/"..i..".png") --cargamos imágenes
- sprite["right"][i] = image.load("img/sprites/zombies/right/"..i..".png")
- end
- --Characters (personaje)
- character = { x = 60, y = 250-sprite["left"][1]:height(),w=32,h=33, status = "floor", direction = "right",score=0, health = 100 , steps=1, jump = 0, topdown= 250, weapon = "bazooka"}
- function character.move()
- character.w = sprite[character.direction][math.floor(character.steps)]:width()
- character.h = sprite[character.direction][math.floor(character.steps)]:height()
- if controls.press("right") or controls.press("left") and character.status == "floor" then
- character.steps = character.steps + 1
- end
- if controls.right() then
- character.direction = "right"
- character.x = character.x + 1.4
- if character.status == "floor" then -- no air walking xD
- character.steps = character.steps + 0.07
- end
- end
- if controls.left() then
- character.direction = "left"
- character.x = character.x - 1.4
- if character.status == "floor" then -- no air walking xD
- character.steps = character.steps + 0.07
- end
- end
- if controls.cross() then
- if character.status == "floor" then
- character.status = "air"
- character.jump = 4
- end
- end
- if character.status == "air" then
- character.y = character.y - character.jump
- character.jump = character.jump -0.2
- end
- if character.steps > 4 then character.steps = 1 end
- if character.y+character.h > character.topdown then character.status = "floor" character.y = character.topdown-character.h end
- end
- while true do
- controls.read()
- character.move()
- sprite[character.direction][math.floor(character.steps)]:blit(character.x,character.y) --blit main character
- if controls.select() then a() end
- screen.flip()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement