diff --git a/input.lua b/input.lua index b4d5d46..d0a6816 100644 --- a/input.lua +++ b/input.lua @@ -4,7 +4,7 @@ Input.playermovekeys = { up = "up", down = "down", left = "left", right = "right Input.playerswitchkeys = { ["1"] = "1", ["2"] = "2", ["3"] = "3"} Input.colorfromkey = {"red", "green", "blue"} -function Input:handler() +function Input:handler(dt) end diff --git a/main.lua b/main.lua index aec1818..57b67c6 100644 --- a/main.lua +++ b/main.lua @@ -1,6 +1,5 @@ love.graphics.setDefaultFilter("linear", "nearest") - class = require "libs/middleclass" Timer = require "libs/hump/timer" sfxr = require "libs/sfxrlua/sfxr" @@ -33,8 +32,8 @@ function love.load() end function love.update(dt) - Input:handler() - currentRoom:update() + Input:handler(dt) + currentRoom:update(dt) if love.keyboard.isDown("w") then worldSha = worldSha + 1 end if love.keyboard.isDown("s") then worldSha = worldSha - 1 end diff --git a/room.lua b/room.lua index 28c5c92..f29f038 100644 --- a/room.lua +++ b/room.lua @@ -1,5 +1,6 @@ Room = class("Room") +require "libs/TSerial" require "player" require "box" require "wall" @@ -173,7 +174,10 @@ function Room:movePlayer(key) local initialTargetEntity - initialTargetEntity = self:getCellInMatrix(self.collidableMatrices[color], initialTargetCell) + if self:isInBounds(initialTargetCell) then + initialTargetEntity = self:getCellInMatrix(self.collidableMatrices[color], initialTargetCell) + end + if initialTargetEntity then initialTargetEntity:bump() end if not self:isInBounds(initialTargetCell) then @@ -467,6 +471,14 @@ function Room:nextRoomCheck() end end +function Room:save() + self:serialize() +end + +function Room:serialize() + +end + function nextRoom(pos) local exit local newPos = {x = pos.x, y = pos.y} @@ -484,9 +496,12 @@ function nextRoom(pos) newPos.y = gridHeight end + currentRoom:save() + currentRoom = Room:new{ player = { x = newPos.x, y = newPos.y, activeColors = currentRoom:getActiveColors() } } -end \ No newline at end of file +end +