Advertisement
xerpi

xerpi way

May 30th, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1. sprite = {}
  2. sprite["right"] = {}
  3. sprite["left"] = {}
  4. for i = 1, 3 do
  5. sprite["left"][i] = image.load("img/sprites/zombies/left/"..i..".png") --cargamos imágenes
  6. sprite["right"][i] = image.load("img/sprites/zombies/right/"..i..".png")
  7. end
  8. --Characters (personaje)
  9. 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"} 
  10.  
  11. function character.move()
  12. character.w = sprite[character.direction][math.floor(character.steps)]:width()
  13. character.h = sprite[character.direction][math.floor(character.steps)]:height()
  14.  
  15. if controls.press("right") or controls.press("left") and character.status == "floor" then
  16.     character.steps = character.steps + 1
  17. end
  18.  
  19. if controls.right() then
  20.     character.direction = "right"
  21.     character.x = character.x + 1.4
  22.     if character.status == "floor" then -- no air walking xD
  23.         character.steps = character.steps + 0.07
  24.     end
  25. end
  26. if controls.left() then
  27.     character.direction = "left"
  28.     character.x = character.x - 1.4
  29.         if character.status == "floor" then -- no air walking xD
  30.         character.steps = character.steps + 0.07
  31.     end
  32. end
  33. if controls.cross() then
  34.     if character.status == "floor" then
  35.         character.status = "air"
  36.         character.jump = 4
  37.     end
  38. end
  39.  
  40. if character.status == "air" then
  41.     character.y = character.y - character.jump
  42.     character.jump = character.jump -0.2
  43. end
  44.  
  45. if character.steps > 4 then character.steps = 1 end
  46. if character.y+character.h > character.topdown then character.status = "floor" character.y = character.topdown-character.h end
  47. end
  48.  
  49. while true do
  50. controls.read()
  51.  
  52. character.move()
  53. sprite[character.direction][math.floor(character.steps)]:blit(character.x,character.y) --blit main character
  54.  
  55. if controls.select() then a() end
  56. screen.flip()
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement