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

@ -38,9 +38,9 @@ func _physics_process(delta):
if not nodes.empty():
var player = nodes[0]
var mouse_position = SceneManager.viewport.get_mouse_position() / SceneManager.viewport_container.rect_scale
mouse_position.x = clamp(mouse_position.x, 8.0, Game.resolution.x - 8.0)
mouse_position.y = clamp(mouse_position.y, 8.0, Game.resolution.y - 8.0)
var world_position = mouse_position + Game.current_sector * Game.resolution
mouse_position.x = clamp(mouse_position.x, 8.0, Game.RESOLUTION.x - 8.0)
mouse_position.y = clamp(mouse_position.y, 8.0, Game.RESOLUTION.y - 8.0)
var world_position = mouse_position + Game.current_sector * Game.RESOLUTION
player.position = world_position
# Game.get_map().get_node("Player").position = get_viewport().get_mouse_position()

View file

@ -1,5 +1,7 @@
extends Node
## difficulty levels
enum Difficulty {
SWEET, # slower enemies, infinite lives
SALTY, # normal enemies, infinite lives
@ -7,51 +9,57 @@ enum Difficulty {
PUNGENT, # faster enemies, 3 lives
}
enum Bonuses {
Collection_Bonus,
Time_Bonus,
Life_Bonus,
Perfect_Bonus
}
const DIFFICULTY_NAMES = ["Sweet","Salty","Spicy","Pungent"]
## resolution the game renders at
const RESOLUTION := Vector2(256,192)
const DIFFICULTY_NAMES := ["Sweet","Salty","Spicy","Pungent"]
var resolution = Vector2(256,192)
var current_sector = Vector2(0,0)
#Onreadys
#Collectibles
var keys = 0
var stars = [false,false,false,false,false]
var shards = 0
var arrows = 0
var score = 0
var final_score = 0
var high_score = 0
var bonuses = [0,0,0,0]
var lives = 2
var deaths = 0
var time = 0.0
#Objects
const block_text = preload("res://objects/hud/blocktext.tscn")
const pause_screen = preload("res://objects/hud/pause_screen.tscn")
#Game info
var respawn_point = Vector2(32,166) #Respawn point
var current_level = 0 #Current level being played
var current_file = 1 #Current save file
var shards_collected = [false,false,false,false,false,false,false,false,false,false]
var is_marathon_mode = false
#== collectibles ==#
var keys: int = 0 # collected keys
## which stars are collected
var stars_collected := [false,false,false,false,false]
var stars : int setget , _get_stars # total stars
## which stars are collected
var shards_collected := [false,false,false,false,false,false,false,false]
## how many shards collected
var shards: int setget , _get_shards # total shards
var arrows: int = 0 # current arrows
#== stats ==#
var lives: int = 2
var deaths: int = 0
var time: float = 0.0
#== score ==#
var score: int = 0
var collection_bonus: int = 0
var time_bonus: int = 0
var life_bonus: int = 0
var perfect_bonus: int = 0
var final_score: int = 0
#== state ==#
var current_sector := Vector2.ZERO
var respawn_point := Vector2(32,166)
var current_level: int = 0
var difficulty: int = Difficulty.SPICY setget _set_difficulty
var enemy_speed_factor: float = 1.0 # multiplier of enemy speed
var is_easy_mode = false # whether to do easy-specific behaviors
var easy_mode_speed_factor = 0.75 # DEPRECATED: speed enemies go in easy mode
var use_lives = false
var can_pause = true
var current_palette = "default"
var is_easy_mode: bool = false # whether to do easy-specific behaviors
var use_lives: bool = false
var can_pause: bool = true
var current_palette: String = "default"
func _ready():
pause_mode = Node.PAUSE_MODE_PROCESS
func _get_stars() -> int:
return stars_collected.count(true)
func _get_shards() -> int:
return shards_collected.count(true)
# stuff to change when setting difficulty
func _set_difficulty(value: int) -> void:
difficulty = value
@ -81,14 +89,50 @@ func instance_node(node:PackedScene,x:float,y:float,parent):
#Get position in sectors
func get_sector(pos):
return (pos / resolution).floor()
return (pos / RESOLUTION).floor()
#Return the current Map
func get_map():
return get_tree().get_nodes_in_group("map")[0]
## tally up scores
func tally_scores() -> void:
var map = get_map()
# collection bonus
if keys >= 50:
collection_bonus += 500
if keys >= 5:
collection_bonus += 500
# 100% collection
if keys >= 50 and shards >= 5:
collection_bonus += 250
shards_collected[5] = true
# 100% time bonus
if time < map.target_time_100:
time_bonus = max(2500 - 2500 * int(time / map.target_time_100), 0)
shards_collected[6] = true
else:
# any% time bonus
if time < map.target_time_any:
time_bonus = max(2500 - 2500 * int(time / map.target_time_any), 0)
shards_collected[6] = true
# life bonus
if deaths == 0:
life_bonus = 500
shards_collected[7] = true
elif deaths == 1:
life_bonus = 1500
# perfect bonus
if shards_collected[5] and shards_collected[6] and shards_collected[7]:
perfect_bonus += 1000
# final score
final_score = score + collection_bonus + time_bonus + life_bonus + perfect_bonus
Game.save()
#Go to new map
func change_map(map: PackedScene):
func change_map(map: PackedScene) -> void:
get_tree().paused = true
can_pause = false
Fade.fade_out(0.4)
@ -105,15 +149,21 @@ func change_map(map: PackedScene):
SceneManager.current_scene = map.instance()
#Clear data
func clear_collectibles():
score = 0
func clear_collectibles() -> void:
# collectibles
keys = 0
stars = [false,false,false,false,false]
shards = 0
shards_collected = [false,false,false,false,false,false,false,false,false,false]
stars_collected.fill(false)
shards_collected.fill(false)
arrows = 0
lives = 2
deaths = 0
# score
score = 0
collection_bonus = 0
time_bonus = 0
life_bonus = 0
perfect_bonus = 0
final_score = 0
#Save
func save():
@ -126,7 +176,7 @@ func save():
save_data.score_100 = max(save_data.score_100, final_score)
save_data.time_100 = min(save_data.time_100, time)
else:
save_data.score_any = max(save_data.score_100, final_score)
save_data.score_any = max(save_data.score_any, final_score)
save_data.time_any = min(save_data.time_any, time)
# set shards
@ -158,11 +208,10 @@ func timeify(input):
#Restart level
func restart_level():
if score > high_score: high_score = score
score = 0
keys = 0
stars = [false,false,false,false,false]
shards = 0
stars_collected.fill(false)
shards_collected.fill(false)
arrows = 0
lives = 2
Audio.ac_climb.stop()

View file

@ -1,4 +1,7 @@
extends Node2D
const PauseScreen := preload("res://objects/hud/pause_screen.tscn")
export var target_time_any = 0
export var target_time_100 = 0
export (AudioStream) var music
@ -16,12 +19,14 @@ func _ready():
Fade.connect("fade_finished", get_tree(), "set_pause", [false], CONNECT_ONESHOT)
Fade.connect("fade_finished", Game, "set", ["can_pause", true], CONNECT_ONESHOT)
Audio.play_music(music)
Game.time = 0.0
func _physics_process(delta):
Game.time += delta
if Debug.entry == false && Game.can_pause:
#Pause
if Input.is_action_just_pressed("pause") && !get_tree().paused:
var pause = Game.pause_screen.instance()
var pause = PauseScreen.instance()
if lore_entries != null && !lore_entries.empty():
var entry = lore_entries[randi() % lore_entries.size()]
pause.lore_entry = entry

View file

@ -1,6 +1,6 @@
extends "res://maps/map.gd"
var acab_shard_has_been_collected = false
var acab_shard_has_been_collected: bool = false
func _physics_process(delta):
._physics_process(delta)
@ -8,6 +8,5 @@ func _physics_process(delta):
if !acab_shard_has_been_collected:
Audio.play_shard_sound()
Game.score += 500
Game.shards += 1
Game.shards_collected[0] = true
acab_shard_has_been_collected = true

View file

@ -1,16 +1,28 @@
extends Node2D
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
onready var shards: Node2D = $Shards
onready var collection_bonus: Sprite = $Bonuses/CollectionBonus
onready var time_bonus: Sprite = $Bonuses/TimeBonus
onready var life_bonus: Sprite = $Bonuses/LifeBonus
onready var perfect_bonus: Sprite = $Bonuses/PerfectBonus
onready var final_score: Label = $FinalScore
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _ready() -> void:
# tween for sequencing
var tween = create_tween()
# fill in shard names
var level: LevelEntry = LevelData.levels[Game.current_level]
for i in 5:
var shard = shards.get_child(i)
shard.get_node("Title").text = level.shard_titles[i]
# shard collect animations
tween.tween_interval(0.5)
if Game.shards_collected[i]:
tween.tween_callback(shard, "collect")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _physics_process(delta: float) -> void:
if Input.is_action_just_released("ui_accept"):
Game.clear_collectibles()
SceneManager.change_scene(preload("res://menus/level_select_scholar.tscn").instance())

View file

@ -1,6 +1,5 @@
[gd_scene load_steps=25 format=2]
[gd_scene load_steps=17 format=2]
[ext_resource path="res://shaders/1px_border.gdshader" type="Shader" id=1]
[ext_resource path="res://shaders/ska_plane.gdshader" type="Shader" id=2]
[ext_resource path="res://graphics/collectibles/shard.png" type="Texture" id=3]
[ext_resource path="res://graphics/hud/results.png" type="Texture" id=4]
@ -11,8 +10,8 @@
[ext_resource path="res://ui/2ndpuberty_outline.tres" type="Material" id=9]
[ext_resource path="res://ui/theme.tres" type="Theme" id=10]
[ext_resource path="res://ui/arrow_figure_8.tres" type="Material" id=11]
[ext_resource path="res://menus/shard_results.tscn" type="PackedScene" id=12]
[ext_resource path="res://menus/results.gd" type="Script" id=13]
[ext_resource path="res://menus/results_icon.tscn" type="PackedScene" id=14]
[sub_resource type="ShaderMaterial" id=5]
shader = ExtResource( 2 )
@ -24,114 +23,10 @@ shader_param/cycle_speed = Vector2( 12, 0 )
shader_param/cycle_alternation = Vector2( 2, 0 )
shader_param/uv_transform = Transform2D( 1, 1, 0, 1, 0, 0 )
[sub_resource type="ShaderMaterial" id=6]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="ShaderMaterial" id=7]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="ShaderMaterial" id=8]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="Animation" id=9]
resource_name = "Collect"
step = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.375, 1 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( 1, 1 ), Vector2( 1.3, 1.3 ), Vector2( 1, 1 ), Vector2( 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("CollectedParticle:emitting")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
}
[sub_resource type="ShaderMaterial" id=10]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="Animation" id=11]
resource_name = "Collect"
step = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.375, 1 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( 1, 1 ), Vector2( 1.3, 1.3 ), Vector2( 1, 1 ), Vector2( 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("CollectedParticle:emitting")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
}
[sub_resource type="ShaderMaterial" id=12]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="Animation" id=13]
resource_name = "Collect"
step = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.375, 1 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( 1, 1 ), Vector2( 1.3, 1.3 ), Vector2( 1, 1 ), Vector2( 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("CollectedParticle:emitting")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
}
[sub_resource type="Gradient" id=2]
interpolation_mode = 2
offsets = PoolRealArray( 0, 0.734694, 1 )
colors = PoolColorArray( 0.576471, 0.980392, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 )
[sub_resource type="Animation" id=3]
resource_name = "New Anim"
@ -142,7 +37,7 @@ loop = true
resource_name = "results"
length = 50.0
tracks/0/type = "value"
tracks/0/path = NodePath("ShardSprites/ShardTitle1:visible")
tracks/0/path = NodePath("Shards/Shard1/Title:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
@ -154,7 +49,7 @@ tracks/0/keys = {
"values": [ false ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("ShardSprites/ShardTitle2:visible")
tracks/1/path = NodePath("Shards/Shard2/Title:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
@ -166,7 +61,7 @@ tracks/1/keys = {
"values": [ false ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("ShardSprites/ShardTitle3:visible")
tracks/2/path = NodePath("Shards/Shard3/Title:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
@ -178,7 +73,7 @@ tracks/2/keys = {
"values": [ false ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("ShardSprites/ShardTitle4:visible")
tracks/3/path = NodePath("Score:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
@ -190,7 +85,7 @@ tracks/3/keys = {
"values": [ false ]
}
tracks/4/type = "value"
tracks/4/path = NodePath("ShardSprites/ShardTitle5:visible")
tracks/4/path = NodePath("Bonuses/CollectionBonus/CollectionBonusText:visible")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/imported = false
@ -202,7 +97,7 @@ tracks/4/keys = {
"values": [ false ]
}
tracks/5/type = "value"
tracks/5/path = NodePath("Score:visible")
tracks/5/path = NodePath("Bonuses/TimeBonus/TimeBonusText:visible")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/imported = false
@ -214,7 +109,7 @@ tracks/5/keys = {
"values": [ false ]
}
tracks/6/type = "value"
tracks/6/path = NodePath("BonusSprites/CollectionBonusText:visible")
tracks/6/path = NodePath("Bonuses/LifeBonus/LifeBonusText:visible")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/imported = false
@ -226,7 +121,7 @@ tracks/6/keys = {
"values": [ false ]
}
tracks/7/type = "value"
tracks/7/path = NodePath("BonusSprites/TimeBonusText:visible")
tracks/7/path = NodePath("Bonuses/PerfectBonus/PerfectBonusText:visible")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/imported = false
@ -238,7 +133,7 @@ tracks/7/keys = {
"values": [ false ]
}
tracks/8/type = "value"
tracks/8/path = NodePath("BonusSprites/LifeBonusText:visible")
tracks/8/path = NodePath("FinalScore:visible")
tracks/8/interp = 1
tracks/8/loop_wrap = true
tracks/8/imported = false
@ -249,142 +144,186 @@ tracks/8/keys = {
"update": 1,
"values": [ false ]
}
tracks/9/type = "value"
tracks/9/path = NodePath("BonusSprites/PerfectBonusText:visible")
tracks/9/interp = 1
tracks/9/loop_wrap = true
tracks/9/imported = false
tracks/9/enabled = true
tracks/9/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ false ]
}
tracks/10/type = "value"
tracks/10/path = NodePath("Final Score:visible")
tracks/10/interp = 1
tracks/10/loop_wrap = true
tracks/10/imported = false
tracks/10/enabled = true
tracks/10/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ false ]
}
[node name="Results" type="Node2D"]
[node name="Results" type="Node"]
script = ExtResource( 13 )
[node name="ColorRect" type="ColorRect" parent="."]
[node name="Background" type="ColorRect" parent="."]
material = SubResource( 5 )
margin_right = 256.0
margin_bottom = 192.0
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_lock_": true
}
[node name="ShardSprites" type="Node2D" parent="."]
position = Vector2( 0, -10 )
[node name="Shards" type="Node2D" parent="."]
[node name="Empty1" type="Sprite" parent="ShardSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 6 )
position = Vector2( 24, 24 )
[node name="Shard1" parent="Shards" instance=ExtResource( 14 )]
position = Vector2( 24, 14 )
texture = ExtResource( 3 )
[node name="Empty2" type="Sprite" parent="ShardSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 6 )
position = Vector2( 24, 40 )
texture = ExtResource( 3 )
[node name="Empty3" type="Sprite" parent="ShardSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 6 )
position = Vector2( 24, 56 )
texture = ExtResource( 3 )
[node name="Empty4" type="Sprite" parent="ShardSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 6 )
position = Vector2( 24, 72 )
texture = ExtResource( 3 )
[node name="Empty5" type="Sprite" parent="ShardSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 6 )
position = Vector2( 24, 88 )
texture = ExtResource( 3 )
[node name="Shard" parent="ShardSprites" instance=ExtResource( 12 )]
position = Vector2( 23, 23 )
[node name="Shard2" parent="ShardSprites" instance=ExtResource( 12 )]
position = Vector2( 23, 39 )
[node name="Shard3" parent="ShardSprites" instance=ExtResource( 12 )]
position = Vector2( 23, 55 )
[node name="Shard4" parent="ShardSprites" instance=ExtResource( 12 )]
position = Vector2( 23, 71 )
[node name="Shard5" parent="ShardSprites" instance=ExtResource( 12 )]
position = Vector2( 23, 87 )
[node name="ShardTitle1" type="Label" parent="ShardSprites"]
visible = false
[node name="Title" type="Label" parent="Shards/Shard1"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 18.0
margin_right = 200.0
margin_bottom = 32.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "AAAAAAAAAAAAAAAAAAAAAAAA"
[node name="ShardTitle2" type="Label" parent="ShardSprites"]
visible = false
[node name="CollectedParticles" type="CPUParticles2D" parent="Shards/Shard1"]
pause_mode = 2
emitting = false
amount = 64
one_shot = true
explosiveness = 1.0
local_coords = false
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 150 )
initial_velocity = 250.0
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount_random = 1.0
color_ramp = SubResource( 2 )
[node name="Shard2" parent="Shards" instance=ExtResource( 14 )]
position = Vector2( 24, 30 )
texture = ExtResource( 3 )
[node name="Title" type="Label" parent="Shards/Shard2"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 34.0
margin_right = 200.0
margin_bottom = 48.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "AAAAAAAAAAAAAAAAAAAAAAAA"
[node name="ShardTitle3" type="Label" parent="ShardSprites"]
visible = false
[node name="CollectedParticles" type="CPUParticles2D" parent="Shards/Shard2"]
pause_mode = 2
emitting = false
amount = 64
one_shot = true
explosiveness = 1.0
local_coords = false
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 150 )
initial_velocity = 250.0
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount_random = 1.0
color_ramp = SubResource( 2 )
[node name="Shard3" parent="Shards" instance=ExtResource( 14 )]
position = Vector2( 24, 46 )
texture = ExtResource( 3 )
[node name="Title" type="Label" parent="Shards/Shard3"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 50.0
margin_right = 200.0
margin_bottom = 64.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "AAAAAAAAAAAAAAAAAAAAAAAA"
[node name="ShardTitle4" type="Label" parent="ShardSprites"]
visible = false
[node name="CollectedParticle" type="CPUParticles2D" parent="Shards/Shard3"]
pause_mode = 2
emitting = false
amount = 64
one_shot = true
explosiveness = 1.0
local_coords = false
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 150 )
initial_velocity = 250.0
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount_random = 1.0
color_ramp = SubResource( 2 )
[node name="Shard4" parent="Shards" instance=ExtResource( 14 )]
position = Vector2( 24, 62 )
texture = ExtResource( 3 )
[node name="Title" type="Label" parent="Shards/Shard4"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 66.0
margin_right = 200.0
margin_bottom = 80.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "AAAAAAAAAAAAAAAAAAAAAAAA"
[node name="ShardTitle5" type="Label" parent="ShardSprites"]
visible = false
[node name="CollectedParticle" type="CPUParticles2D" parent="Shards/Shard4"]
pause_mode = 2
emitting = false
amount = 64
one_shot = true
explosiveness = 1.0
local_coords = false
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 150 )
initial_velocity = 250.0
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount_random = 1.0
color_ramp = SubResource( 2 )
[node name="Shard5" parent="Shards" instance=ExtResource( 14 )]
position = Vector2( 24, 78 )
texture = ExtResource( 3 )
[node name="Title" type="Label" parent="Shards/Shard5"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 82.0
margin_right = 200.0
margin_bottom = 96.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "AAAAAAAAAAAAAAAAAAAAAAAA"
[node name="CollectedParticle" type="CPUParticles2D" parent="Shards/Shard5"]
pause_mode = 2
emitting = false
amount = 64
one_shot = true
explosiveness = 1.0
local_coords = false
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 150 )
initial_velocity = 250.0
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount_random = 1.0
color_ramp = SubResource( 2 )
[node name="Score" type="Label" parent="."]
visible = false
material = ExtResource( 9 )
margin_top = 93.0
margin_right = 256.0
@ -393,112 +332,62 @@ theme = ExtResource( 10 )
text = "Score: 0000000"
align = 1
[node name="BonusSprites" type="Node2D" parent="."]
[node name="Bonuses" type="Node2D" parent="."]
position = Vector2( 0, 6 )
[node name="CollectionBonusEmpty" type="Sprite" parent="BonusSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 7 )
[node name="CollectionBonus" parent="Bonuses" instance=ExtResource( 14 )]
position = Vector2( 24, 112 )
texture = ExtResource( 7 )
[node name="CollectionBonus" parent="BonusSprites" instance=ExtResource( 12 )]
position = Vector2( 24, 112 )
[node name="Sprite" parent="BonusSprites/CollectionBonus" index="0"]
position = Vector2( 0, 0 )
texture = ExtResource( 7 )
[node name="CollectionBonusText" type="Label" parent="BonusSprites"]
visible = false
[node name="CollectionBonusText" type="Label" parent="Bonuses/CollectionBonus"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 106.0
margin_right = 200.0
margin_bottom = 120.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "Collection Bonus"
[node name="TimeBonusEmpty" type="Sprite" parent="BonusSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 8 )
[node name="TimeBonus" parent="Bonuses" instance=ExtResource( 14 )]
position = Vector2( 24, 128 )
texture = ExtResource( 8 )
[node name="TimeBonus" parent="BonusSprites" instance=ExtResource( 12 )]
position = Vector2( 24, 128 )
[node name="Sprite" parent="BonusSprites/TimeBonus" index="0"]
position = Vector2( 0, 0 )
texture = ExtResource( 8 )
[node name="AnimationPlayer" parent="BonusSprites/TimeBonus" index="1"]
anims/Collect = SubResource( 9 )
[node name="TimeBonusText" type="Label" parent="BonusSprites"]
visible = false
[node name="TimeBonusText" type="Label" parent="Bonuses/TimeBonus"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 122.0
margin_right = 200.0
margin_bottom = 136.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "Time Bonus"
[node name="LifeBonusEmpty" type="Sprite" parent="BonusSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 10 )
[node name="LifeBonus" parent="Bonuses" instance=ExtResource( 14 )]
position = Vector2( 24, 144 )
texture = ExtResource( 6 )
[node name="LifeBonus" parent="BonusSprites" instance=ExtResource( 12 )]
position = Vector2( 24, 144 )
[node name="Sprite" parent="BonusSprites/LifeBonus" index="0"]
position = Vector2( 0, 0 )
texture = ExtResource( 6 )
[node name="AnimationPlayer" parent="BonusSprites/LifeBonus" index="1"]
anims/Collect = SubResource( 11 )
[node name="LifeBonusText" type="Label" parent="BonusSprites"]
visible = false
[node name="LifeBonusText" type="Label" parent="Bonuses/LifeBonus"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 138.0
margin_right = 200.0
margin_bottom = 152.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "Life Bonus"
[node name="PerfectBonusEmpty" type="Sprite" parent="BonusSprites"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 12 )
[node name="PerfectBonus" parent="Bonuses" instance=ExtResource( 14 )]
position = Vector2( 24, 160 )
texture = ExtResource( 5 )
[node name="PerfectBonus" parent="BonusSprites" instance=ExtResource( 12 )]
position = Vector2( 24, 160 )
[node name="Sprite" parent="BonusSprites/PerfectBonus" index="0"]
position = Vector2( 0, 0 )
texture = ExtResource( 5 )
[node name="AnimationPlayer" parent="BonusSprites/PerfectBonus" index="1"]
anims/Collect = SubResource( 13 )
[node name="PerfectBonusText" type="Label" parent="BonusSprites"]
visible = false
[node name="PerfectBonusText" type="Label" parent="Bonuses/PerfectBonus"]
material = ExtResource( 9 )
margin_left = 32.0
margin_top = 154.0
margin_right = 200.0
margin_bottom = 168.0
margin_left = 8.0
margin_top = -6.0
margin_right = 176.0
margin_bottom = 8.0
theme = ExtResource( 10 )
text = "Perfect Bonus"
[node name="Final Score" type="Label" parent="."]
visible = false
[node name="FinalScore" type="Label" parent="."]
material = ExtResource( 9 )
margin_top = 178.0
margin_right = 256.0
@ -507,18 +396,12 @@ theme = ExtResource( 10 )
text = "Final score: 123456789"
align = 1
[node name="Results" type="Sprite" parent="."]
material = ExtResource( 11 )
position = Vector2( 232, 80 )
texture = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "New Anim"
"anims/New Anim" = SubResource( 3 )
anims/results = SubResource( 4 )
[node name="Results" type="Sprite" parent="."]
material = ExtResource( 11 )
position = Vector2( 232, 80 )
scale = Vector2( 1, 0.679105 )
texture = ExtResource( 4 )
[editable path="BonusSprites/CollectionBonus"]
[editable path="BonusSprites/TimeBonus"]
[editable path="BonusSprites/LifeBonus"]
[editable path="BonusSprites/PerfectBonus"]

16
menus/results_icon.gd Normal file
View file

@ -0,0 +1,16 @@
extends Sprite
onready var filled_sprite = $FilledSprite
onready var animation_player = $AnimationPlayer
func _ready() -> void:
filled_sprite.texture = texture
func collect() -> void:
animation_player.play("collect")
for child in get_children():
if child is CPUParticles2D:
child.emitting = true

37
menus/results_icon.tscn Normal file
View file

@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://shaders/1px_border.gdshader" type="Shader" id=1]
[ext_resource path="res://menus/results_icon.gd" type="Script" id=3]
[sub_resource type="ShaderMaterial" id=4]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="Animation" id=3]
resource_name = "collect"
step = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("FilledSprite:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.375, 1 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( 1, 1 ), Vector2( 1.3, 1.3 ), Vector2( 1, 1 ), Vector2( 1, 1 ) ]
}
[node name="ResultsIcon" type="Sprite"]
self_modulate = Color( 0, 0, 0, 1 )
material = SubResource( 4 )
script = ExtResource( 3 )
[node name="FilledSprite" type="Sprite" parent="."]
use_parent_material = true
scale = Vector2( 1e-05, 1e-05 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/collect = SubResource( 3 )

View file

@ -1,7 +1,6 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://shaders/1px_border.gdshader" type="Shader" id=1]
[ext_resource path="res://objects/player/player_death_particles.tscn" type="PackedScene" id=2]
[ext_resource path="res://graphics/collectibles/shard.png" type="Texture" id=3]
[sub_resource type="ShaderMaterial" id=1]
@ -70,11 +69,11 @@ offsets = PoolRealArray( 0, 0.734694, 1 )
colors = PoolColorArray( 0.576471, 0.980392, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 )
[node name="Shard" type="Node2D"]
visible = false
[node name="Sprite" type="Sprite" parent="."]
material = SubResource( 1 )
position = Vector2( 1, 1 )
scale = Vector2( 1e-05, 1e-05 )
texture = ExtResource( 3 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
@ -82,13 +81,22 @@ autoplay = "Miss"
anims/Collect = SubResource( 3 )
anims/Miss = SubResource( 4 )
[node name="CollectedParticle" parent="." instance=ExtResource( 2 )]
[node name="CollectedParticle" type="CPUParticles2D" parent="."]
pause_mode = 2
emitting = false
amount = 64
lifetime = 1.0
one_shot = true
explosiveness = 1.0
texture = null
local_coords = false
emission_shape = 2
emission_rect_extents = Vector2( 4, 4 )
direction = Vector2( 0, -1 )
spread = 180.0
gravity = Vector2( 0, 150 )
initial_velocity = 250.0
scale_amount = 1.0
scale_amount_curve = null
initial_velocity_random = 0.9
damping = 2.0
angle = 720.0
angle_random = 1.0
scale_amount_random = 1.0
color_ramp = SubResource( 2 )

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