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