1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
|