develop #50
@ -82,6 +82,8 @@ elif env['platform'] == "windows":
|
||||
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
||||
env.Append(ENV=os.environ)
|
||||
|
||||
env.Append(CXXFLAGS=['-std=c++17'])
|
||||
|
||||
env.Append(LINKFLAGS=[
|
||||
'--static',
|
||||
'-Wl,--no-undefined',
|
||||
|
@ -1,12 +1,14 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[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://GUI/GameOver.tscn" type="PackedScene" id=3]
|
||||
[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]
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 1 )
|
||||
game_version = "1.0.0"
|
||||
level = ExtResource( 2 )
|
||||
|
||||
[node name="Level" type="Node" parent="."]
|
||||
@ -14,3 +16,6 @@ pause_mode = 1
|
||||
|
||||
[node name="GameOver" parent="." instance=ExtResource( 3 )]
|
||||
visible = false
|
||||
|
||||
[node name="GameWon" parent="." instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
|
BIN
godot/assets/music/prototype_r.ogg
(Stored with Git LFS)
Normal file
BIN
godot/assets/music/prototype_r.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
15
godot/assets/music/prototype_r.ogg.import
Normal file
15
godot/assets/music/prototype_r.ogg.import
Normal file
@ -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
|
BIN
godot/assets/sounds/victory.wav
(Stored with Git LFS)
Normal file
BIN
godot/assets/sounds/victory.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
23
godot/assets/sounds/victory.wav.import
Normal file
23
godot/assets/sounds/victory.wav.import
Normal file
@ -0,0 +1,23 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamSample"
|
||||
path="res://.import/victory.wav-652e970b8418d2fc380cb882ddb39b3d.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sounds/victory.wav"
|
||||
dest_files=[ "res://.import/victory.wav-652e970b8418d2fc380cb882ddb39b3d.sample" ]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
@ -1,9 +1,6 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
|
||||
signal player_touched
|
||||
|
||||
|
||||
var velocity = Vector2()
|
||||
export var direction = -1
|
||||
export var detect_edges = true
|
||||
@ -16,6 +13,7 @@ func _ready() -> void:
|
||||
$AnimatedSprite.flip_h = true
|
||||
$FloorChecker.position.x = $CollisionShape2D.shape.get_extents().x * direction
|
||||
$FloorChecker.enabled = detect_edges
|
||||
Event.connect("level_loaded", self, "_on_level_loaded")
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
@ -31,8 +29,15 @@ 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)
|
||||
|
||||
|
||||
func squash() -> void:
|
||||
Event.emit_signal("object_removed", self.get_name())
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_level_loaded() -> void:
|
||||
Event.emit_signal("object_created", self.get_name(), "Walking", global_position, Vector2(0, 0))
|
||||
|
@ -1,9 +1,6 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
|
||||
signal player_touched
|
||||
|
||||
|
||||
export var direction = -1
|
||||
export var speed = 50
|
||||
export var follow_path = false
|
||||
@ -22,6 +19,8 @@ func _ready() -> void:
|
||||
if direction == 1:
|
||||
$AnimatedSprite.flip_h = true
|
||||
|
||||
Event.connect("level_loaded", self, "_on_level_loaded")
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if $LeftWallChecker.is_colliding():
|
||||
@ -29,17 +28,18 @@ func _physics_process(delta: float) -> void:
|
||||
elif $RightWallChecker.is_colliding():
|
||||
wall_checker_collided($RightWallChecker)
|
||||
|
||||
var velocity: Vector2 = Vector2(0, 0)
|
||||
if not follow_path:
|
||||
var target_position = position
|
||||
target_position.x *= 2 * direction
|
||||
position = position.move_toward(target_position, round(speed * delta))
|
||||
|
||||
var velocity = get_velocity_towards_target(delta)
|
||||
velocity = get_velocity_towards_target(delta)
|
||||
var collision = move_and_collide(velocity, true, true, true)
|
||||
if collision and collision.collider.name != "Player":
|
||||
var _collision = move_and_collide(velocity)
|
||||
else:
|
||||
var velocity = get_velocity_towards_target(delta)
|
||||
velocity = get_velocity_towards_target(delta)
|
||||
|
||||
var collision = move_and_collide(velocity, true, true, true)
|
||||
if collision and collision.collider.name != "Player":
|
||||
@ -60,6 +60,8 @@ func _physics_process(delta: float) -> void:
|
||||
elif start_position.x + target.x < position.x:
|
||||
$AnimatedSprite.flip_h = false
|
||||
|
||||
Event.emit_signal("object_updated", self.get_name(), "Flying", global_position, velocity)
|
||||
|
||||
|
||||
func get_velocity_towards_target(delta: float) -> Vector2:
|
||||
var velocity = Vector2(0, 0)
|
||||
@ -77,6 +79,10 @@ 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
|
||||
|
||||
|
||||
func _on_level_loaded() -> void:
|
||||
Event.emit_signal("object_created", self.get_name(), "Flying", global_position, Vector2(0, 0))
|
||||
|
@ -1,9 +1,6 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
|
||||
signal player_touched
|
||||
|
||||
|
||||
onready var start_position = position
|
||||
var velocity = Vector2()
|
||||
export var speed = 50.0
|
||||
@ -11,17 +8,27 @@ export var fall_speed = 75.0
|
||||
var return_to_start: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Event.connect("level_loaded", self, "_on_level_loaded")
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if return_to_start:
|
||||
position = position.move_toward(start_position, speed * delta)
|
||||
Event.emit_signal("object_updated", self.get_name(), "Rising", global_position, velocity)
|
||||
else:
|
||||
var collision = move_and_collide(Vector2(0, (position.y + fall_speed) * delta))
|
||||
if collision:
|
||||
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:
|
||||
return_to_start = false
|
||||
$AnimatedSprite.play("angry")
|
||||
|
||||
|
||||
func _on_level_loaded() -> void:
|
||||
Event.emit_signal("object_created", self.get_name(), "Falling", global_position, Vector2(0, 0))
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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/botonreiniciar.gdns" type="Script" id=3]
|
||||
[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 = -25.0
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="pressed" from="Control/RestartButton" to="." method="_on_restart_button_pressed"]
|
54
godot/gui/GameWon.tscn
Normal file
54
godot/gui/GameWon.tscn
Normal file
@ -0,0 +1,54 @@
|
||||
[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/GameWonScreen.gdns" type="Script" id=3]
|
||||
[ext_resource path="res://assets/sounds/victory.wav" type="AudioStream" id=4]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 50
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
font_data = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.0705882, 0.917647, 0, 1 )
|
||||
|
||||
[node name="GameWon" type="CanvasLayer"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Control"]
|
||||
margin_right = 512.0
|
||||
margin_bottom = 288.0
|
||||
rect_min_size = Vector2( 512, 288 )
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="Label" type="Label" parent="Control"]
|
||||
margin_left = 66.0
|
||||
margin_top = 17.0
|
||||
margin_right = 456.0
|
||||
margin_bottom = 71.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "GANASTE!"
|
||||
align = 1
|
||||
|
||||
[node name="QuitButton" type="Button" parent="Control"]
|
||||
margin_left = 194.0
|
||||
margin_top = 150.0
|
||||
margin_right = 338.0
|
||||
margin_bottom = 180.0
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
custom_styles/hover = SubResource( 3 )
|
||||
text = "SALIR"
|
||||
|
||||
[node name="VictorySound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 4 )
|
||||
volume_db = -18.0
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="pressed" from="Control/QuitButton" to="." method="_on_quit_button_pressed"]
|
8
godot/gui/GameWonScreen.gdns
Normal file
8
godot/gui/GameWonScreen.gdns
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
|
||||
|
||||
[resource]
|
||||
resource_name = "GameWonScreen"
|
||||
class_name = "GameWonScreen"
|
||||
library = ExtResource( 1 )
|
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://assets/coin.png" type="Texture" id=1]
|
||||
[ext_resource path="res://hud/coin/Counter.gdns" type="Script" id=2]
|
||||
[ext_resource path="res://hud/coin/CoinCounter.gdns" type="Script" id=2]
|
||||
[ext_resource path="res://hud/CoinHUD.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
@ -28,31 +28,34 @@ pause_mode = 2
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
margin_left = 144.0
|
||||
margin_top = 18.0
|
||||
margin_right = 288.0
|
||||
margin_bottom = 54.0
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -44.5
|
||||
margin_top = 5.0
|
||||
margin_right = 44.5
|
||||
margin_bottom = 25.0
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
margin_left = 180.0
|
||||
margin_top = 18.0
|
||||
margin_right = 220.0
|
||||
margin_bottom = 36.0
|
||||
[node name="X" type="Label" parent="Panel"]
|
||||
margin_left = 40.0
|
||||
margin_top = 4.0
|
||||
margin_right = 53.0
|
||||
margin_bottom = 24.0
|
||||
text = "X"
|
||||
|
||||
[node name="Coins" type="Label" parent="."]
|
||||
margin_left = 198.0
|
||||
margin_top = 18.0
|
||||
margin_right = 238.0
|
||||
margin_bottom = 32.0
|
||||
[node name="Coins" type="Label" parent="Panel"]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = 13.5
|
||||
margin_top = 4.0
|
||||
margin_right = 36.0
|
||||
margin_bottom = 18.0
|
||||
text = "##"
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( 162, 18 )
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="Panel"]
|
||||
position = Vector2( 12, 1 )
|
||||
frames = SubResource( 4 )
|
||||
animation = "spin"
|
||||
frame = 1
|
||||
playing = true
|
||||
centered = false
|
||||
|
@ -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"]
|
||||
@ -56,4 +57,9 @@ 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"]
|
||||
|
@ -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"]
|
||||
|
19
godot/levels/PrototypeR.tmx
Normal file
19
godot/levels/PrototypeR.tmx
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="120" height="32" tilewidth="18" tileheight="18" infinite="0" nextlayerid="4" nextobjectid="1">
|
||||
<tileset firstgid="1" source="../tilesets/tiles.tsx"/>
|
||||
<layer id="3" name="Background" width="120" height="32">
|
||||
<data encoding="base64" compression="zstd">
|
||||
KLUv/WAAO+UJAKKFEBmgKa0BQ/z5f96XBipzAacygijAnyB3inwKFSvNi9glMAjxxA9XlsgtTIpZPMt4Y5dngxsSKwGqJ/AAXtOPtCPdGGCgMLGl7aACk0ACwdEBxfEUiOZVzal6o7kqyNAeN3fIyH7S5qp2c6UrxlMzmjiIKgDhsHQId31OUO2QhjGOn1jH74PYuHOc8tYy/qlHqaNzDnLc/nFdEc9bdesdom5Z3PEgeGCq2jtS46axwFMfv3dxfKgNZ5HU/e4tjqcWSd0k/yrTDSmpq+CqHl/d0aVt0urewnTzsUiyVcsyprra58l1+g7NC/UOqt5CzniZswtOyWRvAHxDn0csowOGV42bUrLGiSrDqDOLOIxxbSotgVq8/NT2n/z80u/Jz1KVb98VKDofNZOm5Ndvltmp+0cuUIUgKiT5TQw=
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="1" name="Middleground" width="120" height="32">
|
||||
<data encoding="base64" compression="zstd">
|
||||
KLUv/WAAO50FAMQCADEAAAAyMwACAAAAAwQAGwACFgAAABcYABt6AAAAe3wAGxeGXwB7iACGXogxoCCzdWCCFIgEYmQHpY//V412Vf4gGemWL/1AEQoZHqr8I5IHRLoFS671y2WYzYBxqqNa2qcCCqf7uoRE1YZxqzJNOVxJqesG5R7dJVCGcRyg1GVAvQU6Pu6UVhrTRgcqSPFJzkzZ78bTSSezM7YmircT9lep4Hgo+u2SHKWql8yW9EEH
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Foreground" width="120" height="32">
|
||||
<data encoding="base64" compression="zstd">
|
||||
KLUv/WAAO70CAKgAdAB0AIiINzeIN0YjWjcjNyNuNwAaoJD2AWBDhVoO4YKf+iiKEtrHJVQSqc4GzhDlVlFe0Tb1bDJ629TRhBsftwpQtCpKtEu19HH9uSSqrEzywUAhHQ==
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
24
godot/levels/PrototypeR.tmx.import
Normal file
24
godot/levels/PrototypeR.tmx.import
Normal file
@ -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=""
|
154
godot/levels/PrototypeR.tscn
Normal file
154
godot/levels/PrototypeR.tscn
Normal file
@ -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 )
|
@ -1,10 +1,8 @@
|
||||
extends Node
|
||||
|
||||
|
||||
signal monitor_loaded()
|
||||
|
||||
|
||||
export var monitor_enabled: bool = false
|
||||
export var debug: bool = false
|
||||
export var development_url: String = "http://localhost:4050/api/v1"
|
||||
var url_real: String = "https://alai.cromer.cl/api/v1"
|
||||
export var use_development_url: bool = false
|
||||
@ -53,7 +51,11 @@ func _ready() -> void:
|
||||
Event.connect("object_created", self, "_object_created")
|
||||
Event.connect("object_updated", self, "_object_updated")
|
||||
Event.connect("object_removed", self, "_object_removed")
|
||||
Event.connect("game_started", self, "_on_game_started")
|
||||
Event.connect("player_died", self, "_on_game_over")
|
||||
Event.connect("player_won", self, "_on_game_won")
|
||||
Event.connect("coin_collected", self, "_on_coin_update")
|
||||
|
||||
game_version = get_parent().game_version
|
||||
|
||||
player["rut"] = ""
|
||||
@ -108,7 +110,7 @@ func _physics_process(_delta: float) -> void:
|
||||
if monitor_enabled:
|
||||
if has_node("MonitorGUI") and not $MonitorGUI.visible:
|
||||
$MonitorGUI.visible = true
|
||||
emit_signal("monitor_loaded")
|
||||
Event.emit_signal("monitor_loaded")
|
||||
|
||||
if started and not get_tree().paused:
|
||||
var frame = empty_frame.duplicate(true)
|
||||
@ -130,13 +132,14 @@ func _physics_process(_delta: float) -> void:
|
||||
start_monitor()
|
||||
else:
|
||||
get_tree().paused = false
|
||||
emit_signal("monitor_loaded")
|
||||
Event.emit_signal("monitor_loaded")
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_input_validated(validated_player: Dictionary) -> void:
|
||||
$MonitorGUI.queue_free()
|
||||
get_tree().paused = false
|
||||
Event.emit_signal("game_started")
|
||||
player = validated_player.duplicate(true)
|
||||
game["player"] = player
|
||||
|
||||
@ -188,6 +191,7 @@ func remove_object(name: String) -> void:
|
||||
for i in range(0, objects.size()):
|
||||
if objects[i]["name"] == name:
|
||||
objects.remove(i)
|
||||
return
|
||||
|
||||
|
||||
func _on_coin_update(amount: int) -> void:
|
||||
@ -219,7 +223,16 @@ func send_data() -> void:
|
||||
print("Body B: " + String(body.length()))
|
||||
print("Body MB: " + String(body.length() / pow(2, 20)))
|
||||
|
||||
$HTTPRequest.request(url + "/game", headers, false, HTTPClient.METHOD_POST, body)
|
||||
if not debug:
|
||||
$HTTPRequest.request(url + "/game", headers, false, HTTPClient.METHOD_POST, body)
|
||||
else:
|
||||
var file = File.new()
|
||||
if file.open("user://game.json", File.WRITE) != 0:
|
||||
print_debug("Could not open game.json for writing!")
|
||||
return
|
||||
|
||||
file.store_string(json)
|
||||
file.close()
|
||||
|
||||
|
||||
func compress_payload(payload: String) -> String:
|
||||
@ -231,3 +244,21 @@ func compress_payload(payload: String) -> String:
|
||||
return new_payload
|
||||
|
||||
|
||||
func _on_game_started() -> void:
|
||||
print_debug("started game")
|
||||
if not started:
|
||||
start_monitor()
|
||||
|
||||
|
||||
func _on_game_over() -> void:
|
||||
if started:
|
||||
stop_monitor()
|
||||
game["won"] = false
|
||||
send_data()
|
||||
|
||||
|
||||
func _on_game_won() -> void:
|
||||
if started:
|
||||
stop_monitor()
|
||||
game["won"] = true
|
||||
send_data()
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
void alai::CameraLimit::_register_methods()
|
||||
{
|
||||
register_method("_ready", &CameraLimit::_ready);
|
||||
godot::register_method("_ready", &CameraLimit::_ready);
|
||||
}
|
||||
|
||||
alai::CameraLimit::CameraLimit()
|
||||
|
@ -2,11 +2,16 @@
|
||||
|
||||
void alai::Event::_register_methods()
|
||||
{
|
||||
godot::register_signal<Event>("game_started");
|
||||
godot::register_signal<Event>("monitor_loaded");
|
||||
godot::register_signal<Event>("level_loaded");
|
||||
godot::register_signal<Event>("object_created", "name", GODOT_VARIANT_TYPE_STRING, "state", GODOT_VARIANT_TYPE_STRING, "position", GODOT_VARIANT_TYPE_VECTOR2, "velocity", GODOT_VARIANT_TYPE_VECTOR2);
|
||||
godot::register_signal<Event>("object_updated", "name", GODOT_VARIANT_TYPE_STRING, "state", GODOT_VARIANT_TYPE_STRING, "position", GODOT_VARIANT_TYPE_VECTOR2, "velocity", GODOT_VARIANT_TYPE_VECTOR2);
|
||||
godot::register_signal<Event>("object_removed", "name", GODOT_VARIANT_TYPE_STRING);
|
||||
godot::register_signal<Event>("coin_collected", "amount", GODOT_VARIANT_TYPE_INT);
|
||||
godot::register_signal<Event>("player_died");
|
||||
godot::register_signal<Event>("player_won");
|
||||
godot::register_signal<Event>("player_touched", "damage", GODOT_VARIANT_TYPE_INT);
|
||||
|
||||
}
|
||||
|
||||
|
19
src/Main.cpp
19
src/Main.cpp
@ -1,5 +1,7 @@
|
||||
#include "Main.h"
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
#include <SceneTree.hpp>
|
||||
|
||||
void alai::Main::_register_methods()
|
||||
@ -86,24 +88,21 @@ void alai::Main::_ready()
|
||||
|
||||
void alai::Main::_on_monitor_loaded()
|
||||
{
|
||||
if (level != nullptr)
|
||||
{
|
||||
auto level_node = load_level();
|
||||
connect("monitor_loaded", level_node->get_child(0)->find_node("Player", true, false), "_on_monitor_loaded");
|
||||
emit_signal("monitor_loaded");
|
||||
}
|
||||
load_level();
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->emit_signal("level_loaded");
|
||||
}
|
||||
|
||||
void alai::Main::load_monitor()
|
||||
{
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->connect("monitor_loaded", this, "_on_monitor_loaded");
|
||||
godot::Ref<godot::PackedScene> monitor_scene = _resource_loader->load("res://monitor/Monitor.tscn");
|
||||
add_child(monitor_scene->instance());
|
||||
auto monitor = get_node("Monitor");
|
||||
monitor->connect("monitor_loaded", this, "_on_monitor_loaded");
|
||||
get_tree()->set_pause(true);
|
||||
}
|
||||
|
||||
godot::Node *alai::Main::load_level()
|
||||
void alai::Main::load_level()
|
||||
{
|
||||
if (level != nullptr)
|
||||
{
|
||||
@ -111,9 +110,7 @@ godot::Node *alai::Main::load_level()
|
||||
auto loaded_level = level->instance();
|
||||
auto level_node = get_node("Level");
|
||||
level_node->add_child(loaded_level);
|
||||
return level_node;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void alai::Main::_physics_process(float delta)
|
||||
|
@ -224,9 +224,8 @@ namespace alai
|
||||
/**
|
||||
* @brief Loads the selected level.
|
||||
*
|
||||
* @return Node* The level node which we will later add the monitor to.
|
||||
*/
|
||||
Node *load_level();
|
||||
void load_level();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
#include <AudioStreamPlayer.hpp>
|
||||
#include <AnimationPlayer.hpp>
|
||||
|
||||
void alai::CoinCollected::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &CoinCollected::_state_enter);
|
||||
register_method("_state_exit", &CoinCollected::_state_exit);
|
||||
register_method("_on_animation_finished", &CoinCollected::_on_animation_finished);
|
||||
godot::register_method("_state_enter", &CoinCollected::_state_enter);
|
||||
godot::register_method("_state_exit", &CoinCollected::_state_exit);
|
||||
godot::register_method("_on_animation_finished", &CoinCollected::_on_animation_finished);
|
||||
}
|
||||
|
||||
alai::CoinCollected::CoinCollected()
|
||||
@ -32,12 +33,12 @@ void alai::CoinCollected::_state_enter()
|
||||
auto animation_player = Object::cast_to<godot::AnimationPlayer>(node);
|
||||
animation_player->play("jump");
|
||||
}
|
||||
|
||||
auto coin_collected_sound = get_parent()->get_node<godot::AudioStreamPlayer>("CoinCollectedSound");
|
||||
coin_collected_sound->play();
|
||||
}
|
||||
|
||||
void alai::CoinCollected::_state_exit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void alai::CoinCollected::_on_animation_finished(godot::String anim_name)
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
void alai::CoinCounter::_register_methods()
|
||||
{
|
||||
register_method("_on_coin_collected", &CoinCounter::_on_coin_collected);
|
||||
register_method("_ready", &CoinCounter::_ready);
|
||||
godot::register_method("_on_coin_collected", &CoinCounter::_on_coin_collected);
|
||||
godot::register_method("_ready", &CoinCounter::_ready);
|
||||
}
|
||||
|
||||
alai::CoinCounter::CoinCounter()
|
||||
@ -23,15 +23,28 @@ void alai::CoinCounter::_init()
|
||||
coins = 0;
|
||||
}
|
||||
|
||||
void alai::CoinCounter::_on_coin_collected(int amount)
|
||||
{
|
||||
coins = coins + amount;
|
||||
set_text(godot::String::num(coins));
|
||||
}
|
||||
|
||||
void alai::CoinCounter::_ready()
|
||||
{
|
||||
set_text("0");
|
||||
set_text("00");
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->connect("coin_collected", this, "_on_coin_collected");
|
||||
}
|
||||
|
||||
void alai::CoinCounter::_on_coin_collected(int amount)
|
||||
{
|
||||
coins = coins + amount;
|
||||
if (coins >= 100)
|
||||
{
|
||||
auto extra = coins - 100;
|
||||
coins = extra;
|
||||
}
|
||||
godot::String coin_string = godot::String();
|
||||
if (coins <= 9)
|
||||
{
|
||||
coin_string = "0" + godot::String::num(coins);
|
||||
}
|
||||
else{
|
||||
coin_string = godot::String::num(coins);
|
||||
}
|
||||
set_text(coin_string);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace alai
|
||||
GODOT_CLASS(CoinCounter, godot::Label)
|
||||
|
||||
private:
|
||||
int coins;
|
||||
uint8_t coins;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
void alai::CoinNotCollected::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &CoinNotCollected::_state_enter);
|
||||
register_method("_state_exit", &CoinNotCollected::_state_exit);
|
||||
register_method("_on_body_entered", &CoinNotCollected::_on_body_entered);
|
||||
godot::register_method("_state_enter", &CoinNotCollected::_state_enter);
|
||||
godot::register_method("_state_exit", &CoinNotCollected::_state_exit);
|
||||
godot::register_method("_on_body_entered", &CoinNotCollected::_on_body_entered);
|
||||
}
|
||||
|
||||
alai::CoinNotCollected::CoinNotCollected()
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
void alai::GoalNotReached::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &GoalNotReached::_state_enter);
|
||||
register_method("_state_exit", &GoalNotReached::_state_exit);
|
||||
register_method("_on_Goal_body_entered", &GoalNotReached::_on_Goal_body_entered);
|
||||
godot::register_method("_state_enter", &GoalNotReached::_state_enter);
|
||||
godot::register_method("_state_exit", &GoalNotReached::_state_exit);
|
||||
godot::register_method("_on_Goal_body_entered", &GoalNotReached::_on_Goal_body_entered);
|
||||
}
|
||||
|
||||
alai::GoalNotReached::GoalNotReached()
|
||||
|
@ -1,11 +1,13 @@
|
||||
#include "goal/GoalReached.h"
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
#include <Area2D.hpp>
|
||||
|
||||
void alai::GoalReached::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &GoalReached::_state_enter);
|
||||
register_method("_state_exit", &GoalReached::_state_exit);
|
||||
godot::register_method("_state_enter", &GoalReached::_state_enter);
|
||||
godot::register_method("_state_exit", &GoalReached::_state_exit);
|
||||
}
|
||||
|
||||
alai::GoalReached::GoalReached()
|
||||
@ -22,7 +24,8 @@ void alai::GoalReached::_init()
|
||||
|
||||
void alai::GoalReached::_state_enter()
|
||||
{
|
||||
godot::Godot::print("Flag touched");
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->emit_signal("player_won");
|
||||
}
|
||||
|
||||
void alai::GoalReached::_state_exit()
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "goal/GoalReached.h"
|
||||
#include "goal/GoalNotReached.h"
|
||||
#include "gui/game_over/GameOverScreen.h"
|
||||
#include "gui/game_won/GameWonScreen.h"
|
||||
|
||||
/**
|
||||
* @brief This function connects the gdnative init function.
|
||||
@ -62,4 +63,5 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void *handle)
|
||||
godot::register_class<alai::GoalReached>();
|
||||
godot::register_class<alai::GoalNotReached>();
|
||||
godot::register_class<alai::GameOverScreen>();
|
||||
godot::register_class<alai::GameWonScreen>();
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "gui/game_over/GameOverScreen.h"
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
#include <Node.hpp>
|
||||
#include <AudioStreamPlayer.hpp>
|
||||
#include <PackedScene.hpp>
|
||||
#include <Ref.hpp>
|
||||
#include <Resource.hpp>
|
||||
@ -9,11 +10,13 @@
|
||||
#include <Viewport.hpp>
|
||||
|
||||
void alai::GameOverScreen::_register_methods()
|
||||
{
|
||||
register_method("_on_restart_button_pressed", &GameOverScreen::_on_restart_button_pressed);
|
||||
register_method("_ready", &GameOverScreen::_ready);
|
||||
register_method("connect_signal", &GameOverScreen::connect_signal);
|
||||
register_method("_on_player_died", &GameOverScreen::_on_player_died);
|
||||
{
|
||||
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("_on_visibility_changed", &GameOverScreen::_on_visibility_changed);
|
||||
}
|
||||
|
||||
alai::GameOverScreen::GameOverScreen()
|
||||
@ -36,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<godot::PackedScene> level_scene = _resource_loader->load("res://levels/Prototype.tscn");
|
||||
godot::Ref<godot::PackedScene> 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");
|
||||
|
||||
@ -46,7 +49,7 @@ void alai::GameOverScreen::_on_restart_button_pressed()
|
||||
{
|
||||
level_node->add_child(level);
|
||||
set_visible(false);
|
||||
call_deferred("connect_signal");
|
||||
call_deferred("restart_game");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -80,8 +83,28 @@ void alai::GameOverScreen::_on_player_died()
|
||||
}
|
||||
}
|
||||
|
||||
void alai::GameOverScreen::restart_game()
|
||||
{
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->emit_signal("game_started");
|
||||
connect_signal();
|
||||
}
|
||||
|
||||
void alai::GameOverScreen::connect_signal()
|
||||
{
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->connect("player_died", this, "_on_player_died");
|
||||
}
|
||||
|
||||
void alai::GameOverScreen::_on_visibility_changed()
|
||||
{
|
||||
auto gameoversound = get_node<godot::AudioStreamPlayer>("GameOverMusic");
|
||||
if (is_visible())
|
||||
{
|
||||
gameoversound->play();
|
||||
}
|
||||
else
|
||||
{
|
||||
gameoversound->stop();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
#ifndef ALAI_GAME_OVER_SCREEN_H
|
||||
#define ALAI_GAME_OVER_SCREEN_H
|
||||
#ifndef ALAI_GAME_OVER_GAME_OVER_SCREEN_H
|
||||
#define ALAI_GAME_OVER_GAME_OVER_SCREEN_H
|
||||
|
||||
#include <CanvasLayer.hpp>
|
||||
#include <Godot.hpp>
|
||||
#include <ResourceLoader.hpp>
|
||||
|
||||
|
||||
namespace alai
|
||||
{
|
||||
/**
|
||||
@ -52,7 +53,9 @@ namespace alai
|
||||
void _ready();
|
||||
void _on_player_died();
|
||||
void _on_restart_button_pressed();
|
||||
void restart_game();
|
||||
void connect_signal();
|
||||
void _on_visibility_changed();
|
||||
};
|
||||
}
|
||||
|
||||
|
81
src/gui/game_won/GameWonScreen.cpp
Normal file
81
src/gui/game_won/GameWonScreen.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include "gui/game_won/GameWonScreen.h"
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
#include <AudioStreamPlayer.hpp>
|
||||
#include <SceneTree.hpp>
|
||||
#include <Viewport.hpp>
|
||||
|
||||
void alai::GameWonScreen::_register_methods()
|
||||
{
|
||||
godot::register_method("_ready", &GameWonScreen::_ready);
|
||||
godot::register_method("connect_signal", &GameWonScreen::connect_signal);
|
||||
godot::register_method("_on_player_won", &GameWonScreen::_on_player_won);
|
||||
godot::register_method("_on_quit_button_pressed", &GameWonScreen::_on_quit_button_pressed);
|
||||
godot::register_method("_on_visibility_changed", &GameWonScreen::_on_visibility_changed);
|
||||
}
|
||||
|
||||
alai::GameWonScreen::GameWonScreen()
|
||||
{
|
||||
}
|
||||
|
||||
alai::GameWonScreen::~GameWonScreen()
|
||||
{
|
||||
}
|
||||
|
||||
void alai::GameWonScreen::_init()
|
||||
{
|
||||
}
|
||||
|
||||
void alai::GameWonScreen::_ready()
|
||||
{
|
||||
connect_signal();
|
||||
}
|
||||
|
||||
void alai::GameWonScreen::_on_quit_button_pressed()
|
||||
{
|
||||
get_tree()->quit();
|
||||
}
|
||||
|
||||
void alai::GameWonScreen::_on_player_won()
|
||||
{
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->disconnect("player_won", this, "_on_player_won");
|
||||
set_visible(true);
|
||||
auto level_node = get_tree()->get_root()->get_node("Main")->find_node("Level");
|
||||
if (level_node != nullptr)
|
||||
{
|
||||
auto child = level_node->get_child(0);
|
||||
if (child != nullptr)
|
||||
{
|
||||
child->queue_free();
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_PRINT("Child not found!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_PRINT("Node level not found!");
|
||||
}
|
||||
}
|
||||
|
||||
void alai::GameWonScreen::connect_signal()
|
||||
{
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->connect("player_won", this, "_on_player_won");
|
||||
}
|
||||
|
||||
void alai::GameWonScreen::_on_visibility_changed()
|
||||
{
|
||||
auto victorysound = get_node<godot::AudioStreamPlayer>("VictorySound");
|
||||
if (is_visible())
|
||||
{
|
||||
victorysound->play();
|
||||
}
|
||||
else
|
||||
{
|
||||
victorysound->stop();
|
||||
}
|
||||
}
|
52
src/gui/game_won/GameWonScreen.h
Normal file
52
src/gui/game_won/GameWonScreen.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef ALAI_GAME_WON_GAME_WON_SCREEN_H
|
||||
#define ALAI_GAME_WON_GAME_WON_SCREEN_H
|
||||
|
||||
#include <CanvasLayer.hpp>
|
||||
#include <Godot.hpp>
|
||||
|
||||
namespace alai
|
||||
{
|
||||
/**
|
||||
* @brief This class controls what happens when the game is won.
|
||||
*
|
||||
*/
|
||||
class GameWonScreen : public godot::CanvasLayer
|
||||
{
|
||||
GODOT_CLASS(GameWonScreen, godot::CanvasLayer)
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief This method registers classes with Godot.
|
||||
*
|
||||
* @details This method registers methods, properties, and signals with the Godot engine.
|
||||
*/
|
||||
static void _register_methods();
|
||||
|
||||
/**
|
||||
* @brief Construct a new GameWonScreen object.
|
||||
*
|
||||
*/
|
||||
GameWonScreen();
|
||||
|
||||
/**
|
||||
* @brief Destroy the GameWonScreen object.
|
||||
*
|
||||
*/
|
||||
~GameWonScreen();
|
||||
|
||||
/**
|
||||
* @brief Initialize the class from Godot.
|
||||
*
|
||||
* @details This method is called just once when the Godot engine connects to the instance of the class.
|
||||
*/
|
||||
void _init();
|
||||
|
||||
void _ready();
|
||||
void _on_player_won();
|
||||
void _on_quit_button_pressed();
|
||||
void connect_signal();
|
||||
void _on_visibility_changed();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -19,7 +19,7 @@ void alai::player::Player::_register_methods()
|
||||
godot::register_method("set_velocity", &Player::set_velocity);
|
||||
godot::register_method("get_velocity", &Player::get_velocity);
|
||||
godot::register_method("_on_player_touched", &Player::_on_player_touched);
|
||||
godot::register_method("_on_monitor_loaded", &Player::_on_monitor_loaded);
|
||||
godot::register_method("_on_level_loaded", &Player::_on_level_loaded);
|
||||
//godot::register_property<Player, godot::Ref<godot::SpriteFrames>>("sprite_frames", &Player::set_sprite_frames, &Player::get_sprite_frames, godot::Ref<godot::SpriteFrames>(), GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, godot::String("SpriteFrames"));
|
||||
godot::register_property<Player, float>("speed", &Player::set_speed, &Player::get_speed, player::speed);
|
||||
godot::register_property<Player, float>("jump_force", &Player::set_jump_force, &Player::get_jump_force, player::jump_force);
|
||||
@ -51,11 +51,17 @@ void alai::player::Player::_init()
|
||||
|
||||
coins = 0;
|
||||
|
||||
notifier_initialized = false;
|
||||
|
||||
velocity = godot::Vector2();
|
||||
}
|
||||
|
||||
void alai::player::Player::_ready()
|
||||
{
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->connect("level_loaded", this, "_on_level_loaded");
|
||||
event->connect("player_touched", this, "_on_player_touched");
|
||||
|
||||
animated_sprite = get_node<godot::AnimatedSprite>("AnimatedSprite");
|
||||
if (!animated_sprite)
|
||||
{
|
||||
@ -77,7 +83,7 @@ void alai::player::Player::_ready()
|
||||
}
|
||||
}
|
||||
|
||||
void alai::player::Player::_on_monitor_loaded() {
|
||||
void alai::player::Player::_on_level_loaded() {
|
||||
auto state = get_node("StateMachine")->get_child(0);
|
||||
if (state != nullptr)
|
||||
{
|
||||
@ -151,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,10 +192,17 @@ void alai::player::Player::_physics_process(float delta)
|
||||
auto notifier = get_node<godot::VisibilityNotifier2D>("Camera2D/VisibilityNotifier2D");
|
||||
if (notifier != nullptr)
|
||||
{
|
||||
if (!notifier->is_on_screen())
|
||||
if (notifier->is_inside_tree() && !notifier->is_on_screen())
|
||||
{
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->emit_signal("player_died");
|
||||
// The first time the notifier is checked always returns false in the first frame
|
||||
// So skip the check from the first frame
|
||||
if (notifier_initialized) {
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->emit_signal("player_died");
|
||||
}
|
||||
else {
|
||||
notifier_initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -289,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<alai::Event>("/root/Event");
|
||||
event->emit_signal("player_died");
|
||||
|
@ -117,6 +117,11 @@ namespace alai
|
||||
*
|
||||
*/
|
||||
bool double_jump;
|
||||
/**
|
||||
* @brief If the notifier for the player being on screen has been initialized or not.
|
||||
*
|
||||
*/
|
||||
bool notifier_initialized;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -278,13 +283,13 @@ 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.
|
||||
*
|
||||
*/
|
||||
void _on_monitor_loaded();
|
||||
void _on_level_loaded();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
void alai::player::PlayerFall::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &PlayerFall::_state_enter);
|
||||
register_method("_state_exit", &PlayerFall::_state_exit);
|
||||
register_method("_physics_process", &PlayerFall::_physics_process);
|
||||
godot::register_method("_state_enter", &PlayerFall::_state_enter);
|
||||
godot::register_method("_state_exit", &PlayerFall::_state_exit);
|
||||
godot::register_method("_physics_process", &PlayerFall::_physics_process);
|
||||
}
|
||||
|
||||
alai::player::PlayerFall::PlayerFall()
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
void alai::player::PlayerIdle::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &PlayerIdle::_state_enter);
|
||||
register_method("_state_exit", &PlayerIdle::_state_exit);
|
||||
register_method("_physics_process", &PlayerIdle::_physics_process);
|
||||
godot::register_method("_state_enter", &PlayerIdle::_state_enter);
|
||||
godot::register_method("_state_exit", &PlayerIdle::_state_exit);
|
||||
godot::register_method("_physics_process", &PlayerIdle::_physics_process);
|
||||
}
|
||||
|
||||
alai::player::PlayerIdle::PlayerIdle()
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
void alai::player::PlayerJump::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &PlayerJump::_state_enter);
|
||||
register_method("_state_exit", &PlayerJump::_state_exit);
|
||||
register_method("_physics_process", &PlayerJump::_physics_process);
|
||||
godot::register_method("_state_enter", &PlayerJump::_state_enter);
|
||||
godot::register_method("_state_exit", &PlayerJump::_state_exit);
|
||||
godot::register_method("_physics_process", &PlayerJump::_physics_process);
|
||||
}
|
||||
|
||||
alai::player::PlayerJump::PlayerJump()
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
void alai::player::PlayerMove::_register_methods()
|
||||
{
|
||||
register_method("_state_enter", &PlayerMove::_state_enter);
|
||||
register_method("_state_exit", &PlayerMove::_state_exit);
|
||||
register_method("_physics_process", &PlayerMove::_physics_process);
|
||||
godot::register_method("_state_enter", &PlayerMove::_state_enter);
|
||||
godot::register_method("_state_exit", &PlayerMove::_state_exit);
|
||||
godot::register_method("_physics_process", &PlayerMove::_physics_process);
|
||||
}
|
||||
|
||||
alai::player::PlayerMove::PlayerMove()
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
void alai::State::_register_methods()
|
||||
{
|
||||
register_method("set_parent", &State::set_parent);
|
||||
register_method("get_parent", &State::get_parent);
|
||||
register_method("set_state_machine", &State::set_state_machine);
|
||||
register_method("_state_enter", &State::_state_enter);
|
||||
register_method("_state_exit", &State::_state_exit);
|
||||
godot::register_method("set_parent", &State::set_parent);
|
||||
godot::register_method("get_parent", &State::get_parent);
|
||||
godot::register_method("set_state_machine", &State::set_state_machine);
|
||||
godot::register_method("_state_enter", &State::_state_enter);
|
||||
godot::register_method("_state_exit", &State::_state_exit);
|
||||
}
|
||||
|
||||
alai::State::State()
|
||||
|
Loading…
Reference in New Issue
Block a user