This commit is contained in:
Daniel Flanagan 2022-05-25 10:00:06 -05:00
parent d02fe3256d
commit f9f94b446a
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
4 changed files with 13 additions and 9 deletions

View file

@ -48,7 +48,6 @@ script = ExtResource( 2 )
scale = Vector2( 4, 4 )
frames = SubResource( 7 )
animation = "idle"
frame = 1
playing = true
offset = Vector2( 1, -11 )
@ -60,4 +59,8 @@ script = ExtResource( 3 )
[node name="nav_line" type="Line2D" parent="."]
points = PoolVector2Array( 0, 30, 30, 30, 0, 0 )
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
target_desired_distance = 60.0
radius = 30.0
[connection signal="die" from="hurtbox" to="." method="_on_hurtbox_die"]

View file

@ -31,6 +31,7 @@ func _draw():
pass
func _physics_process(delta):
print("Slime nav %s %s %s" % [navigation, position, target_player.position])
nav_path = navigation.get_simple_path(position, target_player.position)
if not nav_path.empty() and (position - target_player.position).length() > (128 + 64):
if (nav_path[0] - position).length() < 5: target_position = nav_path[1]

View file

@ -13,6 +13,8 @@ onready var current_zoom_level_index = 2
onready var player = null
func _ready():
if not get_tree().network_peer:
Global.client.singleplayer()
for c in players.get_children(): c.queue_free()
# TODO: probably have to wait for all peers to be ready before we add players
# camera.zoom = Vector2(0.25, 0.25)

View file

@ -1,6 +1,6 @@
// import { randomInt } from "./deps.ts";
const SERVER_VERSION = "0.2.0";
const SERVER_VERSION = "1.0.0";
// TODO: version comparison
type ID = number;
@ -69,9 +69,7 @@ class Client {
try {
if (this.isConnected()) {
this.socket.send(
typeof message === "object"
? ("json:" + JSON.stringify(message))
: message,
typeof message === "object" ? (JSON.stringify(message)) : message,
);
}
// TODO: maybe log when we try to send and we're not connected?
@ -333,15 +331,15 @@ interface ClientMessage {
function parseMessage(message: string): { type: string; data?: ServerData } {
const trimmedMessage = message.trim();
if (trimmedMessage.startsWith("json:")) {
const { type, ...data } = JSON.parse(trimmedMessage.substr(5));
if (trimmedMessage.startsWith("{")) {
const { type, ...data } = JSON.parse(trimmedMessage);
return { type, data };
} else {
const splitAt = trimmedMessage.indexOf(":");
if (splitAt > 0) {
return {
type: trimmedMessage.substr(0, splitAt),
data: trimmedMessage.substr(splitAt + 1),
type: trimmedMessage.substring(0, splitAt),
data: trimmedMessage.substring(splitAt + 1),
};
} else {
return { type: trimmedMessage };