Skip to content

Commit

Permalink
Fixed errors
Browse files Browse the repository at this point in the history
Added sprite into passenger in DriveTheBus
  • Loading branch information
Jictyvoo committed Feb 7, 2019
1 parent 549c07e commit 53f1bc2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/controllers/gamemodes/BusStop/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ end

function GameController:keypressed(key, scancode, isrepeat)
if key == "space" then
self.tries = self.tries + 1
if self.tries > 3 then
self:finishGame()
elseif self.x >= 296 - 10 and self.x <= 296 + 10 then
if self.x >= 296 - 10 and self.x <= 296 + 10 then
if self.currentStop == self.requestedStop then
self.requestedStop = love.math.random(1, #self.busStops); self.score = self.score + 1
else
self:finishGame()
self.tries = self.tries + 1
if self.tries > 3 then
self:finishGame()
end
end
self:resetStop()
end
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/gamemodes/DriveTheBus/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function GameController:new(world)
busHead = Bus:new(world.world, 200, 150, BusComponent),
background = love.graphics.newImage("assets/sprites/DriveTheBus/background.png"),
cameraController = nil,
passengers = {},
passengers = {}, passengerSprite = love.graphics.newImage("assets/sprites/DriveTheBus/bus_stop.png"),
mapSize = {w = 2400, h = 1800},
elapsedTime = 0,
score = 0,
Expand Down Expand Up @@ -107,7 +107,7 @@ function GameController:removePassenger(fixture)
end

function GameController:addPassenger()
local passenger = Passenger:new(self.world.world, love.math.random(self.mapSize.w), love.math.random(self.mapSize.h))
local passenger = Passenger:new(self.world.world, love.math.random(self.mapSize.w), love.math.random(self.mapSize.h), self.passengerSprite)
self.passengers[passenger:getFixture()] = passenger
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ local Passenger = {}

Passenger.__index = Passenger

function Passenger:new(world, x, y)
function Passenger:new(world, x, y, sprite)
local this = {
body = love.physics.newBody(world, x or 0, y or 0, "static"),
shape = love.physics.newCircleShape(10),
sprite = sprite,
fixture = nil
}

Expand All @@ -32,7 +33,8 @@ function Passenger:update(dt)
end

function Passenger:draw()
love.graphics.circle("fill", self.body:getX(), self.body:getY(), 10)
--love.graphics.circle("line", self.body:getX(), self.body:getY(), 10)
love.graphics.draw(self.sprite, self.body:getX(), self.body:getY(), 0, 1 , 1, 10, 10)
end

return Passenger

0 comments on commit 53f1bc2

Please sign in to comment.