player death, player hurt, ui

This commit is contained in:
OddlyTimbot 2025-02-10 21:12:59 -05:00
parent 8bb10b79a8
commit 4389b9804c
14 changed files with 432 additions and 81 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://brk4npndc5woq"
path="res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/death/Player Death 64x64.png"
dest_files=["res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://yqw4w6dfvdkw"
path="res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/hurt/Player Hurt 48x48.png"
dest_files=["res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -20,4 +20,5 @@ rotation = 3.14089
scale = Vector2(0.0794906, 0.0794906)
texture = ExtResource("2_0y61d")
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=16 format=4 uid="uid://r8jj43l4t6is"]
[gd_scene load_steps=17 format=4 uid="uid://r8jj43l4t6is"]
[ext_resource type="PackedScene" uid="uid://di3tq4f0xmdqc" path="res://scenes/crate.tscn" id="1_tfj4n"]
[ext_resource type="PackedScene" uid="uid://bissd2c653cg5" path="res://scenes/ui.tscn" id="2_5absq"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="3_hm0br"]
[ext_resource type="Texture2D" uid="uid://ka2skiy8uj8c" path="res://assets/graphics/terrains/backgrounds/forestbackground (1).png" id="3_jlqfv"]
[ext_resource type="PackedScene" uid="uid://dcbk086hhrn7y" path="res://scenes/player.tscn" id="3_oy8j2"]
@ -388,6 +389,10 @@ radius = 29.0
unique_name_in_owner = true
script = ExtResource("6_1kka5")
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="ui" parent="CanvasLayer" instance=ExtResource("2_5absq")]
[node name="Background" type="Parallax2D" parent="."]
scroll_scale = Vector2(0.5, 1)
repeat_size = Vector2(320, 0)
@ -446,15 +451,15 @@ position = Vector2(196, 115)
rotation = 2.0228
[node name="RigidBody2D2" parent="crates" instance=ExtResource("1_tfj4n")]
position = Vector2(317, 133)
position = Vector2(353, 143)
[node name="RigidBody2D3" parent="crates" instance=ExtResource("1_tfj4n")]
position = Vector2(389, 49)
position = Vector2(406, 140)
[node name="coins" type="Node2D" parent="."]
[node name="Area2D" parent="coins" instance=ExtResource("10_tkwbv")]
position = Vector2(288, 149)
position = Vector2(307, 150)
[node name="enemies" type="Node2D" parent="."]

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=15 format=4 uid="uid://ctbk75ohtgn52"]
[gd_scene load_steps=17 format=4 uid="uid://ctbk75ohtgn52"]
[ext_resource type="Script" path="res://scripts/scene_manager.gd" id="1_nno8q"]
[ext_resource type="Texture2D" uid="uid://ka2skiy8uj8c" path="res://assets/graphics/terrains/backgrounds/forestbackground (1).png" id="2_2sxt8"]
[ext_resource type="PackedScene" uid="uid://bissd2c653cg5" path="res://scenes/ui.tscn" id="2_6u8nu"]
[ext_resource type="Texture2D" uid="uid://5uu4qwac4co" path="res://assets/graphics/terrains/backgrounds/skystrip.png" id="3_q3nnd"]
[ext_resource type="Texture2D" uid="uid://dvw2k2s2t1s7i" path="res://assets/graphics/terrains/backgrounds/midtrees.png" id="4_pn8y7"]
[ext_resource type="Texture2D" uid="uid://de4acrj4jm3cw" path="res://assets/graphics/objects/planedown.png" id="5_x7x8v"]
@ -10,6 +11,7 @@
[ext_resource type="Script" path="res://scripts/trigger.gd" id="8_1l7lm"]
[ext_resource type="PackedScene" uid="uid://di3tq4f0xmdqc" path="res://scenes/crate.tscn" id="9_akhlr"]
[ext_resource type="PackedScene" uid="uid://djcmk4sjeejcg" path="res://scenes/coin.tscn" id="10_puv42"]
[ext_resource type="PackedScene" uid="uid://dc3up6wvi521j" path="res://scenes/badguy.tscn" id="12_jdqy2"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_pgbim"]
texture = ExtResource("6_exrs3")
@ -387,6 +389,10 @@ radius = 29.0
unique_name_in_owner = true
script = ExtResource("1_nno8q")
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="ui" parent="CanvasLayer" instance=ExtResource("2_6u8nu")]
[node name="Background" type="Parallax2D" parent="."]
scroll_scale = Vector2(0.5, 1)
repeat_size = Vector2(320, 0)
@ -427,7 +433,7 @@ position = Vector2(4, 42)
shape = SubResource("WorldBoundaryShape2D_acecj")
[node name="CharacterBody2D" parent="." instance=ExtResource("7_6hxr3")]
position = Vector2(253, 89)
position = Vector2(119, 53)
[node name="Area2D" type="Area2D" parent="."]
position = Vector2(612, -100)
@ -455,5 +461,19 @@ position = Vector2(406, 145)
[node name="Area2D" parent="coins" instance=ExtResource("10_puv42")]
position = Vector2(288, 149)
[node name="Area2D2" parent="coins" instance=ExtResource("10_puv42")]
position = Vector2(570, -9)
[node name="Area2D3" parent="coins" instance=ExtResource("10_puv42")]
position = Vector2(373, 57)
[node name="enemies" type="Node2D" parent="."]
[node name="Area2D" parent="enemies" instance=ExtResource("12_jdqy2")]
position = Vector2(199, 86)
[node name="Area2D2" parent="enemies" instance=ExtResource("12_jdqy2")]
position = Vector2(415, 53)
[connection signal="areaTrigger" from="Area2D" to="." method="_on_trigger"]
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]

View File

@ -1,12 +1,70 @@
[gd_scene load_steps=28 format=3 uid="uid://dcbk086hhrn7y"]
[gd_scene load_steps=44 format=3 uid="uid://dcbk086hhrn7y"]
[ext_resource type="Script" path="res://scripts/charactercontroller.gd" id="1_6alft"]
[ext_resource type="Texture2D" uid="uid://brk4npndc5woq" path="res://assets/graphics/player/death/Player Death 64x64.png" id="2_hk34k"]
[ext_resource type="Texture2D" uid="uid://c8esv4rqrll0u" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_itql4"]
[ext_resource type="Texture2D" uid="uid://yqw4w6dfvdkw" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="3_3i7wk"]
[ext_resource type="Texture2D" uid="uid://cpksf8fvm4k26" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_fjlo4"]
[ext_resource type="Texture2D" uid="uid://lum1fe47ggoy" path="res://assets/graphics/player/run/player run 48x48.png" id="3_fp3hq"]
[sub_resource type="CircleShape2D" id="CircleShape2D_qrixx"]
[sub_resource type="AtlasTexture" id="AtlasTexture_nobr7"]
atlas = ExtResource("2_hk34k")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_uycsx"]
atlas = ExtResource("2_hk34k")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ytgcw"]
atlas = ExtResource("2_hk34k")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_60hx1"]
atlas = ExtResource("2_hk34k")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_podt1"]
atlas = ExtResource("2_hk34k")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_vlehs"]
atlas = ExtResource("2_hk34k")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_brhlx"]
atlas = ExtResource("2_hk34k")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_3ui1j"]
atlas = ExtResource("2_hk34k")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_kvxru"]
atlas = ExtResource("2_hk34k")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_uqe8x"]
atlas = ExtResource("2_hk34k")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_fva2s"]
atlas = ExtResource("3_3i7wk")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_crb4x"]
atlas = ExtResource("3_3i7wk")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_3g2wg"]
atlas = ExtResource("3_3i7wk")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_cacvb"]
atlas = ExtResource("3_3i7wk")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_xei83"]
atlas = ExtResource("2_itql4")
region = Rect2(0, 0, 48, 48)
@ -95,6 +153,58 @@ region = Rect2(336, 0, 48, 48)
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_nobr7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uycsx")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ytgcw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_60hx1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_podt1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vlehs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_brhlx")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3ui1j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kvxru")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uqe8x")
}],
"loop": false,
"name": &"death",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fva2s")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_crb4x")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3g2wg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_cacvb")
}],
"loop": false,
"name": &"hurt",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_xei83")
}, {
"duration": 1.0,
@ -199,5 +309,7 @@ offset = Vector2(0, -50)
texture_filter = 1
position = Vector2(0, -7)
sprite_frames = SubResource("SpriteFrames_yi1g3")
animation = &"run"
animation = &"death"
autoplay = "jump"
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]

View File

@ -0,0 +1,48 @@
[gd_scene load_steps=2 format=3 uid="uid://bissd2c653cg5"]
[ext_resource type="Script" path="res://scripts/ui.gd" id="1_1f4nb"]
[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_1f4nb")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 23.0
grow_horizontal = 2
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
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"]
layout_mode = 2
text = "HEALTH"
[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
text = "10"
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"]
layout_mode = 2
text = "COINS"
horizontal_alignment = 2

View File

@ -3,6 +3,7 @@ class_name Bullet extends Area2D
var speed = 700
signal hit
signal badguyHit(area)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -28,3 +29,10 @@ func _on_body_entered(body: Node2D) -> void:
print("Bullet hit sumtin")
if not body.is_in_group("player"):
hit.emit(self, body)
func _on_area_entered(area: Area2D) -> void:
print("Bullet hitting area")
if area.is_in_group("enemies"):
badguyHit.emit(area)

View File

@ -21,77 +21,104 @@ var pushLeftEnabled = false
var isJumping = false
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
isJumping = false
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
animation.play("jump")
isJumping = true
# Shove Attack
if Input.is_action_just_pressed("shove"):
if pushRightEnabled && faceLeft == false:
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 2 )
if pushLeftEnabled && faceLeft == true:
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 2 )
# Handle Shooting
if Input.is_action_just_pressed("shoot"):
if faceLeft == true:
var myBullet = %SceneManager.makeBullet(left_target.global_transform, -700)
#myBullet.transform = left_target.global_transform
#myBullet.setSpeed(-700)
if faceLeft == false:
var myBullet = %SceneManager.makeBullet(right_target.global_transform, 700)
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("left", "right")
if direction:
velocity.x = direction * SPEED
if direction <0:
if not isJumping:
animation.play("run")
faceLeft = true
animation.flip_h = true
if direction >0:
if not isJumping:
animation.play("run")
faceLeft = false
animation.flip_h = false
else:
if not isJumping:
animation.play("idle")
velocity.x = move_toward(velocity.x, 0, SPEED)
var living = true
var animPlaying = "idle"
move_and_slide()
if right_ray.is_colliding():
if not faceLeft:
var collider = right_ray.get_collider()
if collider is RigidBody2D:
pushTarget = collider
pushRightEnabled = true
else:
pushRightEnabled = false
signal deathAnimationComplete
func hurtPlayer(_amt):
if _amt < 100:
animPlaying = "hurt"
animation.play(animPlaying)
if left_ray.is_colliding():
if faceLeft:
var collider = left_ray.get_collider()
if collider is RigidBody2D:
pushTarget = collider
pushLeftEnabled = true
else:
pushLeftEnabled = false
for i in get_slide_collision_count():
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal() * BUMP_FORCE)
func killPlayer():
print("PC will kill player")
if living:
living = false
animPlaying = "death"
animation.play(animPlaying)
func _physics_process(delta: float) -> void:
if living and not animPlaying == "hurt":
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
isJumping = false
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
animation.play("jump")
isJumping = true
# Shove Attack
if Input.is_action_just_pressed("shove"):
if pushRightEnabled && faceLeft == false:
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 2 )
if pushLeftEnabled && faceLeft == true:
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 2 )
# Handle Shooting
if Input.is_action_just_pressed("shoot"):
if faceLeft == true:
var myBullet = %SceneManager.makeBullet(left_target.global_transform, -700)
#myBullet.transform = left_target.global_transform
#myBullet.setSpeed(-700)
if faceLeft == false:
var myBullet = %SceneManager.makeBullet(right_target.global_transform, 700)
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("left", "right")
if direction:
velocity.x = direction * SPEED
if direction <0:
if not isJumping:
animation.play("run")
faceLeft = true
animation.flip_h = true
if direction >0:
if not isJumping:
animation.play("run")
faceLeft = false
animation.flip_h = false
else:
if not isJumping:
animation.play("idle")
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
if right_ray.is_colliding():
if not faceLeft:
var collider = right_ray.get_collider()
if collider is RigidBody2D:
pushTarget = collider
pushRightEnabled = true
else:
pushRightEnabled = false
if left_ray.is_colliding():
if faceLeft:
var collider = left_ray.get_collider()
if collider is RigidBody2D:
pushTarget = collider
pushLeftEnabled = true
else:
pushLeftEnabled = false
for i in get_slide_collision_count():
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal() * BUMP_FORCE)
func _on_animation_finished() -> void:
if animPlaying == "hurt":
animPlaying = "idle"
if animPlaying=="death":
# emit death signal
deathAnimationComplete.emit()

View File

@ -13,12 +13,18 @@ var player:Resource
#level information
var levels = ["res://scenes/game.tscn","res://scenes/level2.tscn"]
var timers = [10, 15]
var timers = [20, 25]
var currentLevel = 0
#Signals from GC
signal destroyBox(body)
signal destroyBadguy(area)
signal levelComplete(levelToLoad)
signal playerHurt(amt)
signal playerDeath
signal tick(timeRemaining)
signal coinsUpdate(coinsCollected, coinsAvailable)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -34,21 +40,38 @@ func _ready() -> void:
timer.start()
func reset():
totalCoinsCollected = 0
player.health = player.starting_health
countdown = timers[currentLevel]
tick.emit.call_deferred(countdown)
coinsUpdate.emit.call_deferred(totalCoinsCollected, totalCoins)
playerHurt.emit.call_deferred(player.health)
func secondCounter():
countdown -=1
tick.emit(countdown)
if countdown <=0:
print("YOU LOSE")
levelComplete.emit(levels[currentLevel])
func coinCollected():
totalCoinsCollected += 1
coinsUpdate.emit(totalCoinsCollected, totalCoins)
print("GC knows coin collected")
func playerDamaged():
print("GC knows player taking damage")
player.health -= 20
print("Health remaining: "+str(player.health))
if player.health > 0:
playerHurt.emit(player.health)
else:
playerDeath.emit()
func bulletHitBadguy(area):
#decide what to do
#how many bad guys remaining
#send a signal
destroyBadguy.emit(area)
func bulletHit(body):
print("Game controller knows bullet hit something")
@ -72,3 +95,7 @@ func countCoins(value):
totalCoins = value
func countBadGuys(value):
totalBadGuys = value
func playerDead():
print("GC knows player death")
levelComplete.emit(levels[currentLevel])

View File

@ -3,6 +3,8 @@ extends Node
@onready var crates: Node2D = $"../crates"
@onready var coins: Node2D = $"../coins"
@onready var enemies: Node2D = $"../enemies"
@onready var player: CharacterBody2D = $"../CharacterBody2D"
@onready var ui: Control = $"../CanvasLayer/ui"
var bullet = preload("res://scenes/bullet.tscn")
var bulletArray:Array = []
@ -29,13 +31,24 @@ func _ready() -> void:
if obj.is_in_group("enemies"):
totalEnemies +=1
obj.playerDamage.connect(Gamecontroller.playerDamaged)
Gamecontroller.countBadGuys(totalEnemies)
Gamecontroller.countCoins(totalCoins)
Gamecontroller.countCrates(totalCrates)
# Player interactions
Gamecontroller.playerHurt.connect(player.hurtPlayer)
Gamecontroller.playerDeath.connect(player.killPlayer)
#Subscribe to vital events from GC
Gamecontroller.levelComplete.connect(changeLevel)
player.deathAnimationComplete.connect(Gamecontroller.playerDead)
#ui events
Gamecontroller.tick.connect(ui.timerUpdate)
Gamecontroller.playerHurt.connect(ui.healthUpdate)
Gamecontroller.playerDeath.connect(ui.healthGone)
Gamecontroller.coinsUpdate.connect(ui.coinsUpdate)
Gamecontroller.destroyBadguy.connect(killBadguy)
Gamecontroller.reset()
@ -52,6 +65,7 @@ func bulletFactory():
if bulletArray.size() < 4:
myBullet = bullet.instantiate()
myBullet.connect("hit", onBulletHit)
myBullet.connect("badguyHit", Gamecontroller.bulletHitBadguy)
owner.add_child(myBullet)
else:
myBullet = bulletArray.pop_back()
@ -65,6 +79,9 @@ func makeBullet(position, speed):
myBullet.transform = position
myBullet.setSpeed(speed)
return myBullet
func killBadguy(area):
area.queue_free()
func onBulletHit(bullet, body):
bullet.position = Vector2(-100,-100)

View File

@ -0,0 +1,18 @@
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 # Replace with function body.
func timerUpdate(timeRemaining):
timer.text=str(timeRemaining)
func healthUpdate(healthRemaining):
health.text="HEALTH "+str(healthRemaining)
func healthGone():
health.text="HEALTH 0"
func coinsUpdate(coinsCollectedTotal, coinsAvailableTotal):
coins.text = str(coinsCollectedTotal)+" of "+str(coinsAvailableTotal)