aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-30 10:59:34 +0000
committerfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-30 10:59:34 +0000
commit052fe9c0786d13252a53cb984f125273dac5a598 (patch)
tree4183fc32869b2603dc56813568a3ef6a9eb097c1
parentbb87759291786cba9378334ed88218e3bb155dbd (diff)
Further code cleanup
-rw-r--r--Bullet.gd3
-rw-r--r--Coin.gd8
-rw-r--r--CoinCount.gd18
-rw-r--r--Enemy.gd11
-rw-r--r--Global.gd14
-rw-r--r--HealthBar.gd9
-rw-r--r--Main.gd8
-rw-r--r--Player.gd4
-rw-r--r--Player.tscn2
-rw-r--r--project.godot2
10 files changed, 8 insertions, 71 deletions
diff --git a/Bullet.gd b/Bullet.gd
index b3f0b6a..a2941c6 100644
--- a/Bullet.gd
+++ b/Bullet.gd
@@ -26,6 +26,3 @@ func _physics_process(delta):
queue_free()
if position.x > screen_size.x or position.x < 0 or position.y > screen_size.y or position.y < 0:
queue_free()
-
-
-
diff --git a/Coin.gd b/Coin.gd
index fa5610e..2f5402d 100644
--- a/Coin.gd
+++ b/Coin.gd
@@ -1,12 +1,7 @@
extends StaticBody2D
-
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
var timer
-# Called when the node enters the scene tree for the first time.
func _ready():
timer = Timer.new()
get_parent().add_child(timer)
@@ -16,6 +11,3 @@ func _ready():
func _on_timer_timeout() -> void:
queue_free()
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-# if timer.stopp
diff --git a/CoinCount.gd b/CoinCount.gd
index fadd9ba..e826496 100644
--- a/CoinCount.gd
+++ b/CoinCount.gd
@@ -1,19 +1,7 @@
extends Label
-
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
-var score = 0
-
-
-# Called when the node enters the scene tree for the first time.
-func _ready():
- pass # Replace with function body.
+var coins = 0
func _on_coin_hit():
- score += 1
- self.text = str(score)
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-# pass
+ coins += 1
+ self.text = str(coins)
diff --git a/Enemy.gd b/Enemy.gd
index 46cb750..dd2395b 100644
--- a/Enemy.gd
+++ b/Enemy.gd
@@ -1,17 +1,6 @@
extends KinematicBody2D
-
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
-# var player = get_node("")
onready var globals = get_node("/root/Global")
-# Called when the node enters the scene tree for the first time.
-func _ready():
- pass # Replace with function body.
-
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
move_and_collide(global_position.direction_to(globals.playerPos).normalized() * 300 * delta)
diff --git a/Global.gd b/Global.gd
index 51a7a8e..c84fce0 100644
--- a/Global.gd
+++ b/Global.gd
@@ -1,17 +1,3 @@
extends Node
-
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
var playerPos
-
-
-# Called when the node enters the scene tree for the first time.
-func _ready():
- pass # Replace with function body.
-
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-# pass
diff --git a/HealthBar.gd b/HealthBar.gd
index e064039..3648c67 100644
--- a/HealthBar.gd
+++ b/HealthBar.gd
@@ -1,19 +1,10 @@
extends ProgressBar
-
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
signal player_dead
-# Called when the node enters the scene tree for the first time.
func _ready():
connect("player_dead", get_node("/root/Main/HUD/GameOver"), "_on_player_dead")
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-# pass
func _on_player_hit(delta):
value -= delta * 20
var styleBox = self.get("custom_styles/fg")
diff --git a/Main.gd b/Main.gd
index 813d22b..2a38832 100644
--- a/Main.gd
+++ b/Main.gd
@@ -3,20 +3,14 @@ extends Node2D
export(PackedScene) var enemy_scene
onready var globals = get_node("/root/Global")
-# Called when the node enters the scene tree for the first time.
func _ready():
randomize()
get_node("Player").connect("hit", get_node("HUD/HBoxContainer/HealthBar"), "_on_player_hit")
get_node("Player").connect("coin", get_node("HUD/HBoxContainer/CoinCount"), "_on_coin_hit")
get_node("Player").connect("coin", get_node("HUD/GameOver/GameOverCoinMessage/GameOverCoinCount"), "_on_coin_hit")
+ yield(get_tree().create_timer(15.0), "timeout")
$EnemySpawnTimer.start()
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-# pass
-
-
func _on_EnemySpawnTimer_timeout():
var enemy = enemy_scene.instance()
var spawn_loc = get_node("EnemySpawn/EnemySpawnLocation")
diff --git a/Player.gd b/Player.gd
index 9b5bbd6..9afd919 100644
--- a/Player.gd
+++ b/Player.gd
@@ -1,9 +1,9 @@
extends Area2D
-signal hit
+signal hit(duration)
signal coin
var screen_size
-export (int) var speed = 500
+var speed = 500
var spawn_object = load("res://Bullet.tscn")
var velocity = Vector2()
onready var globals = get_node("/root/Global")
diff --git a/Player.tscn b/Player.tscn
index 8491e22..7be19de 100644
--- a/Player.tscn
+++ b/Player.tscn
@@ -3,7 +3,7 @@
[ext_resource path="res://Player.gd" type="Script" id=1]
[ext_resource path="res://assets/htm_tex.png" type="Texture" id=2]
-[node name="Area2D" type="Area2D"]
+[node name="Player" type="Area2D"]
collision_mask = 3
script = ExtResource( 1 )
diff --git a/project.godot b/project.godot
index 579b7f0..632986b 100644
--- a/project.godot
+++ b/project.godot
@@ -10,7 +10,7 @@ config_version=4
[application]
-config/name="TowerDefence"
+config/name="LikKanShootdown"
run/main_scene="res://Main.tscn"
config/icon="res://icon.png"