-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.lua
More file actions
36 lines (28 loc) · 859 Bytes
/
Copy pathplatform.lua
File metadata and controls
36 lines (28 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "constants"
local gfx = playdate.graphics
class("Platform").extends(gfx.sprite)
-- Constructor
function Platform:init(x, y, width, height)
self.width = width
self.height = height
self:setGroups({ kCollisionGroupPlatform })
self:setCollidesWithGroups({ kCollisionGroupPlayer })
self:setUpdatesEnabled(true)
self.collisionType = kCollisionGroupPlatform
self:refresh()
self:setCollideRect(0, 0, width, height)
self:moveTo(x, y)
self:add()
end
-- Refresh
function Platform:refresh()
local image = gfx.image.new(self.width, self.height)
gfx.pushContext(image)
gfx.setColor(gfx.kColorBlack)
--gfx.fillRect(0, 0, self.width, self.height)
gfx.popContext()
self:setImage(image)
self:setCollideRect(0, 0, self.width, self.height)
end