game.gd cleaning and partial results screen implementation

This commit is contained in:
Haze Weathers 2023-09-10 19:28:42 -04:00
parent b126484109
commit e2b3db0b93
16 changed files with 425 additions and 436 deletions

View file

@ -1,22 +1,30 @@
extends Node2D
# "block" graphic
const BlockText := preload("res://objects/hud/blocktext.tscn")
# speed to fly at
export var speed = 240.0
export var speed: float = 240.0
# group to kill
export var target_group = "enemy_hitbox"
export var target_group: String = "enemy_hitbox"
# direction to fly
export var direction = 1.0
export var direction: float = 1.0
# whether or not it frees on wall collision
export var breaks_on_wall = true
export var breaks_on_wall: float = true
#Edge to check culling, if this edge is offscreen, delete the arrow
onready var cull_edge = Vector2(5 * direction,0)
onready var initial_sector = Game.current_sector
onready var cull_edge := Vector2(5.0 * direction, 0.0)
onready var initial_sector: Vector2 = Game.current_sector
func _ready():
#Flip depending on direction
scale.x = direction
func _physics_process(delta):
#Move in right direction
position.x += speed * direction * delta
@ -25,6 +33,7 @@ func _physics_process(delta):
_persist_trail()
queue_free()
#Wall Collision
func _on_Hitbox_body_entered(body):
if breaks_on_wall:
@ -33,6 +42,7 @@ func _on_Hitbox_body_entered(body):
_persist_trail()
queue_free()
# kill entity if in target group
func _on_Hitbox_area_entered(area):
# block if collided area is in "blocks_arrow" group
@ -41,7 +51,7 @@ func _on_Hitbox_area_entered(area):
# create block text and return if blocked
if area.is_in_group("blocks_arrow"):
var pos = target.global_position
Game.instance_node(Game.block_text, pos.x, pos.y, target.get_parent())
Game.instance_node(BlockText, pos.x, pos.y, target.get_parent())
_make_sparks()
else:
# kill targeted node
@ -56,6 +66,7 @@ func _on_Hitbox_area_entered(area):
_persist_trail()
queue_free()
func _persist_trail():
# don't do this twice to prevent crash
if not is_queued_for_deletion():
@ -68,6 +79,7 @@ func _persist_trail():
# free particles once they have gone through their lifetime
get_tree().create_timer(particles.lifetime, false).connect("timeout", particles, "queue_free")
func _make_sparks():
# don't do this twice to prevent crash
if not is_queued_for_deletion():