/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-16 04:27:01 UTC
  • Revision ID: josh@9ix.org-20130616042701-andlbpq3uuf679fy
enemy thrust

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
 
 
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
 
18
                     self.rotation = math.atan2(pvec.y, pvec.x)
39
19
 
40
20
                     local pdist2 = pvec:len2()
41
21
 
48
28
                        self.thrust.visible = false
49
29
                     end
50
30
 
51
 
                     if math.abs(aDiff) < 0.5 * math.pi and
52
 
                       pdist2 < 400^2 and
 
31
                     if pdist2 < 400^2 and
53
32
                       love.timer.getTime() - self.lastFired > 0.25 then
54
33
                       --print('pew')
55
34
                         b = Bullet:new{