requires tserial module, minor set up for serizlation
This commit is contained in:
parent
cd2e0d862a
commit
7fa31726f4
3 changed files with 20 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ Input.playermovekeys = { up = "up", down = "down", left = "left", right = "right
|
||||||
Input.playerswitchkeys = { ["1"] = "1", ["2"] = "2", ["3"] = "3"}
|
Input.playerswitchkeys = { ["1"] = "1", ["2"] = "2", ["3"] = "3"}
|
||||||
Input.colorfromkey = {"red", "green", "blue"}
|
Input.colorfromkey = {"red", "green", "blue"}
|
||||||
|
|
||||||
function Input:handler()
|
function Input:handler(dt)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
5
main.lua
5
main.lua
|
|
@ -1,6 +1,5 @@
|
||||||
love.graphics.setDefaultFilter("linear", "nearest")
|
love.graphics.setDefaultFilter("linear", "nearest")
|
||||||
|
|
||||||
|
|
||||||
class = require "libs/middleclass"
|
class = require "libs/middleclass"
|
||||||
Timer = require "libs/hump/timer"
|
Timer = require "libs/hump/timer"
|
||||||
sfxr = require "libs/sfxrlua/sfxr"
|
sfxr = require "libs/sfxrlua/sfxr"
|
||||||
|
|
@ -33,8 +32,8 @@ function love.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
Input:handler()
|
Input:handler(dt)
|
||||||
currentRoom:update()
|
currentRoom:update(dt)
|
||||||
|
|
||||||
if love.keyboard.isDown("w") then worldSha = worldSha + 1 end
|
if love.keyboard.isDown("w") then worldSha = worldSha + 1 end
|
||||||
if love.keyboard.isDown("s") then worldSha = worldSha - 1 end
|
if love.keyboard.isDown("s") then worldSha = worldSha - 1 end
|
||||||
|
|
|
||||||
19
room.lua
19
room.lua
|
|
@ -1,5 +1,6 @@
|
||||||
Room = class("Room")
|
Room = class("Room")
|
||||||
|
|
||||||
|
require "libs/TSerial"
|
||||||
require "player"
|
require "player"
|
||||||
require "box"
|
require "box"
|
||||||
require "wall"
|
require "wall"
|
||||||
|
|
@ -173,7 +174,10 @@ function Room:movePlayer(key)
|
||||||
|
|
||||||
local initialTargetEntity
|
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 initialTargetEntity then initialTargetEntity:bump() end
|
||||||
|
|
||||||
if not self:isInBounds(initialTargetCell) then
|
if not self:isInBounds(initialTargetCell) then
|
||||||
|
|
@ -467,6 +471,14 @@ function Room:nextRoomCheck()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Room:save()
|
||||||
|
self:serialize()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Room:serialize()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function nextRoom(pos)
|
function nextRoom(pos)
|
||||||
local exit
|
local exit
|
||||||
local newPos = {x = pos.x, y = pos.y}
|
local newPos = {x = pos.x, y = pos.y}
|
||||||
|
|
@ -484,9 +496,12 @@ function nextRoom(pos)
|
||||||
newPos.y = gridHeight
|
newPos.y = gridHeight
|
||||||
end
|
end
|
||||||
|
|
||||||
|
currentRoom:save()
|
||||||
|
|
||||||
currentRoom = Room:new{
|
currentRoom = Room:new{
|
||||||
player = {
|
player = {
|
||||||
x = newPos.x, y = newPos.y, activeColors = currentRoom:getActiveColors()
|
x = newPos.x, y = newPos.y, activeColors = currentRoom:getActiveColors()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue