1
Rock = WrapTile:extend {
2
image = 'data/rock.png',
4
--self.velocity = util.shortestVector(self, the.player):normalized() * 10
8
self.collider = RockCollider:new{
11
width = self.width * self.scale,
12
height = self.height * self.scale,
16
the.rockColliders:add(self.collider)
18
onUpdate = function(self, dt)
19
self.collider.x = self.x + self.width / 2 * (1 - self.scale)
20
self.collider.y = self.y + self.height / 2 * (1 - self.scale)
21
--self.collider.rotation = self.rotation -- ???
23
onEndFrame = function(self)
24
-- onEndFrame to give a chance to go out of bounds then wrap
26
if DEBUG and the.console.visible then
28
self.text = Text:new()
29
the.view:add(self.text)
32
local pVec = util.shortestVector(self, the.player)
33
self.text.text = pVec.x .. ', ' .. pVec.y
34
self.text.x, self.text.y = self.x, self.y
35
self.text.visible = true
38
self.text.visible = false
44
RockCollider = Fill:extend {
46
onUpdate = function(self, dt)
47
self.visible = DEBUG and the.console.visible
49
onCollide = function(self, other)
50
if other:instanceOf(Bullet) then
55
rotation = util.signOf(self.rock.rotation) * 5
60
the.rocks:remove(self.rock)
61
the.rockColliders:remove(self)
62
self.rock = nil -- break circular reference
64
the.bullets:remove(other)
b'\\ No newline at end of file'