-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Towers obey range according to type (which is the same for all types …
…for now). This fixes issue #24. Also made some minor changes so that the dead enemy and shots on it are no longer shown at game over.
- Loading branch information
Showing
5 changed files
with
84 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
require "towerType" | ||
|
||
function love.turris.newTower(type, x, y) | ||
print ("new tower:", type, x, y) | ||
local o = {} | ||
o.x = x | ||
o.y = y | ||
o.type = type | ||
o.shooting = false | ||
o.target = {} | ||
|
||
o.getRange = function() | ||
return type.range | ||
end | ||
|
||
o.determineTarget = function(enemies,distance_function) | ||
for i = 1, #enemies do | ||
local e = enemies[i] | ||
if not e.dead then | ||
local d = distance_function(o.x,o.y, e.x,e.y) | ||
if (d<=o.type.range)then | ||
return e --TODO: for now we just pick the one existing enemy. Once we have more than one, we need to choose between the ones in range | ||
end | ||
end | ||
end | ||
end | ||
|
||
return o | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters