From c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Mon, 29 Jan 2024 16:20:10 -0600 Subject: All the files --- src/player.moon | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/player.moon (limited to 'src/player.moon') diff --git a/src/player.moon b/src/player.moon new file mode 100644 index 0000000..076f9bb --- /dev/null +++ b/src/player.moon @@ -0,0 +1,49 @@ +char = require "char" +util = require "util" +main = require "main" +bp = require "broadphase" +import KeyInput from char +import Vec2 from util + +mod = ... +--[[A player that we receive information about]] +class RemotePlayer extends char.Character + new: (uname, data, charclass) => + super(uname, data, charclass) + +class LocalPlayer extends char.Character + new:(uname, data, charclass) => + super(uname, data, charclass) + + draw: (...) => + super(...) + healthnode = am.group() ^ {am.translate(-main.width/2,main.height/2) ^ am.text(string.format("Health:%d", @health), vec4(255,255,255,255), "left","top")\tag "health text"} + @node\append(healthnode) + + take_damage: (_from, ammt) => + if am.current_time! - @last_dammage > 1 + @health -= ammt + @last_dammage = am.current_time! + (@node)("health text").text = string.format("Health:%d",@health) + if @health == 0 + @\die! + + filter: (other) => + if other.canfall + return "cross" + if other.hurtbox + if other.owner ~= @ + @take_damage(other,1) + return "cross" + else + return "slide" + die: (...) => + --[[When the player dies, wait 100 ms, load the level, and drop them on the spawnpoint]] + + super(...) + + + +mod["RemotePlayer"] = RemotePlayer +mod["LocalPlayer"] = LocalPlayer +mod -- cgit v1.2.3-70-g09d2