From b1ba9bebeb6e167ddf6ea7c9bdf941294961f3a3 Mon Sep 17 00:00:00 2001 From: bakpakin Date: Wed, 20 May 2015 10:01:38 +0800 Subject: [PATCH] Fix up some demo code. --- main.lua | 4 ++-- src/entities/Pig.lua | 6 +++--- src/entities/Player.lua | 4 ++-- src/systems/AISystem.lua | 4 ++-- src/systems/BumpPhysicsSystem.lua | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/main.lua b/main.lua index ec50be3..6bfc9f2 100644 --- a/main.lua +++ b/main.lua @@ -33,7 +33,7 @@ end function love.draw() if paused then love.graphics.setColor(90, 90, 90, 255) - love.graphics.draw(pauseCanvas, 0, 0) + love.graphics.draw(pauseCanvas, 0, 0) love.graphics.setColor(255, 255, 255, 255) love.graphics.setFont(assets.fnt_hud) love.graphics.printf("Paused - P to Resume", love.graphics.getWidth() * 0.5 - 125, love.graphics.getHeight() * 0.4, 250, "center") @@ -93,7 +93,7 @@ beholder.observe("keypress", "\\", function() local fs = love.window.getFullscreen() if fs then love.window.setMode(900, 600, {resizable = true}) - else + else local w, h = love.window.getDesktopDimensions() love.window.setMode(w, h, {fullscreen = true, }) end diff --git a/src/entities/Pig.lua b/src/entities/Pig.lua index 085de86..84e31a2 100644 --- a/src/entities/Pig.lua +++ b/src/entities/Pig.lua @@ -25,9 +25,9 @@ function Pig:init(x, y, target) } self.ai = { - + } - + self.hitbox = {w = 30, h = 21} self.health = 50 self.maxHealth = 50 @@ -40,7 +40,7 @@ function Pig:init(x, y, target) end function Pig:gotHit() - if self.isAlive then + if self.isAlive then self.isAlive = nil self.lifetime = 0.25 self.fadeTime = 0.25 diff --git a/src/entities/Player.lua b/src/entities/Player.lua index aa114e0..b7ff2fd 100644 --- a/src/entities/Player.lua +++ b/src/entities/Player.lua @@ -9,7 +9,7 @@ local Player = class("Player") function Player:draw(dt) if self.hasGun then - local p = self.animation.position + local p = self.animation.position local dy = (p ~= 2 and p ~= 3) and 0 or -1 local dx = self.platforming.direction == 'l' and 2 or -2 love.graphics.draw(assets.img_gun, self.pos.x + 16 + dx, self.pos.y + 10 + dy, self.gunAngle - math.pi / 4) @@ -30,7 +30,7 @@ function Player:onHit() world:add(self) local n = gamestate.current().score local message = "You Died." - if n == 0 then message = "You Failed Pretty Hard." + if n == 0 then message = "You Failed Pretty Hard." elseif n < 10 then message = "You Killed Some Pigs and They Killed you Back." elseif n < 30 then message = "That's a lot of Bacon." elseif n < 100 then message = "You a crazy Pig Killer." diff --git a/src/systems/AISystem.lua b/src/systems/AISystem.lua index fbf40be..ac34604 100644 --- a/src/systems/AISystem.lua +++ b/src/systems/AISystem.lua @@ -7,8 +7,8 @@ end AISystem.filter = tiny.requireAll("ai", "pos", "platforming") function AISystem:process(e, dt) - if not self.target then - return + if not self.target then + return end local targetx = self.target.pos.x local pos = e.pos diff --git a/src/systems/BumpPhysicsSystem.lua b/src/systems/BumpPhysicsSystem.lua index 9037e3c..118961d 100644 --- a/src/systems/BumpPhysicsSystem.lua +++ b/src/systems/BumpPhysicsSystem.lua @@ -18,7 +18,7 @@ local function collisionFilter(e1, e2) if e2.isPlayer then return 'cross' end elseif e1.isBullet then if e2.isPlayer or e2.isBullet then return nil end - end + end if e1.isSolid then if type(e2) == "string" then -- tile collision if e2:byte(1) == oneWayPrefix then -- one way tile @@ -86,8 +86,8 @@ function BumpPhysicsSystem:process(e, dt) end end - if e.onCollision and collided then - e:onCollision(col) + if e.onCollision and collided then + e:onCollision(col) end end end