/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-06-19 00:50:23 UTC
  • Revision ID: josh@9ix.org-20130619005023-necyd2i8kgqbp1s9
shield

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
                     local pvec = vector.new(the.player.x - self.x,
16
16
                                             the.player.y - self.y)
17
17
 
18
 
                     self.rotation = math.atan2(pvec.y, pvec.x)
 
18
 
 
19
                     local pAngle = math.atan2(pvec.y, pvec.x)
 
20
                     local aDiff = self.rotation - pAngle
 
21
 
 
22
                     while aDiff < (-math.pi) do
 
23
                        --print(aDiff .. ' < -π')
 
24
                        aDiff = aDiff + 2 * math.pi
 
25
                     end
 
26
                     while aDiff > math.pi do
 
27
                        --print(aDiff .. ' > π')
 
28
                        aDiff = aDiff - 2 * math.pi
 
29
                     end
 
30
 
 
31
                     if math.abs(aDiff) > 0.1 then
 
32
                        -- rotation really shouldn't be negative.  I
 
33
                        -- don't understand why that is.  :\
 
34
                        self.velocity.rotation = -2 * util.signOf(aDiff)
 
35
                     else
 
36
                        --print('not rotating')
 
37
                        self.velocity.rotation = 0
 
38
                     end
19
39
 
20
40
                     local pdist2 = pvec:len2()
21
41
 
28
48
                        self.thrust.visible = false
29
49
                     end
30
50
 
31
 
                     if pdist2 < 400^2 and
 
51
                     if math.abs(aDiff) < 0.5 * math.pi and
 
52
                       pdist2 < 400^2 and
32
53
                       love.timer.getTime() - self.lastFired > 0.25 then
33
54
                       --print('pew')
34
55
                         b = Bullet:new{