From e77609c5bc8b44aa22ef88063246fd05add5e705 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 24 Mar 2023 21:11:10 +0000 Subject: use lmdb for world storage; plus other small things support numpad 8456 for movement in addition to wasd refactor server and add player module update outdated documentation slightly --- server/player.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 server/player.lua (limited to 'server/player.lua') diff --git a/server/player.lua b/server/player.lua new file mode 100644 index 0000000..365eadc --- /dev/null +++ b/server/player.lua @@ -0,0 +1,31 @@ +local class = require'common.class' +local Pos = require'common.coords'.Pos + +local nextid = 1 + +local function random_color() + return {math.random(),math.random(),math.random()} +end + +local Player = class() +function Player.make(cls,peer) + local self = { + pos = Pos:make(0,0), + color = random_color(), + peer = peer, + id = nextid, + } + nextid = nextid + 1 + return setmetatable(self,cls) +end +function Player.info_part(self) + -- eh + return { + id=self.id, + x=self.pos.x, + y=self.pos.y, + color=self.color, + } +end + +return {Player=Player} -- cgit v1.2.3