bullet hell, asteroid and reaction done,. i think ill drop space invaders , 40 minutes left
This commit is contained in:
parent
82652730f2
commit
c000461fd6
23 changed files with 377 additions and 23 deletions
|
|
@ -3,11 +3,40 @@ extends Node
|
|||
signal game_win
|
||||
signal game_lose
|
||||
|
||||
@export var asteroid_spawns : Array[Node2D]
|
||||
@export var win_progress : ProgressBar
|
||||
@export var win_time : float = 15
|
||||
var alive_time : float =0
|
||||
@export var spawn_time : float = 3
|
||||
@export var player : Node2D
|
||||
var timer : float
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
timer = spawn_time
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
win_progress.value = alive_time/win_time
|
||||
timer -= delta
|
||||
alive_time += delta
|
||||
if timer <0:
|
||||
spawn_new_asteroid()
|
||||
timer = spawn_time
|
||||
if alive_time >= win_time:
|
||||
print("Asteroid win")
|
||||
game_win.emit()
|
||||
|
||||
func spawn_new_asteroid():
|
||||
var newAsteroid : Node2D = load("res://games/asteroids/asteroid.tscn").instantiate()
|
||||
var randSpawn : int = randi_range(0,3)
|
||||
newAsteroid.global_position = asteroid_spawns[randSpawn].global_position
|
||||
newAsteroid.target_pos = player.global_position
|
||||
#newBullet.heading = -newBullet.global_position.normalized()
|
||||
get_parent().add_child(newAsteroid)
|
||||
|
||||
|
||||
func _on_area_2d_area_entered(area: Area2D) -> void:
|
||||
print("Asteroid lose")
|
||||
game_lose.emit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue