Guest User

Untitled

a guest
Jun 18th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. -----------------------------------------------------------------------------------------
  2. --
  3. -- main.lua
  4. --
  5. -----------------------------------------------------------------------------------------
  6.  
  7. -- Your code here
  8. -- Sprites
  9. local sprite = "guy.png"
  10.  
  11. -- Sleep function (REQUIRED)
  12.  
  13. -- Character Load
  14. function loadChar()
  15. char = display.newImage( sprite )
  16. x = display.contentCenterX
  17. y = display.contentCenterY
  18. char.x = x
  19. char.y = y + 25
  20. char:toFront()
  21. end
  22.  
  23. -- Nexus Load
  24. function loadNexus()
  25. nexus = display.newImage( "tmpNexus.png" )
  26. nexus.x = display.contentCenterX
  27. nexus.y = display.contentCenterY
  28. nexus:toFront()
  29. end
  30.  
  31. -- Map Load
  32. function loadMap()
  33. local background = display.newImage( "back.png" )
  34. background:toBack()
  35. end
  36.  
  37. -- Keys Load
  38. function loadKeys()
  39. local up = display.newImage( "up.png")
  40. local down = display.newImage( "down.png")
  41. local left = display.newImage( "left.png")
  42. local right = display.newImage( "right.png")
  43. down.x = 48
  44. down.y = 294
  45. left.x = 26
  46. left.y = 272
  47. right.x = 70
  48. right.y = 272
  49. up.x = 48
  50. up.y = 250
  51. end
  52.  
  53. function moveTouch( event )
  54. print( "(".. event.x .. ",".. event.y ..")" )
  55. -- UP
  56. if event.y < 262 and event.y > 236 and event.x > 32 and event.x < 64 then
  57. print( "UP" )
  58. sprite = "guy.png"
  59. for i = 1,5 do
  60. char.y = char.y - 1
  61. end
  62. end
  63. -- LEFT
  64. if event.y > 256 and event.y < 288 and event.x > 10 and event.x < 42 then
  65. print( "LEFT" )
  66. sprite = "guyLR.png"
  67. for i = 1,5 do
  68. char.x = char.x - 1
  69. end
  70. end
  71. -- DOWN
  72. if event.y > 278 and event.y < 310 and event.x > 32 and event.x < 64 then
  73. print( "DOWN" )
  74. sprite = "guy.png"
  75. for i = 1,5 do
  76. char.y = char.y + 1
  77. end
  78. end
  79. -- RIGHT
  80. if event.y > 256 and event.y < 288 and event.x > 54 and event.x < 86 then
  81. print( "RIGHT" )
  82. sprite = "guyLR.png"
  83. for i = 1,5 do
  84. char.x = char.x + 1
  85. end
  86. end
  87. end
  88.  
  89. loadMap()
  90. loadNexus()
  91. loadChar()
  92. loadKeys()
  93.  
  94.  
  95. Runtime:addEventListener( "touch", moveTouch )
Advertisement
Add Comment
Please, Sign In to add comment