Player spawning refactoring complete

main
Martin Felis 2024-01-28 12:30:57 +01:00
parent c36edf7651
commit 8238fabaa8
5 changed files with 18 additions and 28 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
# Godot 4+ specific ignores # Godot 4+ specific ignores
.godot/ .godot/
assets/sounds/

View File

@ -7,7 +7,7 @@ class_name Player extends CharacterBody3D
@export var move_down_action := "move_down" @export var move_down_action := "move_down"
@export var move_up_action := "move_up" @export var move_up_action := "move_up"
@export var dash_action := "dash" @export var dash_action := "dash"
@export var bomb_action := "bomp" @export var bomb_action := "bomb"
@export var coloring_sprite_path : NodePath @export var coloring_sprite_path : NodePath
@export var coloring_bomb_sprite_path : NodePath @export var coloring_bomb_sprite_path : NodePath

View File

@ -18,12 +18,6 @@ collision_layer = 5
collision_mask = 7 collision_mask = 7
velocity = Vector3(0, -378.927, 0) velocity = Vector3(0, -378.927, 0)
script = ExtResource("1_w5gy0") script = ExtResource("1_w5gy0")
move_right_action = "move_right_p1"
move_left_action = "move_left_p1"
move_down_action = "move_down_p1"
move_up_action = "move_up_p1"
dash_action = "dash_p1"
bomb_action = "bomb_p1"
[node name="Geometry" type="MeshInstance3D" parent="."] [node name="Geometry" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.472656, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.472656, 0)

View File

@ -145,10 +145,22 @@ func spawn_players():
player1.color = Color(1, 0, 0, 1) player1.color = Color(1, 0, 0, 1)
player1.coloring_sprite_path = world_coloring_viewport.get_node("Player1Sprite").get_path() player1.coloring_sprite_path = world_coloring_viewport.get_node("Player1Sprite").get_path()
player1.coloring_bomb_sprite_path = world_coloring_viewport.get_node("Player1BombSprite").get_path() player1.coloring_bomb_sprite_path = world_coloring_viewport.get_node("Player1BombSprite").get_path()
player1.move_right_action += "_p1"
player1.move_left_action += "_p1"
player1.move_up_action += "_p1"
player1.move_down_action += "_p1"
player1.dash_action += "_p1"
player1.bomb_action += "_p1"
var player2: Player = player_scene.instantiate() var player2: Player = player_scene.instantiate()
player2.color = Color(0, 0, 1, 1) player2.color = Color(0, 0, 1, 1)
player2.coloring_sprite_path = world_coloring_viewport.get_node("Player2Sprite").get_path() player2.coloring_sprite_path = world_coloring_viewport.get_node("Player2Sprite").get_path()
player2.coloring_bomb_sprite_path = world_coloring_viewport.get_node("Player2BombSprite").get_path() player2.coloring_bomb_sprite_path = world_coloring_viewport.get_node("Player2BombSprite").get_path()
player2.move_right_action += "_p2"
player2.move_left_action += "_p2"
player2.move_up_action += "_p2"
player2.move_down_action += "_p2"
player2.dash_action += "_p2"
player2.bomb_action += "_p2"
players_node.add_child(player1) players_node.add_child(player1)
players_node.add_child(player2) players_node.add_child(player2)
@ -173,6 +185,8 @@ func remove_players():
for player: Player in players_node.get_children(): for player: Player in players_node.get_children():
player.queue_free() player.queue_free()
players.clear()
func on_game_startup(): func on_game_startup():
print("Switching to startup") print("Switching to startup")

View File

@ -1,7 +1,6 @@
[gd_scene load_steps=13 format=3 uid="uid://b1nm5h3yccr16"] [gd_scene load_steps=12 format=3 uid="uid://b1nm5h3yccr16"]
[ext_resource type="Script" path="res://scenes/World.gd" id="1_gtcjp"] [ext_resource type="Script" path="res://scenes/World.gd" id="1_gtcjp"]
[ext_resource type="PackedScene" uid="uid://bfyjtfdko3l7o" path="res://entities/Player.tscn" id="2_a343a"]
[ext_resource type="Texture2D" uid="uid://bnsrnuuq28p4d" path="res://assets/textures/player_draw_mask.png" id="4_dipd5"] [ext_resource type="Texture2D" uid="uid://bnsrnuuq28p4d" path="res://assets/textures/player_draw_mask.png" id="4_dipd5"]
[ext_resource type="Texture2D" uid="uid://vcebfpqo2ko7" path="res://assets/textures/player_bomb_mask.png" id="5_17c1g"] [ext_resource type="Texture2D" uid="uid://vcebfpqo2ko7" path="res://assets/textures/player_bomb_mask.png" id="5_17c1g"]
[ext_resource type="PackedScene" path="res://scenes/PixelCountComputeShader.tscn" id="6_75vqy"] [ext_resource type="PackedScene" path="res://scenes/PixelCountComputeShader.tscn" id="6_75vqy"]
@ -33,24 +32,6 @@ autostart = true
[node name="PixelCountComputeShader" parent="." instance=ExtResource("6_75vqy")] [node name="PixelCountComputeShader" parent="." instance=ExtResource("6_75vqy")]
paint_viewport_path = NodePath("../WorldColoringViewport") paint_viewport_path = NodePath("../WorldColoringViewport")
[node name="Player1" parent="." instance=ExtResource("2_a343a")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.121184, 0)
color = Color(1, 0, 0, 1)
coloring_sprite_path = NodePath("../WorldColoringViewport/Player1Sprite")
coloring_bomb_sprite_path = NodePath("../WorldColoringViewport/Player1BombSprite")
[node name="Player2" parent="." instance=ExtResource("2_a343a")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, -0.121184, 0)
color = Color(0, 0, 1, 1)
move_right_action = "move_right_p2"
move_left_action = "move_left_p2"
move_down_action = "move_down_p2"
move_up_action = "move_up_p2"
dash_action = "dash_p2"
bomb_action = "bomb_p2"
coloring_sprite_path = NodePath("../WorldColoringViewport/Player2Sprite")
coloring_bomb_sprite_path = NodePath("../WorldColoringViewport/Player2BombSprite")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_f3jci") environment = SubResource("Environment_f3jci")
@ -137,4 +118,4 @@ player_index = 1
[node name="SpawnPointPlayer3" parent="Level" instance=ExtResource("8_ykvyf")] [node name="SpawnPointPlayer3" parent="Level" instance=ExtResource("8_ykvyf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.55561, 0, 3.26255) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.55561, 0, 3.26255)
[node name="Players" type="Node" parent="."] [node name="Players" type="Node3D" parent="."]