1
-- player = 300 accel, 400 velLimit
5
image = 'data/enemy.png',
6
maxVelocity = {x=velLimit,y=velLimit},
7
minVelocity = {x=-velLimit, y=-velLimit},
9
onNew = function (self)
10
self.thrust = Tile:new{image = 'data/thrust.png'}
11
--the.app.view:add(self.thrust)
13
onStartFrame = function (self)
15
local pvec = vector.new(the.player.x - self.x,
16
the.player.y - self.y)
18
self.rotation = math.atan2(pvec.y, pvec.x)
20
local pdist2 = pvec:len2()
22
if pdist2 > 400^2 then -- ... if player dist > 64?
23
self.acceleration = vector.new(300, 0)
24
self.acceleration:rotate_inplace(self.rotation)
25
self.thrust.visible = true
27
self.acceleration = {x=0, y=0}
28
self.thrust.visible = false
32
love.timer.getTime() - self.lastFired > 0.25 then
35
x = self.x + self.width / 2,
36
y = self.y + self.height / 2,
37
rotation = self.rotation
39
self.lastFired = love.timer.getTime()
43
onUpdate = function(self)
44
self.thrust.x = self.x - self.width
45
self.thrust.y = self.y
46
self.thrust.rotation = self.rotation
b'\\ No newline at end of file'