mirror of
https://github.com/libretro/lutro-iyfct.git
synced 2024-11-27 02:00:39 +00:00
Added coffee powerup inside some open trains
This commit is contained in:
parent
afc748b247
commit
938db12208
BIN
gfx/sprites.png
BIN
gfx/sprites.png
Binary file not shown.
Before Width: | Height: | Size: 792 B After Width: | Height: | Size: 839 B |
BIN
gfx/trains.png
BIN
gfx/trains.png
Binary file not shown.
Before Width: | Height: | Size: 996 B After Width: | Height: | Size: 996 B |
12
main.lua
12
main.lua
@ -44,9 +44,13 @@ function restart()
|
||||
|
||||
score = 0
|
||||
coffee = 0
|
||||
pause = false
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
if pause == true then
|
||||
return
|
||||
end
|
||||
-- Update screenshake thingy
|
||||
if scrn_shake > 0 then
|
||||
scrn_shake = scrn_shake - dt
|
||||
@ -161,10 +165,16 @@ function love.draw()
|
||||
love.graphics.setColor(0,0,0,255)
|
||||
love.graphics.print(math.floor(score),8,8)
|
||||
|
||||
-- Draw game over message
|
||||
if pl.alive == false then
|
||||
love.graphics.printf("you didn't make it to work\npress r to retry",0,45,WIDTH,"center")
|
||||
end
|
||||
|
||||
-- Draw pause message
|
||||
if pause == true then
|
||||
love.graphics.printf("paused",0,50,WIDTH,"center")
|
||||
end
|
||||
|
||||
-- Draw coffee meter
|
||||
local cquad = love.graphics.newQuad(48+math.floor(coffee)*9,64,9,9,128,128)
|
||||
if coffee < 5 or pl.frame < 4 then
|
||||
@ -193,6 +203,8 @@ function love.keypressed(key,unicode)
|
||||
return -- avoid unnecessary checks
|
||||
elseif key == 'r' or key == "return" then
|
||||
restart()
|
||||
elseif key == 'p' then
|
||||
pause = not pause
|
||||
elseif key == '1' then
|
||||
SCALE = 1
|
||||
updateScale()
|
||||
|
14
player.lua
14
player.lua
@ -94,6 +94,10 @@ function Player:draw()
|
||||
end
|
||||
|
||||
function Player:kill(status)
|
||||
if self.invul == true then
|
||||
return
|
||||
end
|
||||
|
||||
scrn_shake = 0.25
|
||||
|
||||
if coffee >= 5 then
|
||||
@ -119,8 +123,7 @@ function Player:collideWithTrain()
|
||||
if self.status == 0 then
|
||||
-- check collision with front of train
|
||||
if Player.collideWithPoint(self,train.x+4,train.y+10) or
|
||||
Player.collideWithPoint(self,train.x+2,train.y+24) and
|
||||
self.invul == false then
|
||||
Player.collideWithPoint(self,train.x+2,train.y+24) then
|
||||
if train.type == 1 then -- hit by closed train
|
||||
self:kill(1)
|
||||
|
||||
@ -141,9 +144,14 @@ function Player:collideWithTrain()
|
||||
end
|
||||
end
|
||||
|
||||
if self.status == 3 then
|
||||
if self.status == 3 then -- inside open train
|
||||
if self.x > train.x+135 then
|
||||
self.status = 0
|
||||
elseif train.hasCoffee == true and
|
||||
self:collideWithPoint(train.x+57,train.y+20) then
|
||||
train.hasCoffee = false
|
||||
coffee = coffee + 1
|
||||
if coffee > 5 then coffee = 5 end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
11
train.lua
11
train.lua
@ -5,6 +5,8 @@ normal_train_quad = love.graphics.newQuad(0,0,132,36,256,256)
|
||||
open_train_quad = love.graphics.newQuad(0,48,146,36,256,256)
|
||||
inside_train_quad = love.graphics.newQuad(0,96,146,36,256,256)
|
||||
|
||||
coffee_cup_quad = love.graphics.newQuad(96,0,26,23,128,128)
|
||||
|
||||
TRAIN_MIN_SPEED = 160
|
||||
TRAIN_MAX_SPEED = 200
|
||||
|
||||
@ -24,6 +26,12 @@ function Train.create(type)
|
||||
self.y = 56
|
||||
self.type = type
|
||||
self.alive = true
|
||||
self.hasCoffee = false
|
||||
if self.type == 2 then
|
||||
if math.random(2) == 1 then
|
||||
self.hasCoffee = true
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
@ -48,6 +56,9 @@ function Train:draw()
|
||||
elseif self.type == 2 then -- open train
|
||||
if pl.status == 3 then -- inside
|
||||
love.graphics.drawq(imgTrains,inside_train_quad,self.x-7,self.y)
|
||||
if self.hasCoffee == true then
|
||||
love.graphics.drawq(imgSprites,coffee_cup_quad,self.x+54,self.y+8)
|
||||
end
|
||||
else -- outside
|
||||
love.graphics.drawq(imgTrains,open_train_quad,self.x-7,self.y)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user