Added sounds and refactoring player handling (WIP)
parent
d096da71a4
commit
c36edf7651
|
@ -0,0 +1,9 @@
|
|||
punch-1-166694.mp3
|
||||
- license:
|
||||
- source: https://pixabay.com/sound-effects/punch-1-166694/
|
||||
- author: floraphonic (https://pixabay.com/users/floraphonic-38928062/)
|
||||
|
||||
whoosh-6316.mp3
|
||||
- license:
|
||||
- source: https://pixabay.com/sound-effects/whoosh-6316/
|
||||
- author: Pixabay (https://pixabay.com/users/pixabay-1/)
|
Binary file not shown.
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://bhbhh78j5rkfe"
|
||||
path="res://.godot/imported/whoosh-6316.mp3-c09ddc29973a4f106e83f9f9f20b7c35.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sounds/pixabay/dash/whoosh-6316.mp3"
|
||||
dest_files=["res://.godot/imported/whoosh-6316.mp3-c09ddc29973a4f106e83f9f9f20b7c35.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
Binary file not shown.
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://qeg12ynvjvy0"
|
||||
path="res://.godot/imported/081895_impact_wav-43951.mp3-b97c4fdee4abc0cae63af4d92e0a6e8a.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sounds/pixabay/explosion/081895_impact_wav-43951.mp3"
|
||||
dest_files=["res://.godot/imported/081895_impact_wav-43951.mp3-b97c4fdee4abc0cae63af4d92e0a6e8a.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
|
@ -0,0 +1,4 @@
|
|||
081895_impact_wav-43951.mp3
|
||||
license:
|
||||
source: https://pixabay.com/sound-effects/081895-impact-wav-43951/
|
||||
author: Pixabay (https://pixabay.com/users/pixabay-1/)
|
Binary file not shown.
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://b33xjins3dqpp"
|
||||
path="res://.godot/imported/game-teleport-90735.mp3-112905f9f7cb1de6d452cc344a4b2de8.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sounds/pixabay/sfx/game-teleport-90735.mp3"
|
||||
dest_files=["res://.godot/imported/game-teleport-90735.mp3-112905f9f7cb1de6d452cc344a4b2de8.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
|
@ -13,7 +13,7 @@ func _ready():
|
|||
collision_area.connect("body_entered", on_body_enter)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
func _physics_process(_delta):
|
||||
if processed:
|
||||
queue_free()
|
||||
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dx6fxak21icvs"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://ck1gd38drird6"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/BombEmitter.gd" id="1_110pt"]
|
||||
[ext_resource type="Script" path="res://entities/BombEmitter.gd" id="1_nvjs2"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_7yhwp"]
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_yy20u"]
|
||||
height = 0.5
|
||||
radius = 3.0
|
||||
radius = 5.0
|
||||
|
||||
[node name="BombEmitter" type="Node3D"]
|
||||
script = ExtResource("1_110pt")
|
||||
script = ExtResource("1_nvjs2")
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||
shape = SubResource("CylinderShape3D_7yhwp")
|
||||
shape = SubResource("CylinderShape3D_yy20u")
|
||||
|
|
|
@ -14,6 +14,9 @@ class_name Player extends CharacterBody3D
|
|||
|
||||
@onready var geometry: MeshInstance3D = $Geometry
|
||||
@onready var collision: CollisionShape3D = $CollisionShape3D
|
||||
@onready var dash_stream_player: AudioStreamPlayer = $DashAudioStreamPlayer
|
||||
@onready var explosion_stream_player: AudioStreamPlayer = $ExplosionAudioStreamPlayer
|
||||
@onready var spawn_stream_player: AudioStreamPlayer = $SpawnAudioStreamPlayer
|
||||
|
||||
var bomb_emitter_scene = preload("res://entities/BombEmitter.tscn")
|
||||
|
||||
|
@ -143,6 +146,8 @@ func calc_coloring_position():
|
|||
|
||||
func on_player_spawn():
|
||||
print ("Player " + str(self) + ": spawning")
|
||||
spawn_stream_player.pitch_scale = 0.8 + randf () * 0.4
|
||||
spawn_stream_player.play()
|
||||
|
||||
func on_player_falling():
|
||||
print ("Player " + str(self) + ": falling")
|
||||
|
@ -154,12 +159,17 @@ func on_dash():
|
|||
is_dashing = true;
|
||||
dash_time = DASH_DURATION
|
||||
energy = max (0, energy - DASH_ENERGY)
|
||||
dash_stream_player.pitch_scale = 0.9 + randf () * 0.2
|
||||
dash_stream_player.play()
|
||||
|
||||
func on_drop_bomb():
|
||||
coloring_bomb_sprite.visible = true;
|
||||
bomb_time = BOMB_DURATION
|
||||
energy = max (0, energy - BOMB_ENERGY)
|
||||
|
||||
explosion_stream_player.pitch_scale = 0.6 + randf () * 0.2
|
||||
explosion_stream_player.play()
|
||||
|
||||
var bomb_emitter : BombEmitter = bomb_emitter_scene.instantiate()
|
||||
bomb_emitter.global_position = global_position
|
||||
get_parent_node_3d().add_child(bomb_emitter)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bfyjtfdko3l7o"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bfyjtfdko3l7o"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/Player.gd" id="1_w5gy0"]
|
||||
[ext_resource type="AudioStream" uid="uid://bhbhh78j5rkfe" path="res://assets/sounds/pixabay/dash/whoosh-6316.mp3" id="2_ykhbt"]
|
||||
[ext_resource type="AudioStream" uid="uid://qeg12ynvjvy0" path="res://assets/sounds/pixabay/explosion/081895_impact_wav-43951.mp3" id="3_mjsr0"]
|
||||
[ext_resource type="AudioStream" uid="uid://b33xjins3dqpp" path="res://assets/sounds/pixabay/sfx/game-teleport-90735.mp3" id="4_y7abk"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_yle83"]
|
||||
size = Vector3(0.24, 0.75, 0.24)
|
||||
|
@ -29,3 +32,14 @@ mesh = SubResource("BoxMesh_yle83")
|
|||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.496337, 0)
|
||||
shape = SubResource("CylinderShape3D_rwgp3")
|
||||
|
||||
[node name="DashAudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("2_ykhbt")
|
||||
|
||||
[node name="ExplosionAudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("3_mjsr0")
|
||||
volume_db = -15.707
|
||||
pitch_scale = 0.84
|
||||
|
||||
[node name="SpawnAudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("4_y7abk")
|
||||
|
|
|
@ -11,6 +11,11 @@ func _ready():
|
|||
area3d.connect("body_entered", on_player_enter)
|
||||
area3d.connect("body_exited", on_player_exited)
|
||||
|
||||
func _process(_delta):
|
||||
for player: Player in near_players:
|
||||
if player.state == Player.PlayerState.Dead:
|
||||
near_players.erase(player)
|
||||
|
||||
func on_player_enter(node: Node3D):
|
||||
var player: Player = node as Player
|
||||
if node == null:
|
||||
|
|
|
@ -126,7 +126,7 @@ move={
|
|||
3d_physics/layer_1="World"
|
||||
3d_physics/layer_2="Obstacles"
|
||||
3d_physics/layer_3="Player"
|
||||
3d_physics/layer_4="Collectibles"
|
||||
3d_physics/layer_4="Clutter"
|
||||
|
||||
[rendering]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class_name World extends Node3D
|
||||
|
||||
@export var players: Array
|
||||
var players: Array
|
||||
|
||||
@onready var score_update_timer: Timer = $ScoreUpdateTimer
|
||||
@onready var pixel_count_compute_shader: PixelCountComputeShader = $PixelCountComputeShader
|
||||
|
@ -9,6 +9,8 @@ class_name World extends Node3D
|
|||
@onready var level: Node3D = $Level
|
||||
@onready var world_coloring_viewport: SubViewport = $WorldColoringViewport
|
||||
|
||||
var player_scene = preload("res://entities/Player.tscn")
|
||||
|
||||
const GAME_DURATION_SECONDS = 20
|
||||
|
||||
var camera_position: Vector3;
|
||||
|
@ -28,30 +30,16 @@ var game_state_last : GameState = GameState.Finished
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
var player1: CharacterBody3D = $Player1
|
||||
var player2: CharacterBody3D = $Player2
|
||||
|
||||
players.append(player1)
|
||||
players.append(player2)
|
||||
|
||||
if players.size() == 1:
|
||||
world_coloring_material = load("res://materials/WorldColoringMaterialPass.tres")
|
||||
world_coloring_material.set_shader_parameter("world_color_texture", world_coloring_viewport.get_texture())
|
||||
else:
|
||||
world_coloring_material = load("res://materials/WorldColoringMaterialPassVersus.tres")
|
||||
world_coloring_material.set_shader_parameter("world_color_texture", world_coloring_viewport.get_texture())
|
||||
|
||||
camera_position = camera.global_position
|
||||
|
||||
score_update_timer.connect("timeout", update_score)
|
||||
|
||||
find_spawn_points(level)
|
||||
|
||||
for player: Player in players:
|
||||
player.state = player.PlayerState.Dead
|
||||
|
||||
|
||||
spawn_players()
|
||||
apply_world_coloring_recursive(level)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
if game_state_last != game_state:
|
||||
|
@ -112,7 +100,7 @@ func _physics_process(_delta):
|
|||
if not spawn_point.is_occupied():
|
||||
occupied = false
|
||||
|
||||
player.global_position = spawn_point.global_position
|
||||
player.global_position = spawn_point.global_position + Vector3.UP * 2
|
||||
player.state = Player.PlayerState.Alive
|
||||
spawn_point.near_players.append(player)
|
||||
|
||||
|
@ -150,6 +138,42 @@ func update_score():
|
|||
if players.size() > 1:
|
||||
players[1].score = pixel_count_compute_shader.blue_score
|
||||
|
||||
func spawn_players():
|
||||
var players_node = $Players
|
||||
|
||||
var player1: Player = player_scene.instantiate()
|
||||
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()
|
||||
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()
|
||||
|
||||
players_node.add_child(player1)
|
||||
players_node.add_child(player2)
|
||||
|
||||
players.clear()
|
||||
|
||||
players.append(player1)
|
||||
players.append(player2)
|
||||
|
||||
if players.size() == 1:
|
||||
world_coloring_material = load("res://materials/WorldColoringMaterialPass.tres")
|
||||
world_coloring_material.set_shader_parameter("world_color_texture", world_coloring_viewport.get_texture())
|
||||
else:
|
||||
world_coloring_material = load("res://materials/WorldColoringMaterialPassVersus.tres")
|
||||
world_coloring_material.set_shader_parameter("world_color_texture", world_coloring_viewport.get_texture())
|
||||
|
||||
for player: Player in players:
|
||||
player.state = player.PlayerState.Dead
|
||||
|
||||
func remove_players():
|
||||
var players_node = $Players
|
||||
|
||||
for player: Player in players_node.get_children():
|
||||
player.queue_free()
|
||||
|
||||
func on_game_startup():
|
||||
print("Switching to startup")
|
||||
stop_gameplay()
|
||||
|
|
|
@ -136,3 +136,5 @@ 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="."]
|
||||
|
|
Loading…
Reference in New Issue