/traderous

To get this branch, use:
bzr branch http://9ix.org/bzr/traderous

« back to all changes in this revision

Viewing changes to enemy.lua

  • Committer: Josh C
  • Date: 2013-07-04 18:15:15 UTC
  • Revision ID: josh@9ix.org-20130704181515-pmp44y2vv3vw170x
reset kill counter on reward

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
-- player = 300 accel, 400 velLimit
2
2
local accelLimit = 150
3
 
local velLimit = 200
 
3
local velLimit = 300
4
4
Enemy = Tile:extend {
5
5
   image = 'data/enemy.png',
6
6
   maxVelocity = {x=velLimit,y=velLimit},
50
50
 
51
51
                     if pdist2 < (the.app.width / 2)^2 then
52
52
                        -- if player is roughly on enemy's screen
53
 
                        if self.state == 'patrolling' and the.player.active then
 
53
                        if self.state == 'patrolling' and the.player.active and not the.player.onPlanet then
54
54
                           self.state = 'combat'
55
55
                           self.target = the.player
56
56
                        end
57
 
                     elseif pdist2 > (2 * the.app.width)^2 then
 
57
                     elseif pdist2 > (3 * the.app.width)^2 then
58
58
                        if self.state == 'combat' then
59
59
                           self.state = 'patrolling'
60
60
                           self:chooseTarget()
112
112
                        the.enemies:remove(self)
113
113
                        the.app.view:remove(self.thrust)
114
114
                        the.app.view:remove(self.shield)
 
115
 
 
116
                        if other.source == the.player then
 
117
                           the.player.kills = the.player.kills + 1
 
118
                        end
 
119
 
 
120
                        -- and add a new enemy somewhere else...
 
121
                        local e = Enemy:new{x = math.random(the.bg.width),
 
122
                                            y = math.random(the.bg.height)}
 
123
                        the.enemies:add(e)
 
124
                        the.view:add(e.thrust)
 
125
                        the.view:add(e.shield)
115
126
                     else
116
127
                        self.shield:onHit()
117
128
                     end