Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# Main
- displayMode(FULLSCREEN)
- function setup()
- en={}
- hw = WIDTH/2
- hh = HEIGHT/2
- ball = physics.body(CIRCLE,20)
- ball.x = 1
- ball.linearVelocity = vec2(1200,0)
- ball.y = hh
- points = {vec2(0,0),vec2(0,500/6),vec2(50,500/6),
- vec2(0,0),vec2(50,0),vec2(50,500/6)}
- mainhero = physics.body(POLYGON,unpack(points))
- mainhero.x = hw
- mainhero.y = hh
- mainhero.gravityScale = 1
- colors = {color(255, 0, 0, 255),color(0, 255, 0, 255),
- color(0, 0, 255, 255),color(255, 0, 0, 255),
- color(0, 255, 0, 255),color(0, 0, 255, 255)}
- heromesh = mesh()
- heromesh.vertices = {unpack(points)}
- heromesh.colors = {unpack(colors)}
- floor = physics.body(EDGE,vec2(0,-3),vec2(WIDTH,-3))
- end
- function draw()
- background(127, 127, 127, 255)
- pushMatrix()
- translate(mainhero.x,mainhero.y)
- rotate(mainhero.angle)
- heromesh:draw()
- popMatrix()
- fill(255, 2, 0, 255)
- ellipse(ball.x,ball.y,40)
- for a,b in pairs(en) do
- b:draw()
- end
- end
- function touched(t)
- if t.state==BEGAN then
- table.insert(en,Horde())
- end
- end
- --# Horde
- --# Horde
- Horde = class()
- function Horde:init()
- self.enemy = physics.body(POLYGON,vec2(0,0),vec2(0,500/6),
- vec2(50,500/6),vec2(0,0),vec2(50,0),vec2(50,500/6))
- self.enemy.x = CurrentTouch.x
- self.enemy.y = CurrentTouch.y
- self.enemy.type = DYNAMIC
- table.insert(en,enemy)
- end
- function Horde:draw()
- fill(255, 157, 0, 255)
- for k,v in pairs(en) do
- pushMatrix()
- translate(v.enemy.x,v.enemy.y)
- rotate(v.enemy.angle)
- rect(0,0,50,500/6)
- popMatrix()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement