1
1
Rock = WrapTile:extend {
2
image = 'data/rock.png'
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.app.view:add(self.collider)
17
the.rockColliders:add(self.collider)
19
onUpdate = function(self, dt)
20
self.collider.x = self.x + self.width / 2 * (1 - self.scale)
21
self.collider.y = self.y + self.height / 2 * (1 - self.scale)
22
--self.collider.rotation = self.rotation -- ???
24
onEndFrame = function(self)
25
-- onEndFrame to give a chance to go out of bounds then wrap
27
if DEBUG and the.console.visible then
29
self.text = Text:new()
30
the.view:add(self.text)
33
local pVec = util.shortestVector(self, the.player)
34
self.text.text = pVec.x .. ', ' .. pVec.y
35
self.text.x, self.text.y = self.x, self.y
36
self.text.visible = true
39
self.text.visible = false
45
RockCollider = Fill:extend {
47
onUpdate = function(self, dt)
48
self.visible = DEBUG and the.console.visible
50
onCollide = function(self, other)
51
if other:instanceOf(Bullet) then
52
the.app.view:remove(self.rock)
53
the.app.view:remove(self)
54
the.rockColliders:remove(self)
55
self.rock = nil -- break circular reference
57
the.app.view:remove(other)
58
the.bullets:remove(other)
b'\\ No newline at end of file'