Compare commits

...

12 Commits

Author SHA1 Message Date
Pascal Abresch 8b2a9e4b30 server update 2022-12-17 17:22:46 +01:00
Pascal Abresch 1a64cc4334 Fix server network 2022-12-12 15:25:03 +01:00
Pascal Abresch 1501ee13b1 reenable some textures 2022-12-04 11:11:19 +01:00
Pascal Abresch 72c301c6b4 add some sources 2022-12-04 11:10:57 +01:00
Pascal Abresch cbe4755d35 script to build package 2022-12-04 11:09:55 +01:00
Pascal Abresch 9ab9d0669c add source for nep textures 2022-12-04 11:09:25 +01:00
Pascal Abresch 25c9bf62fb misc changes 2022-12-04 11:08:48 +01:00
Pascal Abresch 1d87524d40 Add new player sprite; make menu message a function
Co-authored-by: Noriko
2022-12-04 11:07:51 +01:00
Pascal Abresch 6b50f9a6ca Add buttons rendering (WIP)
Co-authored-by: Noriko
2022-12-04 11:05:58 +01:00
Pascal Abresch 0a512bf243 camera offset 2022-12-04 11:04:21 +01:00
Pascal Abresch c78a94d550 enable misc textures 2022-12-04 11:03:53 +01:00
Pascal Abresch 0ae47972a3 Change window casing 2022-10-18 14:27:13 +02:00
30 changed files with 265 additions and 192 deletions

View File

@ -6,7 +6,7 @@ love.conf = function(conf)
conf.window.minwidth = 640
conf.window.resizable = true
conf.window.vsync = -1
conf.window.title = "poppy"
conf.window.title = "Poppy"
conf.version = "11.0"
conf.modules.joystick = false

View File

@ -2,7 +2,7 @@ local CAM_SPEED = 10
camera = {}
camera.target = 0
camera.offset = { x = 0, y = 300 }
camera.offset = { x = 0, y = 0 }
local fullscreen = false
local altPressed, enterPressed = false, false

View File

@ -3,22 +3,32 @@ local player = require("lua.player")
local utils = require("shared.utils")
local fonts = require("shared.fonts")
return function(commands)
return function(commands)
commands.init = function(clientID, args)
local nickname, args = utils.nextStringRecord(args)
local avatarEncoded, args = utils.nextStringRecord(args)
local worldID, args = utils.nextStringRecord(args)
local x, args = utils.nextIntRecord(args)
local y = tonumber(args)
local avatar = love.data.decode("string", "base64", avatarEncoded)
local avatarHash = love.data.decode("string", "base64", avatarEncoded)
print("Connected as " .. clientID .. " with name " .. nickname)
print("New world is " .. worldID .. " Size is [" .. x .. "|" .. y .. "]")
participants[clientID] = player.newPlayer({name = nickname, avatar = levelloop.avatars[avatar].image})
participants[clientID] = player.newPlayer(
{name = nickname, avatar = levelloop.avatars[avatarHash].image, y=y})
participants[clientID].y = y - participants[clientID].avatar:getHeight()
camera.target = clientID
_G.clientID = clientID
levelloop.clientID = clientID
local world = { id = worldID, x = x, y = y }
levelloop.loadworld(world)
camera.setplayer()
end
commands.serverQuit = function(clientID, message)
menu.init(message)
end
@ -86,8 +96,4 @@ local fonts = require("shared.fonts")
end
ui.addChatEntry(name, args)
end
commands.clearCanvas = function(clientID)
drawing.clearAllCanvases()
end
end

View File

@ -7,6 +7,7 @@ commands = {}
require("lua.commands")(commands)
require("shared.commands")(commands)
local socket = require "socket"
local utils = require("shared.utils")
@ -76,15 +77,15 @@ end
local function normalNetworkSend(args)
if clientID == "0" then print("Invalid clientID?") end
local request = constants.protocolVersion ..US.. clientID ..US.. args
assert(levelloop.clientID ~= 0 and levelloop.clientID)
local request = constants.protocolVersion ..US.. levelloop.clientID ..US.. args
levelloop.client:send(request)
end
local function debugNetworkSend(args)
assert(clientID ~= 0)
local request = constants.protocolVersion ..constants.US.. clientID ..constants.US.. args
assert(levelloop.clientID ~= 0 and levelloop.clientID)
local request = constants.protocolVersion ..constants.US.. levelloop.clientID ..constants.US.. args
print("=> " .. utils.pprint(request))
levelloop.client:send(request)
end
@ -202,6 +203,8 @@ function levelloop.init(server, nickname, avatarHash)
levelloop.client:setpeername(server.adress, server.port)
levelloop.client:settimeout(0)
CLIENT = true
SERVER = false
print("Socketnname: " .. levelloop.client:getsockname())
print("Connecting to [" .. server.adress .."]:" .. server.port)
@ -284,6 +287,8 @@ function levelloop.loadworld(world)
levelloop.Canvas.dbg2 = love.graphics.newCanvas(world.x, world.y)
end
levelloop.Canvas.physics = {}
levelloop.world = world
ui.init()
drawing.init()
@ -315,7 +320,7 @@ function levelloop.loadworld(world)
ui.resize()
camera.resize()
end
love.quit = function()
levelloop.networkSend(utils.unit("playerLeave"))
end

View File

@ -113,7 +113,7 @@ function layout.drawTexture(container, x, y, simulate)
if not simulate then
love.graphics.draw(texture, x, y, 0, scale, scale)
end
return x + texture:getWidth()* scale, y + texture:getHeight() * scale
return x + (texture:getWidth() * scale), y + texture:getHeight() * scale
end
@ -241,6 +241,27 @@ function layout.rect(container, x, y, simulate)
end
function layout.button(container, x, y, simulate)
local textObject = love.graphics.newText(fonts.normalFont, container.text)
local width = textObject:getWidth()
local height = textObject:getHeight()
local factor = 1.15
local points = {
x, y,
x + (width *factor), y,
x + (width * factor), y + (height * factor),
x, y + (height * factor),
x, y
}
if not simulate then
love.graphics.rectangle("fill", x, y, width* factor, height* factor)
love.graphics.line(points)
love.graphics.draw(textObject, x + width * 0.075 , y + height * 0.075)
end
return x+ (width *factor), y + (height * factor)
end
function layout.overlayRect(container, x, y, simulate)
asserts.number("layout.overlayRect", 2, x, y)
@ -254,11 +275,10 @@ function layout.overlayRect(container, x, y, simulate)
end
function layout.label(container, x, y, simulate)
if not container.font then container.font = fonts.normalFont end
local text = love.graphics.newText( container.font, container.text )
if not text then text = "Unset text!!" end
if not text then text = love.graphics.newText( container.font, "Unset text!!") end
if not simulate then
love.graphics.draw(text, x, y)
end
@ -354,6 +374,11 @@ function layout.vertical(container, x, y, simulate)
end
function layout.skip(container, x, y, simulate)
return x, y
end
local depth = -1
function layout.handle(container, x, y, simulate)
@ -361,6 +386,7 @@ function layout.handle(container, x, y, simulate)
assert(container, "layout.handle called without container")
local name = container["name"]
if not name then return end
assert(name, "layout.handle container without name")
assert(layout[name], "Unknown layout function " .. name .. " called")

View File

@ -87,7 +87,7 @@ function menu.mousepressed(mousex, mousey)
local fullName = names[love.math.random(1, #names)] .. " " .. lastNames[love.math.random(1, #lastNames)]
local serverID = v.identifier
local serverEntry = menu.serverlist[serverID]
local avatar = love.image.newImageData("textures/player/nephele/dog.png")
local avatar = love.image.newImageData("textures/player/noriko/liz.png")
local avatarHash = love.data.hash("sha512", avatar:getString())
levelloop.init({ adress = serverEntry.host, port = serverEntry.port }, fullName, avatarHash)
layout.uiState = {}
@ -122,71 +122,82 @@ menu.layoutServerList = function()
end
menu.layout = {name ="vertical",
{name = "spacer", height = 20},
{name = "horizontal",
{name = "spacer", width = 20},
{name = "drawTexture", texture = love.graphics.newImage("ressources/Poppy.png")},
{name = "label", font = fonts.bigFont, text = "Welcome to poppy!"},
},
{name = "horizontal",
{name = "spacer", width = 50},
{name = "vertical",
{name = "spacer", height = 20},
{name = "cursorSelect", kind = "localServer", identifier = {"::1", "11150"},
menu.menuMessage = function(message)
if not message then return {name = "skip"} end
return {name = "color",
color = { 1, .5, .5, 1},
{name = "label", font = fonts.bigFont, text = "Welcome to poppy!"}
}
end
menu.layout = function(message)
return {name ="vertical",
{name = "spacer", height = 20},
{name = "horizontal",
{name = "spacer", width = 20},
{name = "drawTexture", texture = love.graphics.newImage("ressources/Poppy.png")},
{name = "label", font = fonts.bigFont, text = "Welcome to poppy!"},
},
menu.menuMessage(message),
{name = "horizontal",
{name = "spacer", width = 50},
{name = "vertical",
{name = "spacer", height = 20},
{name = "cursorSelect", kind = "localServer", identifier = {"::1", "11150"},
{name = "horizontal",
{name = "spacer", width = 10},
{name = "drawTexture",
texture = love.graphics.newImage("textures/menu/serverPlay.png")
},
{name = "spacer", width = 10},
{name = "label", text = "Spin up a local server"},
}
},
{name = "cursorSelect", kind = "localServer", identifier = {"0.0.0.0", "11150"},
{name = "horizontal",
{name = "spacer", width = 10},
{name = "drawTexture",
texture = love.graphics.newImage("textures/menu/serverPlay.png")
},
{name = "spacer", width = 10},
{name = "label", text = "Spin up a local server [IPV4]"},
}
},
{name = "spacer", height = 20},
{name = "label", text = "Or pick a server to join!", font = fonts.headerFont},
{name = "spacer", height = 20},
{name = "horizontal",
{name = "spacer", width = 10},
{name = "drawTexture",
texture = love.graphics.newImage("textures/menu/serverPlay.png")
},
{name = "spacer", width = 10},
{name = "label", text = "Spin up a local server"},
}
},
{name = "cursorSelect", kind = "localServer", identifier = {"0.0.0.0", "11150"},
{name = "horizontal",
{name = "spacer", width = 10},
{name = "drawTexture",
texture = love.graphics.newImage("textures/menu/serverPlay.png")
},
{name = "spacer", width = 10},
{name = "label", text = "Spin up a local server [IPV4]"},
}
},
{name = "spacer", height = 20},
{name = "label", text = "Or pick a server to join!", font = fonts.headerFont},
{name = "spacer", height = 20},
{name = "horizontal",
{name = "spacer", width = 10},
{name = "vertical",
{name = "vertical",
menu.layoutServerList(),
},
{name = "vertical",
{name = "spacer", height = 10},
{name = "horizontal",
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/AddIcon.png")},
{name = "spacer", width = 10 },
{name = "label", text = "placeholder (new server)" },
{name = "spacer", width = 20 },
{name = "label", text = "host: newhost", font = fonts.smallFont},
{name = "spacer", width = 10 },
{name = "label", text = "port: newport", font = fonts.smallFont},
{name = "vertical",
menu.layoutServerList(),
},
{name = "vertical",
{name = "spacer", height = 10},
{name = "horizontal",
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/AddIcon.png")},
{name = "spacer", width = 10 },
{name = "label", text = "placeholder (new server)" },
{name = "spacer", width = 20 },
{name = "label", text = "host: newhost", font = fonts.smallFont},
{name = "spacer", width = 10 },
{name = "label", text = "port: newport", font = fonts.smallFont},
}
}
}
}
}
}
}
}
end
function drawMenu()
function drawMenu(message)
utils.color_push()
love.graphics.setCanvas(menu.Canvas)
uiState = {}
love.graphics.clear( )
layout.handle(menu.layout, 0, 0)
layout.handle(menu.layout(message), 0, 0)
love.graphics.setCanvas()
utils.color_pop()
end
@ -197,11 +208,11 @@ function menu.draw(w, h)
end
function menu.init()
function menu.init(message)
print("init menu")
menu.width, menu.height = love.window.getMode()
menu.Canvas = love.graphics.newCanvas(menu.width, menu.height)
drawMenu()
drawMenu(message)
love.draw = menu.draw
love.keyreleased = menu.keyreleased
love.keypressed = menu.keypressed

View File

@ -90,7 +90,7 @@ function physics.keypressed( key, code, isrepeat)
if isrepeat then return end
if camera.target == 0 then return end
player = participants[camera.target]
local player = participants[clientID]
if key == "p" then
player.flying = not player.flying
if player.flying then
@ -105,7 +105,7 @@ end
function physics.input(dt)
if camera.target == 0 then return end
player = participants[camera.target]
local player = participants[levelloop.clientID]
local speedModified = dt * 20
if love.keyboard.isDown("rshift") or love.keyboard.isDown("lshift")
then
@ -195,7 +195,78 @@ function physics.update(dt)
if granularity < 1 then granularity = 1 end
assert(currentX and currentY)
if player.flying then -- skip physics
if not player.flying then
do -- SCOPE
local blocked_x, blocked_y = false, false
if not SKIP then
for iteration=1, granularity do
intermediateX = currentX + (stepsizeX * iteration)
intermediateY = currentY + (stepsizeY * iteration)
if intermediateY > futureY then -- UP
if physics.is_blocked_x(intermediateX, intermediateY, player.avatar:getWidth()) then
intermediateY = currentY
blocked_y = true
end
end
if intermediateY < futureY then --DOWN
local lowerY = intermediateY + player.avatar:getHeight() -1
if physics.is_blocked_x(intermediateX, lowerY, player.avatar:getWidth()) then
intermediateY = currentY
blocked_y = true
end
end
if intermediateX > futureX then -- ONLY LEFT
if physics.is_blocked_y(intermediateX, intermediateY, player.avatar:getHeight()) then
blocked_x = true
end
end
if intermediateX < futureX then -- ONLY RIGHT
local lowerX = intermediateX + player.avatar:getWidth() -1
if physics.is_blocked_y(lowerX, intermediateY, player.avatar:getHeight()) then
blocked_x = true
end
end
intermediateX, intermediateY, new_sx, new_sy = physics.cap_world(player.avatar:getWidth(), player.avatar:getHeight(), intermediateX, intermediateY, new_sx, new_sy)
if blocked_x and not blocked_y then -- X blocked
--new_sy = 0
player.y = intermediateY
end
if blocked_y and not blocked_x then
--new_sx = 0
player.x = intermediateX
end
if blocked_x and blocked_y then
break
end
if not blocked_x and not blocked_y then
player.x = intermediateX
player.y = intermediateY
end
end
end -- SCOPE
end
-- cap low speed
if new_sx > -.1 and new_sx < .1 then
new_sx = 0
end
if new_sy > -.1 and new_sy < .1 then
new_sy = 0
end
player.speed.x = new_sx
player.speed.y = new_sy
if i == camera.target then -- FIXME: uses camera.target
physics.send_update(player, dt)
end
else -- player.flying
player.x, player.y = futureX, futureY
player.speed.x = new_sx
@ -203,78 +274,6 @@ function physics.update(dt)
if camera.target == i then -- FIXME: uses camera.target
physics.send_update(player, dt)
end
return
end
do -- SCOPE
local blocked_x, blocked_y = false, false
if not SKIP then
for iteration=1, granularity do
intermediateX = currentX + (stepsizeX * iteration)
intermediateY = currentY + (stepsizeY * iteration)
if intermediateY > futureY then -- UP
if physics.is_blocked_x(intermediateX, intermediateY, player.avatar:getWidth()) then
intermediateY = currentY
blocked_y = true
end
end
if intermediateY < futureY then --DOWN
local lowerY = intermediateY + player.avatar:getHeight() -1
if physics.is_blocked_x(intermediateX, lowerY, player.avatar:getWidth()) then
intermediateY = currentY
blocked_y = true
end
end
if intermediateX > futureX then -- ONLY LEFT
if physics.is_blocked_y(intermediateX, intermediateY, player.avatar:getHeight()) then
blocked_x = true
end
end
if intermediateX < futureX then -- ONLY RIGHT
local lowerX = intermediateX + player.avatar:getWidth() -1
if physics.is_blocked_y(lowerX, intermediateY, player.avatar:getHeight()) then
blocked_x = true
end
end
intermediateX, intermediateY, new_sx, new_sy = physics.cap_world(player.avatar:getWidth(), player.avatar:getHeight(), intermediateX, intermediateY, new_sx, new_sy)
if blocked_x and not blocked_y then -- X blocked
--new_sy = 0
player.y = intermediateY
end
if blocked_y and not blocked_x then
--new_sx = 0
player.x = intermediateX
end
if blocked_x and blocked_y then
break
end
if not blocked_x and not blocked_y then
player.x = intermediateX
player.y = intermediateY
end
end
end -- SCOPE
end
-- cap low speed
if new_sx > -.1 and new_sx < .1 then
new_sx = 0
end
if new_sy > -.1 and new_sy < .1 then
new_sy = 0
end
player.speed.x = new_sx
player.speed.y = new_sy
if i == camera.target then -- FIXME: uses camera.target
physics.send_update(player, dt)
end
end
end

View File

@ -8,7 +8,7 @@ playerfuncs.newPlayer = function(arg)
playerTable.speed = {}
playerTable.speed.x = 0
playerTable.speed.y = 0
playerTable.x = 16
playerTable.x = 16
playerTable.y = 16
playerTable.flying = false
return playerTable

View File

@ -372,6 +372,15 @@ function ui.menuDrawer(w, h)
}
}
}
},
{name = "cursorSelectMenu",
identifier = "buttonTest",
kind = "button",
{name = "button",
width = 60,
height = 10,
text = "TestKnopf",
}
}
},
{name = "spacer",
@ -455,7 +464,7 @@ function ui.mousepressed(mousex, mousey)
return
elseif v.kind == "colorpicker" then
print("Picker hit :D")
local scale = 1.0 / granularity
local scale = ui.sidebarScale / granularity
local red = math.floor((mousey - v.y) / v.pointSize) / scale
local green = math.floor((mousex - v.x) / v.pointSize / (scale + 1)) / scale
local blue = (math.floor((mousex - v.x) / v.pointSize) % (scale + 1)) / scale

2
makeCleintLoveFile.sh Executable file
View File

@ -0,0 +1,2 @@
#!sh
zip -r Poppy.love main.lua conf.lua lua/ shared/ ressources/Poppy.png textures/menu/AddIcon.png textures/menu/serverPlay.png server/ textures/blocks/ textures/menu/serverPlay.png textures/player/

Binary file not shown.

BIN
ressources/characters/liz Normal file

Binary file not shown.

View File

@ -1,21 +0,0 @@
local util = require("shared.utils")
local constants = require("server.constants")
local rpc = require("server.rpc")
return function(commands)
function commands.drawTexture(clientID, args)
sharedCommands.drawTexture(clientID, args)
broadcast(clientID, util.unit("drawTexture", args))
end
function commands.deleteTexture(clientID, args)
sharedCommands.deleteTexture(clientID, args)
broadcast(clientID, util.unit("deleteTexture", args))
end
function commands.clearCanvas(clientID)
broadcast(clientID, "clearCanvas")
end
function commands.fillCanvas(clientID, args)
broadcast(clientID, util.unit("fillCanvas", args))
end
end

View File

@ -11,7 +11,7 @@ return function(commands)
participants[clientID].y = y
participants[clientID].speedx = speedx
participants[clientID].speedy = speedy
broadcast(clientID, util.unit("moveUpdate", x, y, speedx, speedy))
end

View File

@ -10,7 +10,6 @@ protocolVersion = constants.protocolVersion
local commands = {}
require("server.commands.players")(commands)
require("server.commands.physics")(commands)
require("server.commands.drawing")(commands)
require("server.commands.chat")(commands)
require("server.commands.saving")(commands)
require("shared.commands")(commands)
@ -64,7 +63,8 @@ function loadTextures(directory, container)
return container
end
love.window.minimize( )
love.window.setTitle( "Poppy server" )
function mainloop(dt)
local data, ip, port
data, ip, port = server:receivefrom()
@ -78,7 +78,7 @@ function mainloop(dt)
end
local result = rpc.validate(data)
--print("=> " .. util.pprint(data))
print("=> " .. util.pprint(data))
if not result.errorMsg then
if result.clientID == 0 then
@ -104,18 +104,21 @@ function levelloop.init(host)
if not status then
error("Server could not be started :( " .. value)
end
print("Server startup. listening on " .. server:getsockname())
local ip, port =server:getsockname()
print("Server startup. listening on " .. ip .. " [".. port .."]")
loadTextures("textures/blocks", levelloop.textures)
levelloop.world = constants.world
levelloop.Canvas = {}
levelloop.Canvas.fg = love.graphics.newCanvas(levelloop.world.x, levelloop.world.y)
levelloop.Canvas.bg = love.graphics.newCanvas(levelloop.world.x, levelloop.world.y)
print("Startup!")
SERVER = true
CLIENT = false
love.update = mainloop
love.draw = function()
love.graphics.clear(.2, 0, .2)
love.graphics.print("Poppy server is running.", fonts.normalFont, 20, 20)
love.graphics.print("listening on " .. server:getsockname(), fonts.normalFont, 20, 50)
love.graphics.print("listening on " .. ip .. " [".. port .."]" , fonts.normalFont, 20, 50)
return end
love.keyreleased = function() return end
love.keypressed = function() return end

View File

@ -62,12 +62,12 @@ function rpc.unprivligedExecute(commands, record, ip, port)
local command = record:match("^.-\31")
if command then command = rpc.clean(command) end
record = record:gsub("^.-\31","")
if not command then
command = record
record = nil
end
rpc.assert(type(commands[command]) == "function", "Unknown command encountered!" .. command)
if record then
rpc.print("executing " .. command .. " with " .. record)
@ -77,8 +77,8 @@ function rpc.unprivligedExecute(commands, record, ip, port)
return commands[command](ip, port)
end
end
function rpc.execute(commands, clientID, record)
assert(type(commands) == "table")
assert(type(record) == "string")

View File

View File

@ -1,9 +1,11 @@
local player = require("lua.player")
local utils = require("shared.utils")
return function(commands)
commands.moveUpdate = function(clientID, args)
if SERVER then
broadcast(clientID, utils.unit("moveUpdate", args))
end
if not participants[clientID] then return end
local x, args = utils.nextIntRecord(args)
local y, args = utils.nextIntRecord(args)
@ -19,15 +21,19 @@ return function(commands)
commands.moveFlying = function(clientID, args)
if SERVER then
broadcast(clientID, utils.unit("moveFlying", args))
end
if not participants[clientID] then return end
participants[clientID].flying = (args == "true")
end
commands.drawTexture = function(clientID, args)
if _G.camera then
if clientID == camera.target then return end
if SERVER then
broadcast(clientID, utils.unit("drawTexture", args))
end
if not participants[clientID] then return end
local x, args = utils.nextIntRecord(args)
local y, args = utils.nextIntRecord(args)
local layer, args = utils.nextStringRecord(args)
@ -37,29 +43,30 @@ return function(commands)
local g, args = utils.nextIntRecord(args)
local b, args = utils.nextIntRecord(args)
a = tonumber(args) or 1
if not textures[hash] then error("Failed to find hash!") return end
if not textures[hash].image then
textures[hash].image = love.graphics.newImage(textures[hash].data)
if not levelloop.textures[hash] then error("Failed to find hash!") return end
if not levelloop.textures[hash].image then
levelloop.textures[hash].image = love.graphics.newImage(levelloop.textures[hash].data)
end
love.graphics.setCanvas(levelloop.Canvas[layer])
love.graphics.setBlendMode("alpha")
utils.color_push()
love.graphics.setColor(r, g, b ,a )
love.graphics.draw(textures[hash].image, x, y)
love.graphics.draw(levelloop.textures[hash].image, x, y)
utils.color_pop()
love.graphics.setCanvas()
end
commands.deleteTexture = function(clientID, args)
if _G.camera then
if clientID == camera.target then return end
if SERVER then
broadcast(clientID, utils.unit("deleteTexture", args))
end
if not participants[clientID] then return end
local x, args = utils.nextIntRecord(args)
local y, args = utils.nextIntRecord(args)
local width, args = utils.nextIntRecord(args)
local height, layer = utils.nextIntRecord(args)
love.graphics.setCanvas(canvas[layer])
love.graphics.setCanvas(levelloop.Canvas[layer])
love.graphics.setBlendMode("replace")
utils.color_push()
love.graphics.setColor(0,0,0,0)
@ -69,7 +76,12 @@ return function(commands)
love.graphics.setCanvas()
end
commands.fillCanvas = function(clientID, args)
if SERVER then
broadcast(clientID, utils.unit("fillCanvas", args))
end
if not participants[clientID] then return end
local layer, args = utils.nextStringRecord(args)
local hashEncoded, args = utils.nextStringRecord(args)
hash = love.data.decode("string", "base64", hashEncoded)
@ -77,12 +89,18 @@ return function(commands)
local g, args = utils.nextIntRecord(args)
local b, args = utils.nextIntRecord(args)
a = tonumber(args)
love.graphics.setCanvas(levelloop.Canvas[layer])
love.graphics.clear()
if not levelloop.textures[hash] then error("Failed to find hash!") return end
if not levelloop.textures[hash].image then
levelloop.textures[hash].image = love.graphics.newImage(levelloop.textures[hash].data)
end
utils.color_push()
love.graphics.setColor({r, g, b, a})
if not levelloop.textures[hash].image then
love.graphics.newImage(levelloop.textures[hash].data)
end
for x = 0, levelloop.world.x -levelloop.textures[hash].image:getPixelWidth(),
levelloop.textures[hash].image:getPixelWidth() do
for y = 0, levelloop.world.y -levelloop.textures[hash].image:getPixelHeight(),
@ -90,8 +108,23 @@ return function(commands)
love.graphics.draw(levelloop.textures[hash].image, x, y)
end
end
utils.color_pop()
love.graphics.setCanvas()
end
commands.clearCanvas = function(clientID)
if SERVER then
broadcast(clientID, "clearCanvas")
end
love.graphics.setCanvas(levelloop.Canvas.fg)
love.graphics.clear()
love.graphics.setCanvas(levelloop.Canvas.bg)
love.graphics.clear()
love.graphics.setCanvas(levelloop.Canvas.dbg)
love.graphics.clear()
love.graphics.setCanvas()
levelloop.Canvas.physics = {}
end
end

View File

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 129 B

View File

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 413 B

View File

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 714 B

View File

Before

Width:  |  Height:  |  Size: 722 B

After

Width:  |  Height:  |  Size: 722 B

View File

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 731 B

View File

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 714 B

View File

Before

Width:  |  Height:  |  Size: 602 B

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Binary file not shown.