Added game music

main
Martin Felis 2024-01-28 12:58:17 +01:00
parent 8238fabaa8
commit c1993a50e9
8 changed files with 53 additions and 4 deletions

Binary file not shown.

View File

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://5da1smwywxdk"
path="res://.godot/imported/Run-Amok(chosic.com).mp3-4acd487c1e868789780d861bef0741e2.mp3str"
[deps]
source_file="res://assets/music/Run-Amok(chosic.com).mp3"
dest_files=["res://.godot/imported/Run-Amok(chosic.com).mp3-4acd487c1e868789780d861bef0741e2.mp3str"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

4
assets/music/sources.txt Normal file
View File

@ -0,0 +1,4 @@
Run-Amok(chosic.com).mp3
- license: CC BY 3.0
- source: https://www.chosic.com/download-audio/39324/
- artist: Run Amok by Kevin MacLeod | https://incompetech.com/

View File

@ -171,5 +171,5 @@ func on_drop_bomb():
explosion_stream_player.play() explosion_stream_player.play()
var bomb_emitter : BombEmitter = bomb_emitter_scene.instantiate() var bomb_emitter : BombEmitter = bomb_emitter_scene.instantiate()
bomb_emitter.global_position = global_position
get_parent_node_3d().add_child(bomb_emitter) get_parent_node_3d().add_child(bomb_emitter)
bomb_emitter.global_position = global_position

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://rd48gl8k5x34"] [gd_scene load_steps=8 format=3 uid="uid://rd48gl8k5x34"]
[ext_resource type="Theme" uid="uid://bb8mjy6l7umui" path="res://themes/GameUI.tres" id="2_eun58"] [ext_resource type="Theme" uid="uid://bb8mjy6l7umui" path="res://themes/GameUI.tres" id="2_eun58"]
[ext_resource type="PackedScene" uid="uid://b1nm5h3yccr16" path="res://scenes/World.tscn" id="2_voimb"] [ext_resource type="PackedScene" uid="uid://b1nm5h3yccr16" path="res://scenes/World.tscn" id="2_voimb"]
@ -9,6 +9,12 @@
[sub_resource type="ViewportTexture" id="ViewportTexture_2lmj8"] [sub_resource type="ViewportTexture" id="ViewportTexture_2lmj8"]
viewport_path = NodePath("Viewport") viewport_path = NodePath("Viewport")
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_y5ieh"]
bg_color = Color(1, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_obhii"]
bg_color = Color(0, 0, 1, 1)
[node name="Game" type="Node"] [node name="Game" type="Node"]
[node name="Viewport" type="SubViewport" parent="."] [node name="Viewport" type="SubViewport" parent="."]
@ -224,7 +230,6 @@ text = "0"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="GameRunningWidgets" type="Panel" parent="GameUI"] [node name="GameRunningWidgets" type="Panel" parent="GameUI"]
visible = false
custom_minimum_size = Vector2(0, 80) custom_minimum_size = Vector2(0, 80)
layout_mode = 1 layout_mode = 1
anchors_preset = 10 anchors_preset = 10
@ -240,16 +245,19 @@ alignment = 1
[node name="NameLabel" type="Label" parent="GameUI/GameRunningWidgets/Player1Widgets"] [node name="NameLabel" type="Label" parent="GameUI/GameRunningWidgets/Player1Widgets"]
layout_mode = 2 layout_mode = 2
theme_override_colors/font_color = Color(1, 0, 0, 1)
text = "Red" text = "Red"
[node name="ScoreLabel" type="Label" parent="GameUI/GameRunningWidgets/Player1Widgets"] [node name="ScoreLabel" type="Label" parent="GameUI/GameRunningWidgets/Player1Widgets"]
layout_mode = 2 layout_mode = 2
theme_override_colors/font_color = Color(1, 0, 0, 1)
text = "0 text = "0
" "
[node name="EnergyProgressBar" type="ProgressBar" parent="GameUI/GameRunningWidgets/Player1Widgets"] [node name="EnergyProgressBar" type="ProgressBar" parent="GameUI/GameRunningWidgets/Player1Widgets"]
custom_minimum_size = Vector2(400, 0) custom_minimum_size = Vector2(400, 0)
layout_mode = 2 layout_mode = 2
theme_override_styles/fill = SubResource("StyleBoxFlat_y5ieh")
value = 33.0 value = 33.0
[node name="Player2Widgets" type="VBoxContainer" parent="GameUI/GameRunningWidgets"] [node name="Player2Widgets" type="VBoxContainer" parent="GameUI/GameRunningWidgets"]
@ -262,16 +270,19 @@ alignment = 1
[node name="NameLabel" type="Label" parent="GameUI/GameRunningWidgets/Player2Widgets"] [node name="NameLabel" type="Label" parent="GameUI/GameRunningWidgets/Player2Widgets"]
layout_mode = 2 layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 1, 1)
text = "Blue" text = "Blue"
[node name="ScoreLabel" type="Label" parent="GameUI/GameRunningWidgets/Player2Widgets"] [node name="ScoreLabel" type="Label" parent="GameUI/GameRunningWidgets/Player2Widgets"]
layout_mode = 2 layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 1, 1)
text = "0 text = "0
" "
[node name="EnergyProgressBar" type="ProgressBar" parent="GameUI/GameRunningWidgets/Player2Widgets"] [node name="EnergyProgressBar" type="ProgressBar" parent="GameUI/GameRunningWidgets/Player2Widgets"]
custom_minimum_size = Vector2(400, 0) custom_minimum_size = Vector2(400, 0)
layout_mode = 2 layout_mode = 2
theme_override_styles/fill = SubResource("StyleBoxFlat_obhii")
value = 75.0 value = 75.0
[node name="TimeWidgets" type="VBoxContainer" parent="GameUI/GameRunningWidgets"] [node name="TimeWidgets" type="VBoxContainer" parent="GameUI/GameRunningWidgets"]

View File

@ -42,6 +42,10 @@ func _process(_delta):
var milliseconds = floor((world.time_left - floor(world.time_left)) * 10) var milliseconds = floor((world.time_left - floor(world.time_left)) * 10)
time_left_label.text = str(minutes) + ":" + str(seconds) + ":" + str(milliseconds) time_left_label.text = str(minutes) + ":" + str(seconds) + ":" + str(milliseconds)
player1_score_label.add_theme_color_override("font-color", world.players[0].color)
if player2_widgets.visible:
player2_score_label.add_theme_color_override("font-color", world.players[1].color)
elif world.game_state == World.GameState.Finished: elif world.game_state == World.GameState.Finished:
game_startup_widgets.visible = false game_startup_widgets.visible = false
game_running_widgets.visible = false game_running_widgets.visible = false

View File

@ -8,6 +8,7 @@ var players: Array
@onready var camera: Camera3D = $Camera3D @onready var camera: Camera3D = $Camera3D
@onready var level: Node3D = $Level @onready var level: Node3D = $Level
@onready var world_coloring_viewport: SubViewport = $WorldColoringViewport @onready var world_coloring_viewport: SubViewport = $WorldColoringViewport
@onready var music_stream_player: AudioStreamPlayer = $MusicAudioStreamPlayer
var player_scene = preload("res://entities/Player.tscn") var player_scene = preload("res://entities/Player.tscn")
@ -142,6 +143,7 @@ func spawn_players():
var players_node = $Players var players_node = $Players
var player1: Player = player_scene.instantiate() var player1: Player = player_scene.instantiate()
player1.name = "Red"
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()
@ -152,6 +154,7 @@ func spawn_players():
player1.dash_action += "_p1" player1.dash_action += "_p1"
player1.bomb_action += "_p1" player1.bomb_action += "_p1"
var player2: Player = player_scene.instantiate() var player2: Player = player_scene.instantiate()
player1.name = "Blue"
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()
@ -192,6 +195,8 @@ func on_game_startup():
print("Switching to startup") print("Switching to startup")
stop_gameplay() stop_gameplay()
music_stream_player.stop()
world_coloring_viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_ONCE world_coloring_viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_ONCE
world_coloring_viewport.render_target_update_mode = SubViewport.UPDATE_ONCE world_coloring_viewport.render_target_update_mode = SubViewport.UPDATE_ONCE
@ -199,6 +204,8 @@ func on_game_running():
print("Switching to gameplay") print("Switching to gameplay")
start_gameplay() start_gameplay()
music_stream_player.play()
world_coloring_viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_NEVER world_coloring_viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_NEVER
world_coloring_viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS world_coloring_viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=12 format=3 uid="uid://b1nm5h3yccr16"] [gd_scene load_steps=13 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="AudioStream" uid="uid://5da1smwywxdk" path="res://assets/music/Run-Amok(chosic.com).mp3" id="3_owwdt"]
[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"]
@ -32,6 +33,9 @@ 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="MusicAudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("3_owwdt")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_f3jci") environment = SubResource("Environment_f3jci")