Compare commits

..

2 Commits

Author SHA1 Message Date
bog c3a678513f ADD: actors animated sprite. 2023-10-01 16:11:38 +02:00
bog f27c52e8ea ADD: improve a little bit the GUI. 2023-10-01 15:34:26 +02:00
23 changed files with 334 additions and 102 deletions

BIN
assets/player.ase Normal file

Binary file not shown.

BIN
assets/player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

View File

@ -9,8 +9,8 @@ func _ready():
pass
func _state_process(delta):
var sprite : Sprite2D = this.get_node('Sprite2D')
var ratio = 0.3
var sprite : AnimatedSprite2D = this.get_node('Sprite2D')
var ratio = 5
sprite.scale.x = max(0, sprite.scale.x - ratio * delta)
sprite.scale.y = max(0, sprite.scale.y - ratio * delta)

View File

@ -3,8 +3,10 @@ extends Node
var this = null
var state_name = 'Jump'
var m_ratio = 0.0
var m_ratio_start = 1.5
var m_ratio_end = 1.8
var m_jump_state = null
var m_speed = 0.7
var m_speed = 1.2
func _ready():
pass
@ -13,7 +15,7 @@ func _state_process(delta):
if m_jump_state != null:
m_jump_state.call(delta)
else:
m_ratio = 0.25
m_ratio = m_ratio_start
m_jump_state = self.go_up
func go_up(delta):
@ -22,7 +24,7 @@ func go_up(delta):
sprite.scale.x = m_ratio
sprite.scale.y = m_ratio
if m_ratio >= 0.38:
if m_ratio >= m_ratio_end:
m_jump_state = self.go_down
func go_down(delta):
@ -31,7 +33,7 @@ func go_down(delta):
sprite.scale.x = m_ratio
sprite.scale.y = m_ratio
if m_ratio <= 0.25:
if m_ratio <= m_ratio_start:
this.to_normal()
queue_free()

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://c0kqx6dsury58"]
[ext_resource type="Script" path="res://Actor/actor.gd" id="1_0612w"]
[ext_resource type="Texture2D" uid="uid://blr8qcmuqs5vl" path="res://icon.svg" id="2_itibm"]
[ext_resource type="SpriteFrames" uid="uid://o3tacari6pde" path="res://Actor/player.tres" id="2_1hnut"]
[sub_resource type="CircleShape2D" id="CircleShape2D_e2sef"]
radius = 3.16228
@ -9,9 +9,12 @@ radius = 3.16228
[node name="Actor" type="CharacterBody2D" groups=["actors"]]
script = ExtResource("1_0612w")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.25, 0.25)
texture = ExtResource("2_itibm")
[node name="Sprite2D" type="AnimatedSprite2D" parent="."]
scale = Vector2(1.5, 1.5)
sprite_frames = ExtResource("2_1hnut")
animation = &"Walk"
frame = 3
frame_progress = 0.69616
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_e2sef")

BIN
src/Actor/player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

51
src/Actor/player.tres Normal file
View File

@ -0,0 +1,51 @@
[gd_resource type="SpriteFrames" load_steps=7 format=3 uid="uid://o3tacari6pde"]
[ext_resource type="Texture2D" uid="uid://btxxm0joxgjtv" path="res://Actor/player.png" id="1_xo6xd"]
[sub_resource type="AtlasTexture" id="AtlasTexture_cvbhj"]
atlas = ExtResource("1_xo6xd")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_87gtp"]
atlas = ExtResource("1_xo6xd")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_xiss8"]
atlas = ExtResource("1_xo6xd")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_n3eh2"]
atlas = ExtResource("1_xo6xd")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_62teh"]
atlas = ExtResource("1_xo6xd")
region = Rect2(96, 0, 32, 32)
[resource]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_cvbhj")
}],
"loop": true,
"name": &"Idle",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_87gtp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xiss8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n3eh2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_62teh")
}],
"loop": true,
"name": &"Walk",
"speed": 10.0
}]

View File

@ -1,16 +1,11 @@
extends Area2D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func _on_body_entered(body):
if body in get_tree().get_nodes_in_group('player'):
CheckPoint.add_checkpoint(name, body.global_position, Music.m_current)

View File

@ -3,6 +3,7 @@ extends CanvasLayer
var m_freq = 2
var m_phase = 0.0
var m_alarm_on = false
var m_prev = 0
func _ready():
$ColorRect.visible = false
@ -14,7 +15,16 @@ func _process(delta):
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:
var thres = 0.80
var cam : Camera2D = get_tree().get_nodes_in_group('camera')[0]
if t >= thres and m_prev < thres:
Music.play_sfx('piew')
m_prev = t
var zoom = (1.0 - t) * 1.5 + t * 1.51
cam.zoom.x = zoom
cam.zoom.y = zoom
else:
$ColorRect.visible = false

View File

@ -35,12 +35,15 @@ func _on_area_2d_body_entered(_body):
CheckPoint.get_checkpoint().alarm = true
func _on_area_2d_more_body_entered(_body):
$Sandbox.strike_enabled = true
$Sandbox.m_strike_freq = 1.0
$Sandbox.m_strike_freq = 1
$CanvasTime.visible = true
$EndTimer.start()
if CheckPoint.has_checkpoint():
CheckPoint.get_checkpoint().strikes = true
CheckPoint.get_checkpoint().alarm = true
func _on_end_timer_timeout():
get_tree().change_scene_to_file("res://WinMenu/win_menu.tscn")

File diff suppressed because one or more lines are too long

View File

@ -15,3 +15,7 @@ func _on_button_pressed():
func _on_checkpoint_pressed():
get_tree().change_scene_to_file("res://Levels/level_intro.tscn")
func _on_quit_btn_pressed():
get_tree().quit()

View File

@ -20,29 +20,40 @@ grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_left = 473.0
offset_top = 54.0
offset_right = 551.0
offset_bottom = 77.0
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -130.0
offset_top = -147.0
offset_right = 136.0
offset_bottom = 160.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
text = "YOU LOSE"
[node name="Button" type="Button" parent="."]
layout_mode = 0
offset_left = 499.0
offset_top = 192.0
offset_right = 555.0
offset_bottom = 223.0
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
layout_mode = 2
[node name="Checkpoint" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "RETRY"
[node name="Checkpoint" type="Button" parent="."]
layout_mode = 0
offset_left = 468.0
offset_top = 131.0
offset_right = 598.0
offset_bottom = 162.0
text = "Last checkpoint"
[node name="Button" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "RESTART"
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
[connection signal="pressed" from="Checkpoint" to="." method="_on_checkpoint_pressed"]
[node name="QuitBtn" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "QUIT"
[connection signal="pressed" from="VBoxContainer/Checkpoint" to="." method="_on_checkpoint_pressed"]
[connection signal="pressed" from="VBoxContainer/Button" to="." method="_on_button_pressed"]
[connection signal="pressed" from="VBoxContainer/QuitBtn" to="." method="_on_quit_btn_pressed"]

View File

@ -8,6 +8,9 @@ func _ready():
func _process(_delta):
pass
func _on_button_pressed():
func _on_play_btn_pressed():
get_tree().change_scene_to_file("res://Levels/level_intro.tscn")
func _on_quit_btn_pressed():
get_tree().quit()

View File

@ -11,13 +11,45 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_ga0yx")
[node name="Button" type="Button" parent="."]
layout_mode = 0
offset_left = 518.0
offset_top = 184.0
offset_right = 565.0
offset_bottom = 215.0
text = "PLAY
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -109.0
offset_top = -75.0
offset_right = 108.0
offset_bottom = 129.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
text = "Ludum Dare 54"
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
layout_mode = 2
[node name="PlayBtn" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Play
"
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
[node name="QuitBtn" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Quit"
[connection signal="pressed" from="VBoxContainer/PlayBtn" to="." method="_on_play_btn_pressed"]
[connection signal="pressed" from="VBoxContainer/QuitBtn" to="." method="_on_quit_btn_pressed"]

View File

@ -1,8 +1,12 @@
[gd_scene load_steps=3 format=3 uid="uid://82kxvlr252x4"]
[gd_scene load_steps=4 format=3 uid="uid://82kxvlr252x4"]
[ext_resource type="Script" path="res://MsgBox/msg_box.gd" id="1_5d2k7"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_msojn"]
bg_color = Color(0.00784314, 0.458824, 0.396078, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rpitp"]
bg_color = Color(0, 0, 0, 1)
[node name="MsgBox" type="Control"]
process_mode = 3
@ -40,18 +44,25 @@ grow_vertical = 2
[node name="Label" type="Label" parent="Panel/VBoxContainer"]
layout_mode = 2
theme_override_styles/normal = SubResource("StyleBoxFlat_rpitp")
text = "TITRE"
horizontal_alignment = 1
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer"]
layout_mode = 2
theme_override_colors/default_color = Color(0, 0, 0, 1)
bbcode_enabled = true
text = "text"
fit_content = true
[node name="Button" type="Button" parent="Panel/VBoxContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
alignment = 2
[node name="Button" type="Button" parent="Panel/VBoxContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 8
text = "OK"
[connection signal="pressed" from="Panel/VBoxContainer/Button" to="." method="_on_button_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/VBoxContainer/Button" to="." method="_on_button_pressed"]

View File

@ -7,17 +7,16 @@ 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_sfx_players : Array = []
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:
@ -42,7 +41,7 @@ func next(music_name):
play(music_name)
func play(music_name):
m_player.volume_db = -7.0
m_player.volume_db = -10.0
m_current = music_name
var data = load("res://Music/" + music_name + ".ogg")
data.loop = true
@ -51,8 +50,15 @@ func play(music_name):
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
var player : AudioStreamPlayer = AudioStreamPlayer.new()
player.stream = load("res://Music/" + sfx_name + ".wav")
player.volume_db = -10
player.connect("finished", _sfx_end)
add_child(player)
m_sfx_players.push_back(player)
player.play()
func _sfx_end():
m_sfx_players = m_sfx_players.filter(func (x): return x.playing)

Binary file not shown.

View File

@ -4,9 +4,13 @@ var m_world = null
var m_shoot_time = 0.2
var m_shoot_timer = 0.0
func _process(_delta):
var to_mouse: Vector2 = get_global_mouse_position() - $Actor.global_position
var angle: float = to_mouse.angle() - PI/2.0
$Actor/Sprite2D.rotation = angle
func _physics_process(dt):
var delta = Vector2(0, 0)
if Input.is_action_just_pressed("player_jump") and $Actor.is_normal():
$Actor.to_jump()
@ -34,6 +38,9 @@ func _physics_process(dt):
if delta.length_squared() > 0:
delta = delta.normalized()
$Actor.m_dir = delta
$Actor/Sprite2D.play("Walk")
else:
$Actor/Sprite2D.play("Idle")
if $Actor.is_normal() or $Actor.is_jump():
$Actor.velocity = delta * $Actor.m_speed

View File

@ -8,5 +8,6 @@ script = ExtResource("1_2pfvx")
[node name="Actor" parent="." instance=ExtResource("2_s40rr")]
[node name="Camera2D" type="Camera2D" parent="Actor"]
[node name="Camera2D" type="Camera2D" parent="Actor" groups=["camera"]]
ignore_rotation = false
zoom = Vector2(1.5, 1.5)

View File

@ -48,6 +48,8 @@ func process(delta):
break
if ground:
Music.play_sfx('strike')
var cam = get_tree().get_nodes_in_group('camera')[0]
cam.rotation = randf_range(-PI/25.0, PI/25.0)
self.add_broken_ground(ground, 1, 0.8)
$Strikes.add_line(to_global($TileMap.map_to_local(ground)), 0.15)
m_strike_timer = 0.0

21
src/WinMenu/win_menu.gd Normal file
View File

@ -0,0 +1,21 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_main_menu_btn_pressed():
get_tree().change_scene_to_file("res://MainMenu/main_menu.tscn")
func _on_restart_btn_pressed():
get_tree().change_scene_to_file("res://Levels/level_intro.tscn")
func _on_quit_btn_pressed():
get_tree().quit()

59
src/WinMenu/win_menu.tscn Normal file
View File

@ -0,0 +1,59 @@
[gd_scene load_steps=2 format=3 uid="uid://bhkf4qcibdpkv"]
[ext_resource type="Script" path="res://WinMenu/win_menu.gd" id="1_litpr"]
[node name="WinMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_litpr")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -37.5
offset_top = -20.0
offset_right = 37.5
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
text = "VICTORY !"
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
layout_mode = 2
[node name="MainMenuBtn" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Back to main menu"
[node name="RestartBtn" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Restart"
[node name="QuitBtn" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Quit"
[connection signal="pressed" from="VBoxContainer/MainMenuBtn" to="." method="_on_main_menu_btn_pressed"]
[connection signal="pressed" from="VBoxContainer/RestartBtn" to="." method="_on_restart_btn_pressed"]
[connection signal="pressed" from="VBoxContainer/QuitBtn" to="." method="_on_quit_btn_pressed"]