Skip to content

Commit

Permalink
Merge pull request #49 from largato/properties
Browse files Browse the repository at this point in the history
Change projectile color according to loyalty
  • Loading branch information
luizcavalcanti authored Oct 20, 2018
2 parents 5e40c9c + b374f16 commit df764b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gunner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ function Gunner:shoot()
self.position.y,
self.target.position.x,
self.target.position.y,
0.2))
0.2,
self.loyalty))
end

function Gunner:seek_target()
Expand Down
11 changes: 9 additions & 2 deletions projectile.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
local Timer = require "libs/hump/timer"
local Character = require "character"

Projectile = Object:extend()

function Projectile:new(size, ox, oy, dx, dy, duration)
function Projectile:new(size, ox, oy, dx, dy, duration, loyalty)
self.loyalty = loyalty
self.size = size
self.pos = { ox, oy }
self.dst = { dx, dy }
Expand All @@ -15,7 +17,12 @@ end

function Projectile:draw()
-- love.
love.graphics.setColor(255,127,0)
if self.loyalty == Character.LOYALTY_ENEMY then
love.graphics.setColor(0, 0, 255)
else
love.graphics.setColor(255, 0 , 0)
end

love.graphics.setLineWidth(self.size)
love.graphics.line(self.pos[1], self.pos[2],
self.dst[1], self.dst[2])
Expand Down
3 changes: 2 additions & 1 deletion tank.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ function Tank:shoot()
self.position.y,
self.target.position.x,
self.target.position.y,
0.2))
0.2,
self.loyalty))
end

function Tank:seek_target()
Expand Down

0 comments on commit df764b3

Please sign in to comment.