Fix bonus ending SLEEEEP

This commit is contained in:
Mikko Ahlroth 2014-10-19 06:51:53 +03:00
parent fc1e4dfdd6
commit e226dbcd16
6 changed files with 23 additions and 9 deletions

View file

@ -13,6 +13,10 @@ BigBallMode = Class{
PowerUpMode.update(self, dt) PowerUpMode.update(self, dt)
end; end;
draw = function(self, x, y)
PowerUpMode.draw(self, x, y)
end;
activate = function(self, plane) activate = function(self, plane)
PowerUpMode.activate(self, plane) PowerUpMode.activate(self, plane)
plane.machinegun:setType("bigball") plane.machinegun:setType("bigball")
@ -20,6 +24,5 @@ BigBallMode = Class{
deactivate = function(self) deactivate = function(self)
PowerUpMode.deactivate(self) PowerUpMode.deactivate(self)
self.plane.machinegun:setType(PLANE_DEFAULT_GUN)
end; end;
} }

View file

@ -13,6 +13,10 @@ ChaingunMode = Class{
PowerUpMode.update(self, dt) PowerUpMode.update(self, dt)
end; end;
draw = function(self, x, y)
PowerUpMode.draw(self, x, y)
end;
activate = function(self, plane) activate = function(self, plane)
PowerUpMode.activate(self, plane) PowerUpMode.activate(self, plane)
plane.machinegun:setType("chaingun") plane.machinegun:setType("chaingun")
@ -20,6 +24,5 @@ ChaingunMode = Class{
deactivate = function(self) deactivate = function(self)
PowerUpMode.deactivate(self) PowerUpMode.deactivate(self)
self.plane.machinegun:setType(PLANE_DEFAULT_GUN)
end; end;
} }

View file

@ -335,6 +335,10 @@ Plane = Class{
love.graphics.pop() love.graphics.pop()
drawDebug(self.debugVectors) drawDebug(self.debugVectors)
if self.powerupmode ~= nil then
self.powerupmode:draw(self.body:getX(), self.body:getY())
end
end end
end; end;

View file

@ -191,8 +191,10 @@ function begin_contact(a, b, coll)
if other:isinstance(gun['projectile']) and plane.health > 0 then if other:isinstance(gun['projectile']) and plane.health > 0 then
plane:receiveDamage(gun['damage']) plane:receiveDamage(gun['damage'])
local shooter = other:getOwner():getOwner()
shooter:addScore(HIT_SCORE)
if plane.health == 0 then if plane.health == 0 then
other:getOwner():getOwner():addScore(KILL_SCORE) shooter:addScore(KILL_SCORE)
end end
end end
end end

View file

@ -10,7 +10,7 @@ PowerUpMode = Class{
end; end;
update = function(self, dt) update = function(self, dt)
if active then if self.active then
self.age = self.age + dt self.age = self.age + dt
end end
@ -20,11 +20,11 @@ PowerUpMode = Class{
end; end;
draw = function(self, x, y) draw = function(self, x, y)
local age = self.age / self.duration local age_ratio = self.age / self.duration
local start_color = {0, 255, 0} local start_color = {255, 0, 0}
local end_color = {255, 0, 0} local end_color = {0, 255, 0}
love.graphics.setColor(colorSlide(start_color, end_color, age_ratio)) love.graphics.setColor(colorSlide(start_color, end_color, age_ratio))
love.graphics.rectangle("fill", self.x, self.y + 60, 50, 5) love.graphics.rectangle("fill", x, y + 60, 50 * (1 - age_ratio), 5)
end; end;
activate = function(self, plane) activate = function(self, plane)
@ -35,5 +35,6 @@ PowerUpMode = Class{
deactivate = function(self) deactivate = function(self)
self.plane.powerupmode = nil self.plane.powerupmode = nil
self.plane.machinegun:setType(PLANE_DEFAULT_GUN)
end; end;
} }

View file

@ -35,7 +35,8 @@ SCOREBOARD_MARGIN = 20
ENGINE_MAX = 1000 ENGINE_MAX = 1000
INITIAL_PLANE_SPEED = 500 INITIAL_PLANE_SPEED = 1000
HIT_SCORE = 1
KILL_SCORE = 10 KILL_SCORE = 10
SUICIDE_SCORE = -2 SUICIDE_SCORE = -2