diff options
| author | Alexander M Pickering <alex@cogarr.net> | 2024-01-29 16:20:10 -0600 |
|---|---|---|
| committer | Alexander M Pickering <alex@cogarr.net> | 2024-01-29 16:20:10 -0600 |
| commit | c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06 (patch) | |
| tree | ac2bb208dab1274cdc5e9059ffe014ae19181a4c /src/player.moon | |
| download | fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.gz fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.bz2 fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.zip | |
All the files
Diffstat (limited to 'src/player.moon')
| -rw-r--r-- | src/player.moon | 49 |
1 files changed, 49 insertions, 0 deletions
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 |
