Skip to content

Commit

Permalink
Added Final Score to appear
Browse files Browse the repository at this point in the history
Fixed some errors and bugs
Added all map colider to a new file, to cleanup the code
Added LetterboadTimer to show the remaining time
  • Loading branch information
Jictyvoo committed Feb 8, 2019
1 parent a2ac9bc commit 458d004
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 124 deletions.
55 changes: 55 additions & 0 deletions src/assets/sprites/DeficientElevator/button.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
return {
frames = {
pressed = {
frame = {
h = 400,
w = 240,
x = 243,
y = 1,
},
sourceSize = {
h = 400,
w = 240,
},
spriteSourceSize = {
h = 400,
w = 240,
x = 0,
y = 0,
},
trimmed = false,
rotated = false,
},
normal = {
frame = {
h = 400,
w = 240,
x = 1,
y = 1,
},
sourceSize = {
h = 400,
w = 240,
},
spriteSourceSize = {
h = 400,
w = 240,
x = 0,
y = 0,
},
trimmed = false,
rotated = false,
},
},
meta = {
format = "RGBA8888",
size = {
h = 402,
w = 484,
},
scale = "1",
app = "http://www.codeandweb.com/texturepacker",
image = "button.png",
version = "1.0",
},
}
Binary file added src/assets/sprites/DeficientElevator/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/sprites/misc/letterboard_timer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/controllers/GameDirector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local CameraController = require "controllers.CameraController"
local DataPersistence = require "controllers.DataPersistence"

-- Models
local LetterboardTimer = require "models.LetterboardTimer"
local World = require "models.business.World"
local Wall = require "models.business.Wall"

Expand All @@ -29,11 +30,12 @@ function GameDirector:new()
libraries = {
Sanghost = Sanghost, ButtonManager = ButtonManager, Button = Button, Pixelurite = Pixelurite,
CameraController = CameraController, DataPersistence = DataPersistence,
Wall = Wall
Wall = Wall, LetterboardTimer = LetterboardTimer
},
fonts = {
default = love.graphics.getFont(),
ledDigits = love.graphics.newFont("assets/fonts/DS-DIGII.ttf", 36),
default = love.graphics.getFont()
letterboard = love.graphics.newFont("assets/fonts/advanced_led_board-7.ttf", 36)
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/controllers/gamemodes/BusStop/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ end

function GameController:reset()
self.x = 900; self.currentStop = 1; self.requestedStop = love.math.random(5)
self.elapsedTime = 0; self.tries = 0; self.score = 0
self.elapsedTime = 0; self.tries = 0; self.score = 0; self.totalTime = 40
end

function GameController:setGamemodesController(gamemodeController)
self.gamemodeController = gamemodeController
end

function GameController:finishGame()
self.gamemodeController:increaseScore(self.score)
self.gamemodeController:exitGamemode()
self:reset()
end
Expand All @@ -68,12 +69,6 @@ end
function GameController:keyreleased(key, scancode)
end

function GameController:mousemoved(x, y, dx, dy, istouch)
self.tx = x
self.ty = y
print(x, y)
end

function GameController:resetStop()
self.x = 900
if self.currentStop >= #self.busStops then self.currentStop = 1 else self.currentStop = self.currentStop + 1 end
Expand Down Expand Up @@ -105,6 +100,7 @@ function GameController:draw()
love.graphics.setFont(gameDirector:getFonts().default)
love.graphics.draw(self.busStops[self.requestedStop], -70, 240, -0.65, 0.5, 0.5)
love.graphics.draw(self.background, 0, 0, 0)
gameDirector:getLibrary("LetterboardTimer"):draw(self.totalTime)
end

return GameController
51 changes: 47 additions & 4 deletions src/controllers/gamemodes/DeficientElevator/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,30 @@ function GameController:new(world)
background = love.graphics.newImage("assets/sprites/DeficientElevator/bus_background.png"),
elevator = love.graphics.newImage("assets/sprites/DeficientElevator/elevator.png"),
wheelchair = gameDirector:getLibrary("Pixelurite").configureSpriteSheet("wheelchair", "assets/sprites/DeficientElevator/", true, nil, 1, 1, true),
elapsedTime = 0,
controlPanel = love.graphics.newImage("assets/sprites/DeficientElevator/control_panel.png"),
panelButton = {}, buttonSprite = gameDirector:getLibrary("Pixelurite").getSpritesheet():new("button", "assets/sprites/DeficientElevator/"),
elapsedTime = 0, totalTime = 20,
score = 0, currentState = 0,
driverSprite = gameDirector:getLibrary("Pixelurite").configureSpriteSheet("driver", "assets/sprites/DeficientElevator/", true, nil, 1, 1, true)
}
world:addCallback("DeficientElevator", beginContact, "beginContact")
world:changeCallbacks("DeficientElevator")

this = setmetatable(this, GameController)

local spriteQuads = this.buttonSprite:getQuads()
local buttonQuads = {
normal = spriteQuads["normal"], hover = spriteQuads["normal"],
pressed = spriteQuads["pressed"], disabled = spriteQuads["pressed"]
}
local button = gameDirector:getLibrary("Button"):new(nil, 516, 94, 400, 240, buttonQuads, this.buttonSprite:getAtlas())
button:setCallback(function(self) this:elevatorMovement("up") end)
table.insert(this.panelButton, button)
button = gameDirector:getLibrary("Button"):new(nil, 516, 273, 400, 240, buttonQuads, this.buttonSprite:getAtlas())
button:setCallback(function(self) this:elevatorMovement("down") end)
button:setScale(1, -1)
button:setOffset(0, 240)
table.insert(this.panelButton, button)
return this
end

Expand All @@ -35,14 +51,14 @@ function GameController:getInstance(world)
end

function GameController:reset()
self.currentState = 0; self.score = 0; self.elevatorPosition = 0; self.elapsedTime = 0
self.currentState = 0; self.score = 0; self.elevatorPosition = 0; self.elapsedTime = 0; self.totalTime = 20
end

function GameController:setGamemodesController(gamemodeController)
self.gamemodeController = gamemodeController
end

function GameController:keypressed(key, scancode, isrepeat)
function GameController:elevatorMovement(key)
if key == "up" then
if self.elevatorPosition > -38 then
self.elevatorPosition = self.elevatorPosition - 4
Expand All @@ -58,14 +74,38 @@ function GameController:keypressed(key, scancode, isrepeat)
end
end

function GameController:keypressed(key, scancode, isrepeat)
self:elevatorMovement(key)
end

function GameController:keyreleased(key, scancode)
end

function GameController:mousemoved(x, y, dx, dy, istouch)
for _, button in pairs(self.panelButton) do
button:mousemoved(x, y, dx, dy, istouch)
end
end

function GameController:mousepressed(x, y, button, istouch)
for _, button in pairs(self.panelButton) do
button:mousepressed(x, y, button, istouch)
end
end

function GameController:mousereleased(x, y, button, istouch)
for _, button in pairs(self.panelButton) do
button:mousereleased(x, y, button, istouch)
end
end

function GameController:update(dt)
self.elapsedTime = self.elapsedTime + dt
self.totalTime = self.totalTime - dt
self.driverSprite:update(dt)
self.wheelchair:update(dt)
if self.elapsedTime >= 10 then
if self.totalTime <= 0 then
self.gamemodeController:increaseScore(self.score)
self.gamemodeController:exitGamemode()
self:reset()
end
Expand All @@ -77,7 +117,10 @@ function GameController:draw()
if self.currentState == 1 then
self.wheelchair:draw(158, 430 + self.elevatorPosition)
end
love.graphics.draw(self.controlPanel, 517, 113, 0, 1, 1)
for _, button in pairs(self.panelButton) do button:draw() end
self.driverSprite:draw(45, 467)
gameDirector:getLibrary("LetterboardTimer"):draw(self.totalTime)
end

return GameController
Loading

0 comments on commit 458d004

Please sign in to comment.