Skip to content

Commit

Permalink
coords innit
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanyLeonic committed Mar 3, 2024
1 parent 7c29be2 commit a9cc848
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion game-source/scenes/other_player/other_player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ script = ExtResource("1_lpra8")
target_position = Vector2(0, 19)

[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.458, 0.368)
scale = Vector2(1.245, 1)
texture = ExtResource("2_ldfvl")
hframes = 3
vframes = 4
Expand Down
3 changes: 3 additions & 0 deletions game-source/scenes/player_character/player_character.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extends CharacterBody2D
@onready var wsClient: WebSocketClient = get_tree().current_scene.find_child('WebSocketClient')
@onready var container: VBoxContainer = get_tree().current_scene.find_child('CanvasLayer').find_child('SpawnListScroll').find_child('SpawnListContainer')
@onready var inventoryContainer: VBoxContainer = get_tree().current_scene.find_child('CanvasLayer').find_child('Inventory').find_child('InventoryList')
@onready var coordLabel: Label = get_tree().current_scene.find_child('CanvasLayer').find_child('Coord')

@onready var OtherObjects: Node2D = get_tree().current_scene.find_child('OtherObjects')
@onready var BoxObject = preload('res://scenes/box/box.tscn')
Expand Down Expand Up @@ -162,12 +163,14 @@ func _input(event):


func make_player_state(make_player_state:Vector2):
coordLabel.text = "X: " + str(make_player_state.x) + " Y: " + str(make_player_state.y)
return JSON.stringify({
"initialised": true,
"player": playerInfo,
"coordinates": [make_player_state.x, make_player_state.y]
})


func _on_player_did_move(new_pos):
wsClient.send(make_player_state(new_pos))
var ser_res = JSON.parse_string(await wsClient.message_received)
Expand Down
6 changes: 6 additions & 0 deletions game-source/scenes/player_character/player_character.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,10 @@ offset_bottom = 60.0
[node name="InventoryList" type="VBoxContainer" parent="CanvasLayer/Inventory"]
layout_mode = 2

[node name="Coord" type="Label" parent="CanvasLayer"]
offset_left = 459.0
offset_top = 280.0
offset_right = 572.0
offset_bottom = 321.0

[connection signal="player_did_move" from="." to="." method="_on_player_did_move"]

0 comments on commit a9cc848

Please sign in to comment.