From 8238fabaa8f83d0f2c6539eaf5c48941ffb28003 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 28 Jan 2024 12:30:57 +0100 Subject: [PATCH] Player spawning refactoring complete --- .gitignore | 1 + entities/Player.gd | 2 +- entities/Player.tscn | 6 ------ scenes/World.gd | 14 ++++++++++++++ scenes/World.tscn | 23 ++--------------------- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 4709183..5dfd0d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Godot 4+ specific ignores .godot/ +assets/sounds/ diff --git a/entities/Player.gd b/entities/Player.gd index 8ffc4b9..57d37e7 100644 --- a/entities/Player.gd +++ b/entities/Player.gd @@ -7,7 +7,7 @@ class_name Player extends CharacterBody3D @export var move_down_action := "move_down" @export var move_up_action := "move_up" @export var dash_action := "dash" -@export var bomb_action := "bomp" +@export var bomb_action := "bomb" @export var coloring_sprite_path : NodePath @export var coloring_bomb_sprite_path : NodePath diff --git a/entities/Player.tscn b/entities/Player.tscn index 1e63fc4..3e9ab54 100644 --- a/entities/Player.tscn +++ b/entities/Player.tscn @@ -18,12 +18,6 @@ collision_layer = 5 collision_mask = 7 velocity = Vector3(0, -378.927, 0) 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="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.472656, 0) diff --git a/scenes/World.gd b/scenes/World.gd index 7a4a05e..1c95f71 100644 --- a/scenes/World.gd +++ b/scenes/World.gd @@ -145,10 +145,22 @@ func spawn_players(): player1.color = Color(1, 0, 0, 1) 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.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() player2.color = Color(0, 0, 1, 1) 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.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(player2) @@ -173,6 +185,8 @@ func remove_players(): for player: Player in players_node.get_children(): player.queue_free() + + players.clear() func on_game_startup(): print("Switching to startup") diff --git a/scenes/World.tscn b/scenes/World.tscn index d20f00f..f0c57a1 100644 --- a/scenes/World.tscn +++ b/scenes/World.tscn @@ -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="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://vcebfpqo2ko7" path="res://assets/textures/player_bomb_mask.png" id="5_17c1g"] [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")] 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="."] environment = SubResource("Environment_f3jci") @@ -137,4 +118,4 @@ player_index = 1 [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) -[node name="Players" type="Node" parent="."] +[node name="Players" type="Node3D" parent="."]