add ui and prettify
This commit is contained in:
parent
f31033dd59
commit
d08cfff850
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=14 format=4 uid="uid://dhgts0kodsujx"]
|
[gd_scene load_steps=15 format=4 uid="uid://dhgts0kodsujx"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://djkjmi7bo58uv" path="res://scenes/crate.tscn" id="1_6shkr"]
|
[ext_resource type="PackedScene" uid="uid://djkjmi7bo58uv" path="res://scenes/crate.tscn" id="1_6shkr"]
|
||||||
[ext_resource type="Script" path="res://scripts/sceneManager.gd" id="1_ooich"]
|
[ext_resource type="Script" path="res://scripts/sceneManager.gd" id="1_ooich"]
|
||||||
@ -10,6 +10,7 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://dktvd8atklmau" path="res://assets/graphics/terrains/Terrain (32x32).png" id="6_jpfcs"]
|
[ext_resource type="Texture2D" uid="uid://dktvd8atklmau" path="res://assets/graphics/terrains/Terrain (32x32).png" id="6_jpfcs"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cey0ymp1n0iqe" path="res://scenes/coin.tscn" id="8_cgxc5"]
|
[ext_resource type="PackedScene" uid="uid://cey0ymp1n0iqe" path="res://scenes/coin.tscn" id="8_cgxc5"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bk0pk4m1ln716" path="res://scenes/badguy.tscn" id="9_da82o"]
|
[ext_resource type="PackedScene" uid="uid://bk0pk4m1ln716" path="res://scenes/badguy.tscn" id="9_da82o"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dna0q0tmmxs0g" path="res://scenes/ui.tscn" id="11_i83dw"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v72u6"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v72u6"]
|
||||||
texture = ExtResource("6_jpfcs")
|
texture = ExtResource("6_jpfcs")
|
||||||
@ -383,6 +384,10 @@ radius = 62.0
|
|||||||
|
|
||||||
[node name="Game" type="Node2D"]
|
[node name="Game" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="ui" parent="CanvasLayer" instance=ExtResource("11_i83dw")]
|
||||||
|
|
||||||
[node name="background" type="Parallax2D" parent="."]
|
[node name="background" type="Parallax2D" parent="."]
|
||||||
scroll_offset = Vector2(626, 298)
|
scroll_offset = Vector2(626, 298)
|
||||||
repeat_size = Vector2(320, 0)
|
repeat_size = Vector2(320, 0)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=15 format=4 uid="uid://dxvvtcldbhsac"]
|
[gd_scene load_steps=16 format=4 uid="uid://dxvvtcldbhsac"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://dordo7deet5y0" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="1_fca7k"]
|
[ext_resource type="Texture2D" uid="uid://dordo7deet5y0" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="1_fca7k"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cukevm4avtgnp" path="res://assets/graphics/terrains/backgrounds/sky.png" id="2_7a0hu"]
|
[ext_resource type="Texture2D" uid="uid://cukevm4avtgnp" path="res://assets/graphics/terrains/backgrounds/sky.png" id="2_7a0hu"]
|
||||||
@ -10,6 +10,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://djkjmi7bo58uv" path="res://scenes/crate.tscn" id="8_q5n2b"]
|
[ext_resource type="PackedScene" uid="uid://djkjmi7bo58uv" path="res://scenes/crate.tscn" id="8_q5n2b"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cey0ymp1n0iqe" path="res://scenes/coin.tscn" id="9_iql8u"]
|
[ext_resource type="PackedScene" uid="uid://cey0ymp1n0iqe" path="res://scenes/coin.tscn" id="9_iql8u"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bk0pk4m1ln716" path="res://scenes/badguy.tscn" id="10_w2bl5"]
|
[ext_resource type="PackedScene" uid="uid://bk0pk4m1ln716" path="res://scenes/badguy.tscn" id="10_w2bl5"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dna0q0tmmxs0g" path="res://scenes/ui.tscn" id="11_6mr7q"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v72u6"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v72u6"]
|
||||||
texture = ExtResource("5_qoo1j")
|
texture = ExtResource("5_qoo1j")
|
||||||
@ -386,6 +387,10 @@ radius = 62.0
|
|||||||
|
|
||||||
[node name="Game" type="Node2D"]
|
[node name="Game" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="ui" parent="CanvasLayer" instance=ExtResource("11_6mr7q")]
|
||||||
|
|
||||||
[node name="background" type="Parallax2D" parent="."]
|
[node name="background" type="Parallax2D" parent="."]
|
||||||
scroll_offset = Vector2(626, 298)
|
scroll_offset = Vector2(626, 298)
|
||||||
repeat_size = Vector2(320, 0)
|
repeat_size = Vector2(320, 0)
|
||||||
@ -473,5 +478,8 @@ position = Vector2(72, 107)
|
|||||||
[node name="Area2D2" parent="coins" instance=ExtResource("9_iql8u")]
|
[node name="Area2D2" parent="coins" instance=ExtResource("9_iql8u")]
|
||||||
position = Vector2(-178, 75)
|
position = Vector2(-178, 75)
|
||||||
|
|
||||||
|
[node name="Area2D3" parent="coins" instance=ExtResource("9_iql8u")]
|
||||||
|
position = Vector2(315, 204)
|
||||||
|
|
||||||
[connection signal="areaTrigger" from="Area2D" to="." method="_on_trigger"]
|
[connection signal="areaTrigger" from="Area2D" to="." method="_on_trigger"]
|
||||||
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]
|
||||||
|
@ -186,7 +186,7 @@ animations = [{
|
|||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": &"playerDeath",
|
"name": &"playerDeath",
|
||||||
"speed": 12.0
|
"speed": 6.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
75
scenes/ui.tscn
Normal file
75
scenes/ui.tscn
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://dna0q0tmmxs0g"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui.gd" id="1_1b5vo"]
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_bb10x"]
|
||||||
|
font_size = 12
|
||||||
|
font_color = Color(0.776471, 0.027451, 0.113725, 1)
|
||||||
|
outline_size = 1
|
||||||
|
outline_color = Color(0.0768358, 0.0768358, 0.0768358, 1)
|
||||||
|
shadow_size = 3
|
||||||
|
shadow_color = Color(0.121569, 0.121569, 0.121569, 0.670588)
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_rb7h3"]
|
||||||
|
font_size = 12
|
||||||
|
outline_size = 1
|
||||||
|
outline_color = Color(0.0768358, 0.0768358, 0.0768358, 1)
|
||||||
|
shadow_size = 3
|
||||||
|
shadow_color = Color(0.121569, 0.121569, 0.121569, 0.670588)
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_fsj7b"]
|
||||||
|
font_size = 12
|
||||||
|
font_color = Color(0.99068, 0.855439, 0.297628, 1)
|
||||||
|
outline_size = 1
|
||||||
|
outline_color = Color(0.0768358, 0.0768358, 0.0768358, 1)
|
||||||
|
shadow_size = 3
|
||||||
|
shadow_color = Color(0.121569, 0.121569, 0.121569, 0.670588)
|
||||||
|
|
||||||
|
[node name="Control" 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_1b5vo")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 10
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_bottom = 23.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
texture_filter = 1
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="health" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer"]
|
||||||
|
texture_filter = 1
|
||||||
|
layout_mode = 2
|
||||||
|
label_settings = SubResource("LabelSettings_bb10x")
|
||||||
|
|
||||||
|
[node name="MarginContainer3" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="timer" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
label_settings = SubResource("LabelSettings_rb7h3")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="coins" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2"]
|
||||||
|
texture_filter = 1
|
||||||
|
layout_mode = 2
|
||||||
|
label_settings = SubResource("LabelSettings_fsj7b")
|
||||||
|
horizontal_alignment = 2
|
@ -22,7 +22,7 @@ var bullet = preload("res://scenes/bullet.tscn")
|
|||||||
var isJumping = false
|
var isJumping = false
|
||||||
|
|
||||||
var living = true
|
var living = true
|
||||||
var animPlaying = "idle"
|
var animPlaying = "playerIdle"
|
||||||
|
|
||||||
signal deathAnimDone
|
signal deathAnimDone
|
||||||
|
|
||||||
|
@ -18,9 +18,12 @@ var currentLevel = 0
|
|||||||
#Gamecontroller signals
|
#Gamecontroller signals
|
||||||
signal destroyBox(body)
|
signal destroyBox(body)
|
||||||
signal levelComplete(leveltoLoad)
|
signal levelComplete(leveltoLoad)
|
||||||
signal playerHurt(amt)
|
signal playerHurt(amt, max)
|
||||||
signal playerDeath()
|
signal playerDeath()
|
||||||
|
|
||||||
|
signal tick(timeRemaining)
|
||||||
|
signal coinsUpdate(collected, remaining)
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
player = load("res://scripts/res/playerstats.tres")
|
player = load("res://scripts/res/playerstats.tres")
|
||||||
@ -33,14 +36,22 @@ func _ready() -> void:
|
|||||||
timer.start()
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func reset():
|
func reset():
|
||||||
secondCount = timers[currentLevel]
|
secondCount = timers[currentLevel]
|
||||||
player.health = player.starting_health
|
player.health = player.starting_health
|
||||||
|
playerHurt.emit.call_deferred(player.health, player.max_health)
|
||||||
|
tick.emit.call_deferred(secondCount)
|
||||||
|
totalCoinsCollected = 0
|
||||||
|
coinsUpdate.emit.call_deferred(totalCoinsCollected, totalCoins)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func secondCounter():
|
func secondCounter():
|
||||||
print("time left: ", secondCount)
|
print("time left: ", secondCount)
|
||||||
secondCount -=1
|
secondCount -=1
|
||||||
|
tick.emit(secondCount)
|
||||||
if secondCount <= 0:
|
if secondCount <= 0:
|
||||||
print("TIME IS UP")
|
print("TIME IS UP")
|
||||||
levelComplete.emit(levels[currentLevel])
|
levelComplete.emit(levels[currentLevel])
|
||||||
@ -50,9 +61,9 @@ func playerDamaged():
|
|||||||
print("GC knows player took damage")
|
print("GC knows player took damage")
|
||||||
player.health = max(player.health-20, 0)
|
player.health = max(player.health-20, 0)
|
||||||
print("Player Health: "+str(player.health))
|
print("Player Health: "+str(player.health))
|
||||||
if player.health > 0:
|
playerHurt.emit(player.health, player.max_health)
|
||||||
playerHurt.emit(player.health)
|
|
||||||
else:
|
if player.health <= 0:
|
||||||
playerDeath.emit()
|
playerDeath.emit()
|
||||||
|
|
||||||
|
|
||||||
@ -60,6 +71,7 @@ func playerDamaged():
|
|||||||
func coinCollected():
|
func coinCollected():
|
||||||
totalCoinsCollected += 1
|
totalCoinsCollected += 1
|
||||||
print("DING! Coins collected: "+ str(totalCoinsCollected) )
|
print("DING! Coins collected: "+ str(totalCoinsCollected) )
|
||||||
|
coinsUpdate.emit(totalCoinsCollected, totalCoins)
|
||||||
|
|
||||||
|
|
||||||
func bulletHit(body):
|
func bulletHit(body):
|
||||||
|
@ -6,6 +6,7 @@ extends Node
|
|||||||
@onready var enemies: Node2D = $"../enemies"
|
@onready var enemies: Node2D = $"../enemies"
|
||||||
|
|
||||||
@onready var player: CharacterBody2D = $"../CharacterBody2D"
|
@onready var player: CharacterBody2D = $"../CharacterBody2D"
|
||||||
|
@onready var ui: Control = $"../CanvasLayer/ui"
|
||||||
|
|
||||||
var theBullet = preload("res://scenes/bullet.tscn")
|
var theBullet = preload("res://scenes/bullet.tscn")
|
||||||
var bulletArray:Array = []
|
var bulletArray:Array = []
|
||||||
@ -42,6 +43,11 @@ func _ready() -> void:
|
|||||||
# Subscribe to signals
|
# Subscribe to signals
|
||||||
GameController.levelComplete.connect(changeLevel)
|
GameController.levelComplete.connect(changeLevel)
|
||||||
player.deathAnimDone.connect(GameController.playerDead)
|
player.deathAnimDone.connect(GameController.playerDead)
|
||||||
|
|
||||||
|
GameController.tick.connect(ui.timerUpdate)
|
||||||
|
GameController.playerHurt.connect(ui.healthUpdate, ConnectFlags.CONNECT_DEFERRED)
|
||||||
|
GameController.coinsUpdate.connect(ui.coinsUpdate)
|
||||||
|
|
||||||
GameController.reset()
|
GameController.reset()
|
||||||
|
|
||||||
|
|
||||||
|
31
scripts/ui.gd
Normal file
31
scripts/ui.gd
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
@onready var timer: Label = $VBoxContainer/HBoxContainer/MarginContainer3/timer
|
||||||
|
@onready var health: Label = $VBoxContainer/HBoxContainer/MarginContainer/health
|
||||||
|
@onready var coins: Label = $VBoxContainer/HBoxContainer/MarginContainer2/coins
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func timerUpdate(timeRemaining):
|
||||||
|
if timeRemaining <= 0:
|
||||||
|
timer.text = "OUT OF TIME"
|
||||||
|
else:
|
||||||
|
timer.text = "🕔: "+str(timeRemaining)
|
||||||
|
|
||||||
|
|
||||||
|
func healthUpdate(healthRemaining, healthMax):
|
||||||
|
if healthRemaining <= 0:
|
||||||
|
health.text = " 💀 💀 💀 💀 "
|
||||||
|
else:
|
||||||
|
health.text = (" ❤️: "+str(healthRemaining)+"/"+str(healthMax))
|
||||||
|
|
||||||
|
|
||||||
|
func coinsUpdate(collected, remaining):
|
||||||
|
coins.text = ("🪙: "+str(collected)+"/"+str(remaining)+" ")
|
Loading…
Reference in New Issue
Block a user