summaryrefslogtreecommitdiff
path: root/server/player.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-03-24 21:11:10 +0000
committerubq323 <ubq323@ubq323.website>2023-03-24 21:11:10 +0000
commite77609c5bc8b44aa22ef88063246fd05add5e705 (patch)
tree1829e2098e40f7fad82af8707bd8a359edd2be1d /server/player.lua
parent0927f9297c06525a453b4aad44fa4c2916c75906 (diff)
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
Diffstat (limited to 'server/player.lua')
-rw-r--r--server/player.lua31
1 files changed, 31 insertions, 0 deletions
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}