-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbomb.lua
28 lines (19 loc) · 787 Bytes
/
bomb.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
bomb = class('bomb')
function bomb:initialize(world,x,y)
self.xtarget = x
self.ytarget = y
self.body = love.physics.newBody(world,400,500,"kinematic")
local vx = x - game.bombtower.x
local vy = y - game.bombtower.y
self.body:setBullet(true)
self.body:setLinearVelocity(vx,vy)
self.shape = love.physics.newRectangleShape(x,y,8,4)
local x1, y1, x2, y2 = self.shape:computeAABB(0,0,0)
self.width = x2 - x1
self.height = y2 - y1
self.fixture = love.physics.newFixture(self.body, self.shape, 1.0)
end
function bomb:draw()
love.graphics.setColor(math.random(0,255),math.random(0,255),math.random(0,255))
love.graphics.rectangle('fill',self.body:getX(),self.body:getY(),self.width,self.height)
end