Advertisement
Guest User

Untitled

a guest
Oct 16th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1.  
  2. --# Main
  3.  
  4. displayMode(FULLSCREEN)
  5.  
  6. function setup()
  7. en={}
  8.  
  9. hw = WIDTH/2
  10. hh = HEIGHT/2
  11. ball = physics.body(CIRCLE,20)
  12. ball.x = 1
  13. ball.linearVelocity = vec2(1200,0)
  14. ball.y = hh
  15. points = {vec2(0,0),vec2(0,500/6),vec2(50,500/6),
  16. vec2(0,0),vec2(50,0),vec2(50,500/6)}
  17. mainhero = physics.body(POLYGON,unpack(points))
  18. mainhero.x = hw
  19. mainhero.y = hh
  20. mainhero.gravityScale = 1
  21. colors = {color(255, 0, 0, 255),color(0, 255, 0, 255),
  22. color(0, 0, 255, 255),color(255, 0, 0, 255),
  23. color(0, 255, 0, 255),color(0, 0, 255, 255)}
  24. heromesh = mesh()
  25. heromesh.vertices = {unpack(points)}
  26. heromesh.colors = {unpack(colors)}
  27. floor = physics.body(EDGE,vec2(0,-3),vec2(WIDTH,-3))
  28. end
  29.  
  30. function draw()
  31. background(127, 127, 127, 255)
  32. pushMatrix()
  33. translate(mainhero.x,mainhero.y)
  34. rotate(mainhero.angle)
  35. heromesh:draw()
  36. popMatrix()
  37. fill(255, 2, 0, 255)
  38. ellipse(ball.x,ball.y,40)
  39. for a,b in pairs(en) do
  40. b:draw()
  41. end
  42. end
  43.  
  44. function touched(t)
  45. if t.state==BEGAN then
  46. table.insert(en,Horde())
  47. end
  48. end
  49.  
  50. --# Horde
  51.  
  52. --# Horde
  53. Horde = class()
  54.  
  55. function Horde:init()
  56. self.enemy = physics.body(POLYGON,vec2(0,0),vec2(0,500/6),
  57. vec2(50,500/6),vec2(0,0),vec2(50,0),vec2(50,500/6))
  58. self.enemy.x = CurrentTouch.x
  59. self.enemy.y = CurrentTouch.y
  60. self.enemy.type = DYNAMIC
  61. table.insert(en,enemy)
  62. end
  63.  
  64. function Horde:draw()
  65. fill(255, 157, 0, 255)
  66. for k,v in pairs(en) do
  67. pushMatrix()
  68. translate(v.enemy.x,v.enemy.y)
  69. rotate(v.enemy.angle)
  70. rect(0,0,50,500/6)
  71. popMatrix()
  72. end
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement