Compare commits

..

2 Commits

Author SHA1 Message Date
bog 9e8fbafaa8 ADD: some sfx + alarm. 2023-10-01 10:33:55 +02:00
bog 728cd1b766 ADD: music integration. 2023-10-01 08:10:07 +02:00
22 changed files with 398 additions and 54 deletions

View File

@ -13,4 +13,4 @@ func _process(_delta):
func _on_body_entered(body): func _on_body_entered(body):
if body in get_tree().get_nodes_in_group('player'): if body in get_tree().get_nodes_in_group('player'):
CheckPoint.add_checkpoint(name, body.global_position) CheckPoint.add_checkpoint(name, body.global_position, Music.m_current)

View File

@ -4,31 +4,39 @@ class CheckPointData:
var checkpoint_name var checkpoint_name
var player_position var player_position
var strikes: bool = false var strikes: bool = false
var strikes_freq = 5.0
var alarm = false
var music = ''
func _init(myname, ppos): func _init(myname, ppos, mymusic):
checkpoint_name = myname checkpoint_name = myname
player_position = ppos player_position = ppos
music = mymusic
var m_checkpoints = [] var m_checkpoints = []
func _ready(): func _ready():
pass pass
func _process(delta): func _process(_delta):
pass pass
func reset(): func reset():
m_checkpoints.clear() m_checkpoints.clear()
func add_checkpoint(name, pos): func add_checkpoint(myname, pos, music):
for cp in m_checkpoints: for cp in m_checkpoints:
if cp.checkpoint_name == name: if cp.checkpoint_name == myname:
return return
var strikes = false var strikes = false
var alarm = false
if m_checkpoints.is_empty() == false: if m_checkpoints.is_empty() == false:
strikes = m_checkpoints.back().strikes strikes = m_checkpoints.back().strikes
m_checkpoints.push_back(CheckPointData.new(name, pos)) alarm = m_checkpoints.back().alarm
m_checkpoints.push_back(CheckPointData.new(myname, pos, music))
m_checkpoints.back().strikes = strikes m_checkpoints.back().strikes = strikes
m_checkpoints.back().alarm = alarm
func has_checkpoint(): func has_checkpoint():
return m_checkpoints.is_empty() == false return m_checkpoints.is_empty() == false

20
src/Levels/CanvasAlarm.gd Normal file
View File

@ -0,0 +1,20 @@
extends CanvasLayer
var m_freq = 2
var m_phase = 0.0
var m_alarm_on = false
func _ready():
$ColorRect.visible = false
func _process(delta):
if m_alarm_on:
$ColorRect.visible = true
var t = sin(2 * PI * m_phase)
m_phase += m_freq * delta
$ColorRect.color = Color(1.0, 0.2, 0.2, (1.0 - t) * 0.0 + t * 0.1)
if t >= 0.95:
Music.play_sfx('piew')
else:
$ColorRect.visible = false

View File

@ -6,24 +6,41 @@ func _ready():
var cp = CheckPoint.get_checkpoint() var cp = CheckPoint.get_checkpoint()
$Sandbox/Player/Actor.global_position = cp.player_position $Sandbox/Player/Actor.global_position = cp.player_position
$Sandbox.strike_enabled = cp.strikes $Sandbox.strike_enabled = cp.strikes
$Sandbox/CanvasAlarm.m_alarm_on = cp.alarm
var msg = preload("res://MsgBox/msg_box.tscn").instantiate() if cp.music != '':
$Sandbox/Canvas.add_child(msg) Music.play(cp.music)
msg.enable('Hello prisoner', ' else:
Hello prisoner, var msg = preload("res://MsgBox/msg_box.tscn").instantiate()
Our spaceship is under attack, but don\'t worry, $Sandbox/Canvas.add_child(msg)
you will be executed at time, as soon as we escape. msg.enable('Hello prisoner', '
Good luck ! Hello prisoner,
') Our spaceship is under attack, but don\'t worry,
you will be executed at time, as soon as we escape.
Good luck ! Muhahahahaha
')
func _start(): func _start():
pass pass
func _process(delta): func _process(_delta):
pass $CanvasTime/Label.text = str(round($EndTimer.time_left))
func _on_area_2d_body_entered(_body):
func _on_area_2d_body_entered(body):
$Sandbox.strike_enabled = true $Sandbox.strike_enabled = true
$Sandbox.m_strike_freq = 5.0
$Sandbox/CanvasAlarm.m_alarm_on = true
if CheckPoint.has_checkpoint(): if CheckPoint.has_checkpoint():
CheckPoint.get_checkpoint().strikes = true CheckPoint.get_checkpoint().strikes = true
CheckPoint.get_checkpoint().alarm = true
func _on_area_2d_more_body_entered(_body):
$Sandbox.strike_enabled = true
$Sandbox.m_strike_freq = 1.0
$CanvasTime.visible = true
$EndTimer.start()
if CheckPoint.has_checkpoint():
CheckPoint.get_checkpoint().strikes = true
CheckPoint.get_checkpoint().alarm = true

File diff suppressed because one or more lines are too long

View File

@ -1,13 +1,11 @@
extends Control extends Control
# Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass
# Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta):
func _process(delta):
pass pass
func _on_button_pressed(): func _on_button_pressed():

View File

@ -2,7 +2,7 @@ extends Control
func _ready(): func _ready():
pass # Replace with function body. Music.play('novox')
func _process(_delta): func _process(_delta):

View File

@ -8,7 +8,7 @@ var m_bodies = []
func _ready(): func _ready():
pass pass
func _process(delta): func _process(_delta):
pass pass
func _on_body_entered(body): func _on_body_entered(body):

View File

@ -15,7 +15,7 @@ var m_pages = []
func _ready(): func _ready():
pass pass
func _process(delta): func _process(_delta):
if Input.is_action_just_pressed("ui_accept"): if Input.is_action_just_pressed("ui_accept"):
self._on_button_pressed() self._on_button_pressed()

BIN
src/Music/explose.wav Normal file

Binary file not shown.

BIN
src/Music/fight_or_die.ogg Normal file

Binary file not shown.

58
src/Music/music.gd Normal file
View File

@ -0,0 +1,58 @@
extends Node
var m_music = null
var m_player : AudioStreamPlayer = null
var m_current = ''
var m_stop_timer = 0.0
var m_stop_time = 0.5
var m_stop = false
var m_next = null
var m_sfx_player : AudioStreamPlayer = null
var m_titles = [
'fight_or_die'
]
func _ready():
m_player = AudioStreamPlayer.new()
m_sfx_player = AudioStreamPlayer.new()
m_player.process_mode = Node.PROCESS_MODE_ALWAYS
add_child(m_player)
add_child(m_sfx_player)
func _process(delta):
if m_stop:
var t = m_stop_timer / m_stop_time
m_player.volume_db = t * -16.0
if m_stop_timer >= m_stop_time:
m_stop = false
m_stop_timer = 0.0
if m_next:
play(m_next)
m_stop_timer += delta
func next(music_name):
if m_player.playing and m_current == music_name:
return
if m_player.playing:
m_next = music_name
m_stop = true
else:
play(music_name)
func play(music_name):
m_player.volume_db = -7.0
m_current = music_name
var data = load("res://Music/" + music_name + ".ogg")
data.loop = true
m_player.stream = data
m_player.seek(0)
m_player.play()
func play_sfx(sfx_name):
m_sfx_player.stream = load("res://Music/" + sfx_name + ".wav")
m_sfx_player.play()
m_sfx_player.volume_db = 5

BIN
src/Music/novox.ogg Normal file

Binary file not shown.

BIN
src/Music/piew.wav Normal file

Binary file not shown.

BIN
src/Music/prepare.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
src/Music/strike.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,14 @@
extends Area2D
@export var music : String = Music.m_titles[0]
func _ready():
pass
func _process(_delta):
pass
func _on_body_entered(body):
if body in get_tree().get_nodes_in_group('player'):
Music.next(music)

View File

@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://dw7khu8cvs50n"]
[ext_resource type="Script" path="res://MusicArea/music_area.gd" id="1_60yhl"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c834i"]
size = Vector2(383, 20)
[node name="MusicArea" type="Area2D"]
script = ExtResource("1_60yhl")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_c834i")
debug_color = Color(0.627451, 0.823529, 0.270588, 0.419608)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -9,6 +9,7 @@ var m_death_time = 1.0
var m_strike_time = 1.0 var m_strike_time = 1.0
var m_strike_timer = 0.0 var m_strike_timer = 0.0
var m_strike_freq = 5.0
var m_strikes = [] var m_strikes = []
func _ready(): func _ready():
@ -46,10 +47,11 @@ func process(delta):
ground = t ground = t
break break
if ground: if ground:
Music.play_sfx('strike')
self.add_broken_ground(ground, 1, 0.8) self.add_broken_ground(ground, 1, 0.8)
$Strikes.add_line(to_global($TileMap.map_to_local(ground)), 0.15) $Strikes.add_line(to_global($TileMap.map_to_local(ground)), 0.15)
m_strike_timer = 0.0 m_strike_timer = 0.0
m_strike_time = randf() * 5.0 m_strike_time = randf() * m_strike_freq
m_strike_timer += delta m_strike_timer += delta
if m_broken_timer >= m_broken_time: if m_broken_timer >= m_broken_time:
@ -95,6 +97,7 @@ func throw_bomb(from: Vector2, dir: Vector2, dist: float):
add_child(bomb) add_child(bomb)
func _on_bomb_explode(bomb, _level): func _on_bomb_explode(bomb, _level):
Music.play_sfx("explose")
var tilemap: TileMap = $TileMap var tilemap: TileMap = $TileMap
var pos = tilemap.local_to_map(bomb.position) var pos = tilemap.local_to_map(bomb.position)

View File

@ -1,14 +1,14 @@
[preset.0] [preset.0]
name="Linux/X11" name="macOS"
platform="Linux/X11" platform="macOS"
runnable=true runnable=true
dedicated_server=false dedicated_server=false
custom_features="" custom_features=""
export_filter="all_resources" export_filter="all_resources"
include_filter="" include_filter=""
exclude_filter="" exclude_filter=""
export_path="../../Export/hello.x86_64" export_path="../../Export/aze/hello.zip"
encryption_include_filters="" encryption_include_filters=""
encryption_exclude_filters="" encryption_exclude_filters=""
encrypt_pck=false encrypt_pck=false
@ -16,24 +16,88 @@ encrypt_directory=false
[preset.0.options] [preset.0.options]
export/distribution_type=1
binary_format/architecture="universal"
custom_template/debug="" custom_template/debug=""
custom_template/release="" custom_template/release=""
debug/export_console_wrapper=1 debug/export_console_wrapper=1
binary_format/embed_pck=false application/icon=""
texture_format/bptc=true application/icon_interpolation=4
texture_format/s3tc=true application/bundle_identifier="bog.ld54s"
texture_format/etc=false application/signature=""
texture_format/etc2=false application/app_category="Games"
binary_format/architecture="x86_64" application/short_version="1.0"
application/version=""
application/copyright=""
application/copyright_localized={}
application/min_macos_version="10.12"
display/high_res=true
xcode/platform_build="14C18"
xcode/sdk_version="13.1"
xcode/sdk_build="22C55"
xcode/sdk_name="macosx13.1"
xcode/xcode_version="1420"
xcode/xcode_build="14C18"
codesign/codesign=1
codesign/installer_identity=""
codesign/apple_team_id=""
codesign/identity=""
codesign/entitlements/custom_file=""
codesign/entitlements/allow_jit_code_execution=false
codesign/entitlements/allow_unsigned_executable_memory=false
codesign/entitlements/allow_dyld_environment_variables=false
codesign/entitlements/disable_library_validation=false
codesign/entitlements/audio_input=false
codesign/entitlements/camera=false
codesign/entitlements/location=false
codesign/entitlements/address_book=false
codesign/entitlements/calendars=false
codesign/entitlements/photos_library=false
codesign/entitlements/apple_events=false
codesign/entitlements/debugging=false
codesign/entitlements/app_sandbox/enabled=false
codesign/entitlements/app_sandbox/network_server=false
codesign/entitlements/app_sandbox/network_client=false
codesign/entitlements/app_sandbox/device_usb=false
codesign/entitlements/app_sandbox/device_bluetooth=false
codesign/entitlements/app_sandbox/files_downloads=0
codesign/entitlements/app_sandbox/files_pictures=0
codesign/entitlements/app_sandbox/files_music=0
codesign/entitlements/app_sandbox/files_movies=0
codesign/entitlements/app_sandbox/files_user_selected=0
codesign/entitlements/app_sandbox/helper_executables=[]
codesign/custom_options=PackedStringArray()
notarization/notarization=0
privacy/microphone_usage_description=""
privacy/microphone_usage_description_localized={}
privacy/camera_usage_description=""
privacy/camera_usage_description_localized={}
privacy/location_usage_description=""
privacy/location_usage_description_localized={}
privacy/address_book_usage_description=""
privacy/address_book_usage_description_localized={}
privacy/calendar_usage_description=""
privacy/calendar_usage_description_localized={}
privacy/photos_library_usage_description=""
privacy/photos_library_usage_description_localized={}
privacy/desktop_folder_usage_description=""
privacy/desktop_folder_usage_description_localized={}
privacy/documents_folder_usage_description=""
privacy/documents_folder_usage_description_localized={}
privacy/downloads_folder_usage_description=""
privacy/downloads_folder_usage_description_localized={}
privacy/network_volumes_usage_description=""
privacy/network_volumes_usage_description_localized={}
privacy/removable_volumes_usage_description=""
privacy/removable_volumes_usage_description_localized={}
ssh_remote_deploy/enabled=false ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip" ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22" ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh="" ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp="" ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="#!/usr/bin/env bash ssh_remote_deploy/run_script="#!/usr/bin/env bash
export DISPLAY=:0
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
\"{temp_dir}/{exe_name}\" {cmd_args}" open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}"
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\")
rm -rf \"{temp_dir}\"" rm -rf \"{temp_dir}\""

View File

@ -18,6 +18,7 @@ config/icon="res://icon.svg"
[autoload] [autoload]
CheckPoint="*res://Checkpoint/CheckPoint.gd" CheckPoint="*res://Checkpoint/CheckPoint.gd"
Music="*res://Music/music.gd"
[input] [input]