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

@ -18,12 +18,12 @@ func _process(delta):
else:
var current_sector = Game.get_sector(player.global_position + Vector2(0.0, 1.0))
if scroll_h && current_sector.x != last_sector.x:
position.x = current_sector.x * Game.resolution.x
position.x = current_sector.x * Game.RESOLUTION.x
if respawn_h:
var offset = Vector2(8.0 * sign(current_sector.x - last_sector.x), 0.0)
Game.respawn_point = player.global_position
last_sector.x = current_sector.x
if scroll_v && current_sector.y != last_sector.y:
position.y = current_sector.y * Game.resolution.y
position.y = current_sector.y * Game.RESOLUTION.y
last_sector.y = current_sector.y
Game.current_sector = last_sector

View file

@ -16,6 +16,5 @@ func _on_Area2D_body_entered(body):
emit_signal("collected",number)
Audio.play_shard_sound()
Game.score += 500
Game.shards += 1
Game.shards_collected[number] = true
queue_free()

View file

@ -31,11 +31,10 @@ func _on_Area2D_body_entered(body):
if body.is_in_group("player"):
Audio.play_sound(Audio.a_star,Audio.ac_collectible)
Game.score += 100
Game.stars[color] = true
Game.stars_collected[color] = true
#5 Star reward
if Game.stars[0] && Game.stars[1] && Game.stars[2] && Game.stars[3] && Game.stars[4]:
if Game.stars == 5:
Audio.play_shard_sound()
Game.shards += 1
Game.shards_collected[4] = true
Game.score += 500
queue_free()

View file

@ -40,7 +40,7 @@ func _physics_process(delta: float) -> void:
velocity.y = speed
global_position += velocity * delta
var sector_rect = Rect2(home_sector * Game.resolution, Game.resolution)
var sector_rect = Rect2(home_sector * Game.RESOLUTION, Game.RESOLUTION)
# disable hitbox at edge of screen
var global_hitbox_clip = hitbox_clip
@ -74,7 +74,7 @@ func _physics_process(delta: float) -> void:
# clip to inside of home sector
var rid = get_canvas_item()
var rect = Rect2(to_local(home_sector * Game.resolution), Game.resolution)
var rect = Rect2(to_local(home_sector * Game.RESOLUTION), Game.RESOLUTION)
VisualServer.canvas_item_set_custom_rect(rid, true, rect)
VisualServer.canvas_item_set_clip(rid, true)

View file

@ -16,34 +16,6 @@ func _physics_process(delta):
func _on_Area2D_area_entered(area):
if area.is_in_group("player_hitbox"):
#BONUSES
Game.final_score = Game.score
Game.bonuses = [0,0,0,0]
#Collection bonus
if Game.keys == 50: Game.Bonuses.Collection_Bonus += 500
if Game.shards == 5: Game.Bonuses.Collection_Bonus += 500
if Game.keys == 50 && Game.shards == 5:
Game.Bonuses.Collection_Bonus += 250
Game.shards_collected[5] = true
#Time bonus
if Game.keys == 50 && Game.shards == 5:
if Game.time < map.target_time_100:
Game.Bonuses.Time_Bonus += max(2500 - 2500 * int(Game.time / map.target_time_100), 0)
Game.shards_collected[6] = true
else:
if Game.time < map.target_time_any:
Game.Bonuses.Time_Bonus += max(2500 - 2500 * int(Game.time / map.target_time_any), 0)
Game.shards_collected[6] = true
#Life bonus
if Game.lives == 1: Game.Bonuses.Life_Bonus += 500
if Game.lives == 2:
Game.Bonuses.Life_Bonus += 1500
Game.shards_collected[7] = true
#Perfect bonus
if Game.lives == 2 && Game.keys == 50 && Game.shards == 5 && Game.time < map.target_time_100:
Game.Bonuses.Perfect_Bonus += 1000
for bonus in Game.bonuses:
Game.final_score += bonus
if Game.final_score > Game.high_final_score: Game.high_final_score = Game.final_score
Game.save()
Game.change_map(load("res://maps/level_select.tscn"))
Game.tally_scores()
SceneManager.change_scene(preload("res://menus/results.tscn").instance())
# Game.change_map(load("res://maps/level_select.tscn"))

View file

@ -54,11 +54,11 @@ func _physics_process(delta):
#Shard Counter
shard_counter.text = str(Game.shards)
#Star Counter
red_star.visible = Game.stars[0]
yellow_star.visible = Game.stars[1]
green_star.visible = Game.stars[2]
blue_star.visible = Game.stars[3]
magenta_star.visible = Game.stars[4]
red_star.visible = Game.stars_collected[0]
yellow_star.visible = Game.stars_collected[1]
green_star.visible = Game.stars_collected[2]
blue_star.visible = Game.stars_collected[3]
magenta_star.visible = Game.stars_collected[4]
#Score Counter
score_counter.text = "%05d" % Game.score
#Arrow Counter
@ -74,8 +74,6 @@ func _physics_process(delta):
lives_counter.modulate = bonus_color
else:
lives_counter.modulate = Color.white
#High counter
high_counter.text = str("HIGH:") + str("%06d" % Game.high_score)
##Timer
Game.time += delta
time_counter.text = Game.timeify(Game.time)

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():