Plane: added ability to die
This commit is contained in:
parent
5a5381e817
commit
ec4d8a309f
2 changed files with 26 additions and 12 deletions
|
@ -81,6 +81,10 @@ Plane = Class{
|
|||
self.powerupmode = nil
|
||||
end;
|
||||
|
||||
receiveDamage = function(self, amount)
|
||||
self.health = math.max(0, self.health - amount);
|
||||
end;
|
||||
|
||||
getGunPosition = function(self)
|
||||
local x = self.body:getX()
|
||||
local y = self.body:getY()
|
||||
|
@ -248,6 +252,7 @@ Plane = Class{
|
|||
end;
|
||||
|
||||
draw = function(self)
|
||||
if self.health > 0 then
|
||||
PhysicsEntity.draw(self)
|
||||
love.graphics.push()
|
||||
|
||||
|
@ -262,6 +267,7 @@ Plane = Class{
|
|||
|
||||
love.graphics.pop()
|
||||
drawDebug(self.debugVectors)
|
||||
end
|
||||
end;
|
||||
|
||||
cw = function(self, isTurning)
|
||||
|
|
|
@ -5,6 +5,7 @@ require 'scoreboard'
|
|||
require 'entities/chaingunpowerup'
|
||||
require 'entities/plane'
|
||||
require 'chaingunmode'
|
||||
require 'entities/plane'
|
||||
|
||||
level_state = {}
|
||||
|
||||
|
@ -137,6 +138,13 @@ function begin_contact(a, b, coll)
|
|||
elseif bObj:isinstance(Plane) and aObj:isinstance(ChaingunPowerUp) then
|
||||
aObj.deleteLater = true
|
||||
bObj:setPowerUpMode(ChaingunMode())
|
||||
else
|
||||
if aObj:isinstance(Plane) then
|
||||
aObj:receiveDamage(1000);
|
||||
end
|
||||
if bObj:isinstance(Plane) then
|
||||
bObj:receiveDamage(1000);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue