diff --git a/godot/Main.tscn b/godot/Main.tscn
index de0bf8a..4257b35 100644
--- a/godot/Main.tscn
+++ b/godot/Main.tscn
@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Main.gdns" type="Script" id=1]
-[ext_resource path="res://levels/Prototype.tscn" type="PackedScene" id=2]
+[ext_resource path="res://levels/PrototypeR.tscn" type="PackedScene" id=2]
[ext_resource path="res://gui/GameOver.tscn" type="PackedScene" id=3]
[ext_resource path="res://gui/GameWon.tscn" type="PackedScene" id=4]
diff --git a/godot/assets/music/prototype_r.ogg b/godot/assets/music/prototype_r.ogg
new file mode 100644
index 0000000..a9c0020
--- /dev/null
+++ b/godot/assets/music/prototype_r.ogg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:212b33aef7ed3befca6912a1fcd86e7166a9bbbe55a3422a7d10bbf1afbf5020
+size 2189889
diff --git a/godot/assets/music/prototype_r.ogg.import b/godot/assets/music/prototype_r.ogg.import
new file mode 100644
index 0000000..4e378c2
--- /dev/null
+++ b/godot/assets/music/prototype_r.ogg.import
@@ -0,0 +1,15 @@
+[remap]
+
+importer="ogg_vorbis"
+type="AudioStreamOGGVorbis"
+path="res://.import/prototype_r.ogg-fe1f80b61f2acb1c2ae620457cf8aac9.oggstr"
+
+[deps]
+
+source_file="res://assets/music/prototype_r.ogg"
+dest_files=[ "res://.import/prototype_r.ogg-fe1f80b61f2acb1c2ae620457cf8aac9.oggstr" ]
+
+[params]
+
+loop=true
+loop_offset=0
diff --git a/godot/characters/enemies/WalkingEnemy.gd b/godot/characters/enemies/WalkingEnemy.gd
index 94a01b5..15707dc 100644
--- a/godot/characters/enemies/WalkingEnemy.gd
+++ b/godot/characters/enemies/WalkingEnemy.gd
@@ -1,9 +1,6 @@
extends KinematicBody2D
-signal player_touched
-
-
var velocity = Vector2()
export var direction = -1
export var detect_edges = true
@@ -32,7 +29,7 @@ func _physics_process(_delta: float) -> void:
for i in get_slide_count():
var collision = get_slide_collision(i)
if collision.collider.name == "Player":
- emit_signal("player_touched")
+ Event.emit_signal("player_touched", 3)
Event.emit_signal("object_updated", self.get_name(), "Walking", global_position, velocity)
diff --git a/godot/characters/enemies/blightwing/Blightwing.gd b/godot/characters/enemies/blightwing/Blightwing.gd
index 1446628..a41b7a1 100644
--- a/godot/characters/enemies/blightwing/Blightwing.gd
+++ b/godot/characters/enemies/blightwing/Blightwing.gd
@@ -1,9 +1,6 @@
extends KinematicBody2D
-signal player_touched
-
-
export var direction = -1
export var speed = 50
export var follow_path = false
@@ -82,7 +79,7 @@ func get_velocity_towards_target(delta: float) -> Vector2:
func wall_checker_collided(wall_checker: RayCast2D) -> void:
if wall_checker.get_collider().name == "Player":
- emit_signal("player_touched")
+ Event.emit_signal("player_touched", 3)
direction *= -1
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h
diff --git a/godot/characters/enemies/blockface/Blockface.gd b/godot/characters/enemies/blockface/Blockface.gd
index 3f52a5a..fab7b04 100644
--- a/godot/characters/enemies/blockface/Blockface.gd
+++ b/godot/characters/enemies/blockface/Blockface.gd
@@ -1,9 +1,6 @@
extends KinematicBody2D
-signal player_touched
-
-
onready var start_position = position
var velocity = Vector2()
export var speed = 50.0
@@ -25,7 +22,7 @@ func _physics_process(delta: float) -> void:
return_to_start = true
$AnimatedSprite.play("normal")
if collision.collider.name == "Player":
- emit_signal("player_touched")
+ Event.emit_signal("player_touched", 3)
Event.emit_signal("object_updated", self.get_name(), "Falling", global_position, velocity)
if position.y <= start_position.y:
diff --git a/godot/characters/player/Player.tscn b/godot/characters/player/Player.tscn
index bbd2fc2..5ac8d15 100644
--- a/godot/characters/player/Player.tscn
+++ b/godot/characters/player/Player.tscn
@@ -52,4 +52,4 @@ collision_mask = 24
[node name="Jump" type="AudioStreamPlayer" parent="Sounds"]
stream = ExtResource( 8 )
-volume_db = -45.0
+volume_db = -20.0
diff --git a/godot/collectables/coin/Coin.tscn b/godot/collectables/coin/Coin.tscn
index 6d52bb0..1c40bc1 100644
--- a/godot/collectables/coin/Coin.tscn
+++ b/godot/collectables/coin/Coin.tscn
@@ -1,9 +1,10 @@
-[gd_scene load_steps=10 format=2]
+[gd_scene load_steps=11 format=2]
[ext_resource path="res://assets/coin.png" type="Texture" id=1]
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=2]
[ext_resource path="res://collectables/coin/states/CoinNotCollected.gdns" type="Script" id=3]
[ext_resource path="res://collectables/coin/states/CoinCollected.gdns" type="Script" id=4]
+[ext_resource path="res://assets/sounds/coin.wav" type="AudioStream" id=5]
[sub_resource type="CircleShape2D" id=1]
radius = 6.0
@@ -67,5 +68,9 @@ script = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/jump = SubResource( 5 )
+[node name="CoinCollectedSound" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 5 )
+volume_db = -6.19
+
[connection signal="body_entered" from="." to="StateMachine/CoinNotCollected" method="_on_body_entered" flags=6]
[connection signal="animation_finished" from="AnimationPlayer" to="StateMachine/CoinCollected" method="_on_animation_finished" flags=6]
diff --git a/godot/gui/GameOver.tscn b/godot/gui/GameOver.tscn
index bff3216..56c19a8 100644
--- a/godot/gui/GameOver.tscn
+++ b/godot/gui/GameOver.tscn
@@ -1,8 +1,9 @@
-[gd_scene load_steps=7 format=2]
+[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/fonts/ttf/PixelOperator8.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://assets/fonts/ttf/PixelOperatorHB8.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://gui/GameOverScreen.gdns" type="Script" id=3]
+[ext_resource path="res://assets/sounds/died.wav" type="AudioStream" id=4]
[sub_resource type="DynamicFont" id=1]
size = 50
@@ -45,4 +46,9 @@ custom_fonts/font = SubResource( 2 )
custom_styles/hover = SubResource( 3 )
text = "REINICIAR"
+[node name="GameOverMusic" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 4 )
+volume_db = -23.524
+
+[connection signal="visibility_changed" from="." to="." method="_play_music"]
[connection signal="pressed" from="Control/RestartButton" to="." method="_on_restart_button_pressed"]
diff --git a/godot/levels/Prototype.tscn b/godot/levels/Prototype.tscn
index 2d3dce5..b585f63 100644
--- a/godot/levels/Prototype.tscn
+++ b/godot/levels/Prototype.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=9 format=2]
[ext_resource path="res://CameraLimit.gdns" type="Script" id=1]
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
@@ -6,6 +6,7 @@
[ext_resource path="res://assets/backgrounds/mountains.png" type="Texture" id=4]
[ext_resource path="res://collectables/coin/Coin.tscn" type="PackedScene" id=5]
[ext_resource path="res://hud/CoinHUD.tscn" type="PackedScene" id=6]
+[ext_resource path="res://assets/music/prototype_r.ogg" type="AudioStream" id=7]
[ext_resource path="res://goal/Goal.tscn" type="PackedScene" id=8]
[node name="Prototype" type="Node2D"]
@@ -55,3 +56,10 @@ position = Vector2( 72, 450 )
position = Vector2( 234, 450 )
[node name="Goal" parent="." instance=ExtResource( 8 )]
+
+[node name="BGM" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 7 )
+volume_db = -29.714
+autoplay = true
+
+[editable path="Coins/coin"]
diff --git a/godot/levels/PrototypeEnemies.tscn b/godot/levels/PrototypeEnemies.tscn
index d53033f..f521a70 100644
--- a/godot/levels/PrototypeEnemies.tscn
+++ b/godot/levels/PrototypeEnemies.tscn
@@ -89,10 +89,3 @@ position = Vector2( 247, 439 )
[node name="SuperShelly" parent="Enemies" instance=ExtResource( 7 )]
position = Vector2( 62, 546 )
-
-[connection signal="player_touched" from="Enemies/Blightwing" to="Player" method="_on_player_touched"]
-[connection signal="player_touched" from="Enemies/Blockface" to="Player" method="_on_player_touched"]
-[connection signal="player_touched" from="Enemies/Dreadtooth" to="Player" method="_on_player_touched"]
-[connection signal="player_touched" from="Enemies/Dreadtooth2" to="Player" method="_on_player_touched"]
-[connection signal="player_touched" from="Enemies/Shelly" to="Player" method="_on_player_touched"]
-[connection signal="player_touched" from="Enemies/SuperShelly" to="Player" method="_on_player_touched"]
diff --git a/godot/levels/PrototypeR.tmx b/godot/levels/PrototypeR.tmx
new file mode 100644
index 0000000..6280b25
--- /dev/null
+++ b/godot/levels/PrototypeR.tmx
@@ -0,0 +1,19 @@
+
+
diff --git a/godot/levels/PrototypeR.tmx.import b/godot/levels/PrototypeR.tmx.import
new file mode 100644
index 0000000..17122e4
--- /dev/null
+++ b/godot/levels/PrototypeR.tmx.import
@@ -0,0 +1,24 @@
+[remap]
+
+importer="vnen.tiled_importer"
+type="PackedScene"
+path="res://.import/PrototypeR.tmx-dfb7d18f520c5c44182a13443fe1b69c.scn"
+
+[deps]
+
+source_file="res://levels/PrototypeR.tmx"
+dest_files=[ "res://.import/PrototypeR.tmx-dfb7d18f520c5c44182a13443fe1b69c.scn" ]
+
+[params]
+
+custom_properties=true
+tile_metadata=false
+uv_clip=true
+y_sort=false
+image_flags=0
+collision_layer=2
+collision_mask=0
+embed_internal_images=false
+save_tiled_properties=false
+add_background=true
+post_import_script=""
diff --git a/godot/levels/PrototypeR.tscn b/godot/levels/PrototypeR.tscn
new file mode 100644
index 0000000..e6ac0ce
--- /dev/null
+++ b/godot/levels/PrototypeR.tscn
@@ -0,0 +1,154 @@
+[gd_scene load_steps=15 format=2]
+
+[ext_resource path="res://CameraLimit.gdns" type="Script" id=1]
+[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
+[ext_resource path="res://levels/PrototypeR.tmx" type="PackedScene" id=3]
+[ext_resource path="res://assets/backgrounds/hills.png" type="Texture" id=4]
+[ext_resource path="res://hud/CoinHUD.tscn" type="PackedScene" id=5]
+[ext_resource path="res://collectables/coin/Coin.tscn" type="PackedScene" id=6]
+[ext_resource path="res://assets/music/prototype_r.ogg" type="AudioStream" id=7]
+[ext_resource path="res://goal/Goal.tscn" type="PackedScene" id=8]
+[ext_resource path="res://characters/enemies/blockface/Blockface.tscn" type="PackedScene" id=9]
+[ext_resource path="res://characters/enemies/shelly/Shelly.tscn" type="PackedScene" id=10]
+[ext_resource path="res://characters/enemies/dreadtooth/Dreadtooth.tscn" type="PackedScene" id=11]
+[ext_resource path="res://characters/enemies/spikeball/Spikeball.tscn" type="PackedScene" id=12]
+[ext_resource path="res://characters/enemies/super_shelly/SuperShelly.tscn" type="PackedScene" id=13]
+[ext_resource path="res://characters/enemies/blightwing/Blightwing.tscn" type="PackedScene" id=14]
+
+[node name="PrototypeR" type="Node2D"]
+
+[node name="Player" parent="." instance=ExtResource( 2 )]
+position = Vector2( 36, 444 )
+collision_layer = 5
+
+[node name="Camera2D" type="Camera2D" parent="Player"]
+current = true
+limit_left = 0
+limit_top = 0
+limit_right = 512
+limit_bottom = 288
+drag_margin_h_enabled = true
+drag_margin_v_enabled = true
+__meta__ = {
+"_edit_bone_": true
+}
+
+[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="Player/Camera2D"]
+rect = Rect2( 0, 0, 24, 24 )
+
+[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
+
+[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"]
+motion_scale = Vector2( 0.2, 0.1 )
+motion_offset = Vector2( 0, -288 )
+motion_mirroring = Vector2( 528, 0 )
+
+[node name="Sprite" type="Sprite" parent="ParallaxBackground/ParallaxLayer"]
+texture = ExtResource( 4 )
+centered = false
+
+[node name="Map" type="Node2D" parent="."]
+
+[node name="PrototypeR" parent="Map" instance=ExtResource( 3 )]
+script = ExtResource( 1 )
+
+[node name="CoinHUD" parent="." instance=ExtResource( 5 )]
+
+[node name="Coins" type="Node" parent="."]
+
+[node name="Coin" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 270, 432 )
+
+[node name="Coin2" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 846, 252 )
+
+[node name="Coin3" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 1278, 342 )
+
+[node name="Coin4" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 1278, 180 )
+
+[node name="Coin9" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 1278, 108 )
+
+[node name="Coin10" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 1800, 378 )
+
+[node name="Coin11" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 1872, 378 )
+
+[node name="Coin12" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 1836, 315 )
+
+[node name="Coin5" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 522, 270 )
+
+[node name="Coin6" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 990, 324 )
+
+[node name="Coin13" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 1134, 414 )
+
+[node name="Coin7" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 468, 306 )
+
+[node name="Coin8" parent="Coins" instance=ExtResource( 6 )]
+position = Vector2( 576, 306 )
+
+[node name="BGM" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 7 )
+volume_db = -25.0
+autoplay = true
+
+[node name="Goal" parent="." instance=ExtResource( 8 )]
+position = Vector2( 2052, 396 )
+
+[node name="Enemies" type="Node" parent="."]
+
+[node name="Blockface" parent="Enemies" instance=ExtResource( 9 )]
+position = Vector2( 531, 228 )
+
+[node name="Blockface2" parent="Enemies" instance=ExtResource( 9 )]
+position = Vector2( 1287, 72 )
+
+[node name="Shelly" parent="Enemies" instance=ExtResource( 10 )]
+position = Vector2( 918, 258 )
+
+[node name="Shelly2" parent="Enemies" instance=ExtResource( 10 )]
+position = Vector2( 612, 360 )
+
+[node name="Dreadtooth" parent="Enemies" instance=ExtResource( 11 )]
+position = Vector2( 1337, 217 )
+
+[node name="Spikeball" parent="Enemies" instance=ExtResource( 12 )]
+position = Vector2( 1458, 336 )
+
+[node name="Spikeball2" parent="Enemies" instance=ExtResource( 12 )]
+position = Vector2( 1428, 348 )
+
+[node name="Spikeball3" parent="Enemies" instance=ExtResource( 12 )]
+position = Vector2( 1845, 366 )
+
+[node name="SuperShelly" parent="Enemies" instance=ExtResource( 13 )]
+position = Vector2( 1962, 432 )
+
+[node name="Blightwing" parent="Enemies" instance=ExtResource( 14 )]
+position = Vector2( 1206, 450 )
+follow_path = true
+
+[node name="Path" type="Node2D" parent="Enemies/Blightwing"]
+
+[node name="Node2D" type="Node2D" parent="Enemies/Blightwing/Path"]
+position = Vector2( -126, 0 )
+
+[node name="Blightwing2" parent="Enemies" instance=ExtResource( 14 )]
+position = Vector2( 1846, 324 )
+follow_path = true
+
+[node name="Path" type="Node2D" parent="Enemies/Blightwing2"]
+
+[node name="Node2D" type="Node2D" parent="Enemies/Blightwing2/Path"]
+position = Vector2( -36, 63 )
+
+[node name="Node2D2" type="Node2D" parent="Enemies/Blightwing2/Path"]
+position = Vector2( 36, 63 )
diff --git a/src/Event.cpp b/src/Event.cpp
index 8795d1e..9605468 100644
--- a/src/Event.cpp
+++ b/src/Event.cpp
@@ -11,6 +11,8 @@ void alai::Event::_register_methods()
godot::register_signal("coin_collected", "amount", GODOT_VARIANT_TYPE_INT);
godot::register_signal("player_died");
godot::register_signal("player_won");
+ godot::register_signal("player_touched", "damage", GODOT_VARIANT_TYPE_INT);
+
}
alai::Event::Event()
diff --git a/src/coin/CoinCollected.cpp b/src/coin/CoinCollected.cpp
index cc6155e..0e9921f 100644
--- a/src/coin/CoinCollected.cpp
+++ b/src/coin/CoinCollected.cpp
@@ -2,6 +2,7 @@
#include "Event.h"
+#include
#include
void alai::CoinCollected::_register_methods()
@@ -32,7 +33,8 @@ void alai::CoinCollected::_state_enter()
auto animation_player = Object::cast_to(node);
animation_player->play("jump");
}
-
+ auto coin_collected_sound = get_parent()->get_node("CoinCollectedSound");
+ coin_collected_sound->play();
}
void alai::CoinCollected::_state_exit()
diff --git a/src/gui/game_over/GameOverScreen.cpp b/src/gui/game_over/GameOverScreen.cpp
index 9627b2c..622a032 100644
--- a/src/gui/game_over/GameOverScreen.cpp
+++ b/src/gui/game_over/GameOverScreen.cpp
@@ -2,6 +2,7 @@
#include "Event.h"
+#include
#include
#include
#include
@@ -9,12 +10,13 @@
#include
void alai::GameOverScreen::_register_methods()
-{
+{
godot::register_method("_on_restart_button_pressed", &GameOverScreen::_on_restart_button_pressed);
godot::register_method("_ready", &GameOverScreen::_ready);
godot::register_method("restart_game", &GameOverScreen::restart_game);
godot::register_method("connect_signal", &GameOverScreen::connect_signal);
godot::register_method("_on_player_died", &GameOverScreen::_on_player_died);
+ godot::register_method("_play_music", &GameOverScreen::_play_music);
}
alai::GameOverScreen::GameOverScreen()
@@ -37,9 +39,9 @@ void alai::GameOverScreen::_ready()
void alai::GameOverScreen::_on_restart_button_pressed()
{
- if (_resource_loader->exists("res://levels/Prototype.tscn"))
+ if (_resource_loader->exists("res://levels/PrototypeR.tscn"))
{
- godot::Ref level_scene = _resource_loader->load("res://levels/Prototype.tscn");
+ godot::Ref level_scene = _resource_loader->load("res://levels/PrototypeR.tscn");
auto level = level_scene->instance();
auto level_node = get_tree()->get_root()->get_node("Main")->find_node("Level");
@@ -93,3 +95,7 @@ void alai::GameOverScreen::connect_signal()
auto event = get_node("/root/Event");
event->connect("player_died", this, "_on_player_died");
}
+
+void alai::GameOverScreen::_play_music()
+{
+}
diff --git a/src/gui/game_over/GameOverScreen.h b/src/gui/game_over/GameOverScreen.h
index d3315c6..3fb679c 100644
--- a/src/gui/game_over/GameOverScreen.h
+++ b/src/gui/game_over/GameOverScreen.h
@@ -5,6 +5,7 @@
#include
#include
+
namespace alai
{
/**
@@ -54,6 +55,7 @@ namespace alai
void _on_restart_button_pressed();
void restart_game();
void connect_signal();
+ void _play_music();
};
}
diff --git a/src/player/Player.cpp b/src/player/Player.cpp
index 9a128f9..43dce2e 100644
--- a/src/player/Player.cpp
+++ b/src/player/Player.cpp
@@ -60,6 +60,7 @@ void alai::player::Player::_ready()
{
auto event = get_node("/root/Event");
event->connect("level_loaded", this, "_on_level_loaded");
+ event->connect("player_touched", this, "_on_player_touched");
animated_sprite = get_node("AnimatedSprite");
if (!animated_sprite)
@@ -156,11 +157,11 @@ void alai::player::Player::_physics_process(float delta)
}
else if (collider->is_in_group("enemy") && (collider->is_in_group("rideable") && godot::Vector2::DOWN.dot(collision->get_normal()) > 0))
{
- _on_player_touched();
+ _on_player_touched(3);
}
else if (collider->is_in_group("enemy") && !collider->is_in_group("rideable"))
{
- _on_player_touched();
+ _on_player_touched(3);
}
}
@@ -301,7 +302,7 @@ godot::Vector2 alai::player::Player::get_velocity()
return this->velocity;
}
-void alai::player::Player::_on_player_touched()
+void alai::player::Player::_on_player_touched(uint8_t damage)
{
auto event = get_node("/root/Event");
event->emit_signal("player_died");
diff --git a/src/player/Player.h b/src/player/Player.h
index 578840a..9510e09 100644
--- a/src/player/Player.h
+++ b/src/player/Player.h
@@ -283,7 +283,7 @@ namespace alai
* @brief This function is called when an enemy touches the player.
*
*/
- void _on_player_touched();
+ void _on_player_touched(uint8_t damage);
/**
* @brief Called when the monitor is loaded to connect the player to it for tracking.