1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
Felipe M 614ee06c34
Main Menu 2021-02-04 20:25:48 +01:00
Felipe M f272b7b433
Start menu 2021-02-04 20:09:35 +01:00
Felipe M 0f5e075a54
Health meter 2021-02-04 20:04:56 +01:00
Felipe M edadd138b0
Camera and UI 2021-02-04 19:53:22 +01:00
16 changed files with 12218 additions and 6 deletions

4
metroidvania/Events.gd Normal file
View File

@ -0,0 +1,4 @@
extends Node
# warning-ignore-all:unused_signal
signal add_screenshake(amount, duration)

View File

@ -2,4 +2,5 @@ extends Area2D
# Receives damage
# warning-ignore-all:unused_signal
signal hit(damage)

View File

@ -4,10 +4,15 @@ class_name PlayerStats
var max_health = 4
var health = max_health setget set_health
signal player_health_changed(value)
signal player_died
func set_health(value):
if value < health:
Events.emit_signal("add_screenshake", 0.5, 0.5)
health = clamp(value, 0, max_health)
emit_signal("player_health_changed", health)
if health == 0:
emit_signal("player_died")

View File

@ -0,0 +1,11 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://Assets/UI/ButtonHoverStylebox.png" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 6, 6 )
margin_left = 2.0
margin_right = 2.0
margin_top = 2.0
margin_bottom = 2.0

View File

@ -0,0 +1,11 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://Assets/UI/ButtonStylebox.png" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 6, 6 )
margin_left = 2.0
margin_right = 2.0
margin_top = 2.0
margin_bottom = 2.0

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
extends Control
var PlayerStats = ResourceLoader.PlayerStats
onready var full = $Full
func _ready():
PlayerStats.connect("player_health_changed", self, "_on_player_health_changed")
func _on_player_health_changed(value):
full.rect_size.x = value * 5 + 1

View File

@ -0,0 +1,27 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Assets/UI/HealthMeterEmpty.png" type="Texture" id=1]
[ext_resource path="res://Assets/UI/HealthMeter.png" type="Texture" id=2]
[ext_resource path="res://Scenes/UI/HealthMeter.gd" type="Script" id=3]
[node name="HealthMeter" type="Control"]
margin_right = 21.0
margin_bottom = 12.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Empty" type="TextureRect" parent="."]
margin_right = 21.0
margin_bottom = 12.0
texture = ExtResource( 1 )
expand = true
stretch_mode = 2
[node name="Full" type="TextureRect" parent="."]
margin_right = 21.0
margin_bottom = 12.0
texture = ExtResource( 2 )
expand = true
stretch_mode = 2

View File

@ -0,0 +1,8 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://Assets/UI/Pixel.ttf" type="DynamicFontData" id=1]
[resource]
size = 6
extra_spacing_top = 1
font_data = ExtResource( 1 )

View File

@ -0,0 +1,46 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://StarMenu.gd" type="Script" id=1]
[ext_resource path="res://Scenes/UI/DefaultTheme.tres" type="Theme" id=2]
[node name="StarMenu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 2 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CenterContainer" type="CenterContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 132.0
margin_top = 62.0
margin_right = 188.0
margin_bottom = 118.0
[node name="StartButton" type="Button" parent="CenterContainer/VBoxContainer"]
margin_right = 56.0
margin_bottom = 16.0
rect_min_size = Vector2( 56, 16 )
text = "New Game"
[node name="LoadButton" type="Button" parent="CenterContainer/VBoxContainer"]
margin_top = 20.0
margin_right = 56.0
margin_bottom = 36.0
rect_min_size = Vector2( 56, 16 )
text = "Load game"
[node name="QuitButton" type="Button" parent="CenterContainer/VBoxContainer"]
margin_top = 40.0
margin_right = 56.0
margin_bottom = 56.0
rect_min_size = Vector2( 56, 16 )
text = "Quit"
[connection signal="pressed" from="CenterContainer/VBoxContainer/StartButton" to="." method="_on_StartButton_pressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/LoadButton" to="." method="_on_LoadButton_pressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"]

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/UI/HealthMeter.tscn" type="PackedScene" id=1]
[node name="UI" type="CanvasLayer"]
[node name="HealthMeter" parent="." instance=ExtResource( 1 )]
margin_left = 4.0
margin_top = 4.0
margin_right = 25.0
margin_bottom = 16.0

View File

@ -0,0 +1,23 @@
extends Camera2D
var shake = 0
onready var timer = $Timer
func _ready():
Events.connect("add_screenshake", self, "_on_Events_add_screenshake")
func _process(delta):
offset_h = rand_range(-shake, shake)
offset_v = rand_range(-shake, shake)
func screenshake(amount, duration):
shake = amount
timer.wait_time = duration
timer.start()
func _on_Timer_timeout():
shake = 0
func _on_Events_add_screenshake(amount, duration):
screenshake(amount, duration)

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/World/Camera.gd" type="Script" id=1]
[node name="Camera" type="Camera2D"]
current = true
smoothing_enabled = true
script = ExtResource( 1 )
[node name="Timer" type="Timer" parent="."]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

View File

@ -1,10 +1,12 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://Scenes/World/TileMap.tscn" type="PackedScene" id=1]
[ext_resource path="res://Scenes/Player/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scenes/World/World.gd" type="Script" id=3]
[ext_resource path="res://Scenes/World/MovingPlatform.tscn" type="PackedScene" id=4]
[ext_resource path="res://Scenes/Enemies/WalkingEnemy.tscn" type="PackedScene" id=5]
[ext_resource path="res://Scenes/World/Camera.tscn" type="PackedScene" id=6]
[ext_resource path="res://Scenes/UI/UI.tscn" type="PackedScene" id=7]
[node name="World" type="Node"]
script = ExtResource( 3 )
@ -12,13 +14,11 @@ script = ExtResource( 3 )
[node name="Player" parent="." instance=ExtResource( 2 )]
position = Vector2( 9, 96 )
[node name="CameraFollow" parent="Player" index="4"]
[node name="CameraFollow" parent="Player" index="5"]
remote_path = NodePath("../../Camera")
[node name="Camera" type="Camera2D" parent="."]
[node name="Camera" parent="." instance=ExtResource( 6 )]
position = Vector2( 9, 88 )
current = true
smoothing_enabled = true
[node name="TileMap" parent="." instance=ExtResource( 1 )]
tile_data = PoolIntArray( 18, 0, 0, 19, 0, 5, 20, 0, 196609, 21, 0, 196609, 22, 0, 196609, 23, 0, 196609, 24, 0, 196609, 25, 0, 196609, 26, 0, 196609, 27, 0, 196609, 28, 0, 196609, 29, 0, 196609, 30, 0, 196609, 31, 0, 196609, 32, 0, 196609, 33, 0, 196609, 34, 0, 196609, 35, 0, 196609, 36, 0, 196609, 37, 0, 196609, 38, 0, 196609, 39, 0, 196609, 40, 0, 7, 65536, 0, 4, 65537, 0, 196609, 65538, 0, 196609, 65539, 0, 196609, 65540, 0, 196609, 65541, 0, 6, 65542, 0, 5, 65543, 0, 196609, 65544, 0, 196609, 65545, 0, 196609, 65546, 0, 6, 65547, 0, 2, 65554, 0, 65536, 65555, 0, 65538, 65576, 0, 65539, 196607, 0, 4, 131072, 0, 196615, 131077, 0, 131072, 131078, 0, 131074, 131082, 0, 65536, 131083, 0, 131077, 131084, 0, 1, 131085, 0, 5, 131086, 0, 196609, 131087, 0, 196609, 131088, 0, 196609, 131089, 0, 196609, 131090, 0, 196614, 131091, 0, 131074, 131112, 0, 65539, 262143, 0, 65539, 196618, 0, 131072, 196619, 0, 131073, 196620, 0, 131073, 196621, 0, 131074, 196648, 0, 65539, 327679, 0, 65539, 262184, 0, 65539, 393215, 0, 65539, 327705, 1, 3, 327706, 1, 4, 327707, 0, 1, 327708, 0, 1, 327709, 0, 1, 327710, 0, 1, 327711, 536870913, 4, 327712, 536870913, 3, 327720, 0, 65539, 458751, 0, 65539, 393238, 1, 0, 393239, 0, 1, 393240, 0, 1, 393241, 1, 5, 393242, 536870912, 65537, 393243, 536870912, 65537, 393244, 536870912, 65537, 393245, 536870912, 65537, 393246, 536870912, 65537, 393247, 536870912, 65537, 393248, 536870913, 5, 393249, 536870912, 1, 393250, 536870912, 1, 393251, 536870913, 0, 393256, 0, 65539, 524287, 0, 65539, 458762, 1, 3, 458763, 1, 4, 458764, 0, 1, 458765, 0, 2, 458773, 1, 0, 458774, 1, 1, 458775, 536870912, 65537, 458776, 536870912, 65537, 458777, 536870912, 65537, 458778, 536870912, 65537, 458779, 536870912, 65537, 458780, 536870912, 65537, 458781, 536870912, 65537, 458782, 536870912, 65537, 458783, 536870912, 65537, 458784, 536870912, 65537, 458785, 536870912, 65537, 458786, 536870912, 65537, 458787, 536870913, 1, 458788, 536870913, 0, 458792, 0, 65539, 589823, 0, 65539, 524294, 1, 0, 524295, 0, 1, 524296, 0, 1, 524297, 0, 1, 524298, 0, 131078, 524299, 0, 65537, 524300, 0, 65537, 524301, 0, 131077, 524302, 0, 1, 524303, 0, 1, 524304, 0, 1, 524305, 0, 1, 524306, 0, 1, 524307, 0, 1, 524308, 0, 2, 524309, 1, 2, 524310, 536870912, 131073, 524311, 536870912, 131073, 524312, 536870912, 131073, 524313, 536870912, 131073, 524314, 536870912, 131073, 524315, 536870912, 131073, 524316, 536870912, 131073, 524317, 536870912, 131073, 524318, 536870912, 131073, 524319, 536870912, 131073, 524320, 536870912, 131073, 524321, 536870912, 131073, 524322, 536870912, 131073, 524323, 536870912, 131073, 524324, 536870913, 2, 524325, 0, 196609, 524326, 0, 196609, 524327, 0, 196609, 524328, 0, 196615, 655359, 0, 131076, 589824, 0, 2, 589829, 1, 0, 589830, 1, 1, 589831, 0, 65537, 589832, 0, 65537, 589833, 0, 65537, 589834, 0, 65537, 589835, 0, 65537, 589836, 0, 65537, 589837, 0, 65537, 589838, 0, 65537, 589839, 0, 65537, 589840, 0, 65537, 589841, 0, 65537, 589842, 0, 65537, 589843, 0, 65537, 589844, 0, 65538, 720895, 0, 65536, 655360, 0, 131077, 655361, 0, 1, 655362, 0, 1, 655363, 0, 1, 655364, 0, 1, 655365, 1, 1, 655366, 0, 65537, 655367, 0, 65537, 655368, 0, 65541, 655369, 0, 131073, 655370, 0, 131073, 655371, 0, 131073, 655372, 0, 65542, 655373, 0, 65537, 655374, 0, 65537, 655375, 0, 65537, 655376, 0, 65537, 655377, 0, 65541, 655378, 0, 131073, 655379, 0, 131073, 655380, 0, 131074, 786431, 0, 131072, 720896, 0, 65542, 720897, 0, 65537, 720898, 0, 65537, 720899, 0, 65537, 720900, 0, 65537, 720901, 0, 65537, 720902, 0, 65537, 720903, 0, 65541, 720904, 0, 131074, 720908, 0, 131072, 720909, 0, 65542, 720910, 0, 65537, 720911, 0, 65537, 720912, 0, 65541, 720913, 0, 131074, 786432, 0, 65536, 786433, 0, 65537, 786434, 0, 65537, 786435, 0, 65537, 786436, 0, 65537, 786437, 0, 65537, 786438, 0, 65537, 786439, 0, 65538, 786445, 0, 65536, 786446, 0, 65541, 786447, 0, 131073, 786448, 0, 131074, 851968, 0, 131072, 851969, 0, 65542, 851970, 0, 65537, 851971, 0, 65537, 851972, 0, 65541, 851973, 0, 131073, 851974, 0, 131073, 851975, 0, 196613, 851976, 0, 196609, 851977, 0, 196609, 851978, 0, 196609, 851979, 0, 196609, 851980, 0, 196609, 851981, 0, 196614, 851982, 0, 131074, 917505, 0, 131072, 917506, 0, 131073, 917507, 0, 131073, 917508, 0, 131074 )
@ -35,4 +35,6 @@ position = Vector2( 160, 208 )
[node name="WalkingEnemy3" parent="." instance=ExtResource( 5 )]
position = Vector2( 448, 80 )
[node name="UI" parent="." instance=ExtResource( 7 )]
[editable path="Player"]

15
metroidvania/StarMenu.gd Normal file
View File

@ -0,0 +1,15 @@
extends Control
func _ready():
VisualServer.set_default_clear_color(Color.black)
func _on_StartButton_pressed():
# warning-ignore:return_value_discarded
get_tree().change_scene("res://Scenes/World/World.tscn")
func _on_LoadButton_pressed():
# TODO: Savegames
pass
func _on_QuitButton_pressed():
get_tree().quit()

View File

@ -21,13 +21,14 @@ _global_script_class_icons={
[application]
config/name="Metroidvania"
run/main_scene="res://Scenes/World/World.tscn"
run/main_scene="res://Scenes/UI/StarMenu.tscn"
config/icon="res://icon.png"
[autoload]
Utils="*res://Utils.gd"
ResourceLoader="*res://ResourceLoader.gd"
Events="*res://Events.gd"
[display]