Score count
This commit is contained in:
parent
22274ac82a
commit
7774c8f3aa
3 changed files with 15 additions and 1 deletions
|
@ -166,14 +166,21 @@ function begin_contact(a, b, coll)
|
|||
if other and other:isinstance(Plane) then
|
||||
plane:receiveDamage(1000)
|
||||
other:receiveDamage(1000)
|
||||
plane:getOwner():addScore(SUICIDE_SCORE)
|
||||
other:getOwner():addScore(SUICIDE_SCORE)
|
||||
elseif plane then
|
||||
if other:getOwner() == nil then
|
||||
-- Collision with ground or other plane
|
||||
plane:receiveDamage(1000)
|
||||
plane:getOwner():addScore(SUICIDE_SCORE)
|
||||
elseif other:getOwner().id ~= plane.id then
|
||||
for key, gun in pairs(GUNS) do
|
||||
if other:isinstance(gun['projectile']) then
|
||||
if other:isinstance(gun['projectile']) and plane.health > 0 then
|
||||
plane:receiveDamage(gun['damage'])
|
||||
|
||||
if plane.health == 0 then
|
||||
other:getOwner():getOwner():addScore(KILL_SCORE)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,6 +41,10 @@ Player = Class{
|
|||
return self.plane
|
||||
end;
|
||||
|
||||
addScore = function(self, score)
|
||||
self.score = self.score + score
|
||||
end;
|
||||
|
||||
press = function(self, key)
|
||||
for action, keycode in pairs(self.keys) do
|
||||
if key == keycode then
|
||||
|
|
|
@ -36,3 +36,6 @@ SCOREBOARD_MARGIN = 20
|
|||
ENGINE_MAX = 1000
|
||||
|
||||
INITIAL_PLANE_SPEED = 500
|
||||
|
||||
KILL_SCORE = 10
|
||||
SUICIDE_SCORE = -2
|
||||
|
|
Loading…
Reference in a new issue