-
Notifications
You must be signed in to change notification settings - Fork 0
/
pickup.lua
65 lines (59 loc) · 1.99 KB
/
pickup.lua
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
-- timePickupImage = love.graphics.newImage('timepickup.png')
-- timePickupQuads = {
-- love.graphics.newQuad(0,0,25,25,250,25),
-- love.graphics.newQuad(25,0,25,25,250,25),
-- love.graphics.newQuad(50,0,25,25,250,25),
-- love.graphics.newQuad(75,0,25,25,250,25),
-- love.graphics.newQuad(100,0,25,25,250,25),
-- love.graphics.newQuad(125,0,25,25,250,25),
-- love.graphics.newQuad(150,0,25,25,250,25),
-- love.graphics.newQuad(175,0,25,25,250,25),
-- love.graphics.newQuad(200,0,25,25,250,25),
-- love.graphics.newQuad(225,0,25,25,250,25)
-- }
pickupImage = love.graphics.newImage('scorepickup.png')
scorePickupImage = love.graphics.newImage('scorepickup.png')
Pickup = {}
Pickup.__index = Pickup
function Pickup.create()
local pickup = {}
setmetatable(pickup, Pickup)
--
pickup.type = 'moretime'
pickup.value = 1
pickup.x = 0
pickup.y = 0
pickup.w = scrWidth/25
pickup.h = scrHeight/25
pickup.xvel = 0
pickup.yvel = 0
pickup.movespeed = 200
--
return pickup
end
function Pickup:update(dt)
-- move
self.x = self.x + (self.xvel * dt)
self.y = self.y + (self.yvel * dt)
end
function Pickup:draw()
if self.type == 'moretime' then
love.graphics.setColor(0x23, 0x33, 0x60)
--love.graphics.rectangle('fill', self.x, self.y, self.w, self.h)
love.graphics.draw(pickupImage, self.x, self.y)
love.graphics.setColor(0xFF, 0xFF, 0xFF)
love.graphics.print('+'..self.value, self.x, self.y+self.h/4)
elseif self.type == 'lesstime' then
love.graphics.setColor(0xFB, 0x00, 0x00)
--love.graphics.rectangle('fill', self.x, self.y, self.w, self.h)
love.graphics.draw(pickupImage, self.x, self.y)
love.graphics.setColor(0xFF, 0xFF, 0xFF)
love.graphics.print('-'..self.value, self.x, self.y+self.h/4)
elseif self.type == 'score' then
love.graphics.setColor(0xE6, 0xD6, 0x17)
--love.graphics.rectangle('fill', self.x, self.y, self.w, self.h)
love.graphics.draw(scorePickupImage, self.x, self.y)
love.graphics.setColor(0xFF,0xFF,0xFF)
love.graphics.print(self.value,self.x,self.y+self.h/4)
end
end