fix most of the script errors and warnings, fixed a couple tiny bugs in the process :)

This commit is contained in:
Haze Weathers 2024-03-08 15:11:48 -05:00
parent 9435089f21
commit 72733db609
23 changed files with 55 additions and 63 deletions

View file

@ -22,15 +22,15 @@ func _init() -> void:
func get_key(action: String) -> int:
var scancode = cfg.get_value(action, "keyboard")
if scancode == null:
var scancode = cfg.get_value(action, "keyboard", -1)
if scancode == -1:
scancode = _get_default_key(action)
return scancode
func get_button(action: String) -> int:
var button_index = cfg.get_value(action, "gamepad")
if button_index == null:
var button_index = cfg.get_value(action, "gamepad", -1)
if button_index == -1:
button_index = _get_default_button(action)
return button_index
@ -58,8 +58,8 @@ func _apply_saved_bindings() -> void:
func _configure_action_key(action: String) -> void:
var scancode = cfg.get_value(action, "keyboard")
if scancode == null:
var scancode = cfg.get_value(action, "keyboard", -1)
if scancode == -1:
scancode = _get_default_key(action)
_apply_action_key(action, scancode)
var linked_action = LINKED_ACTIONS.get(action)
@ -68,8 +68,8 @@ func _configure_action_key(action: String) -> void:
func _configure_action_button(action: String) -> void:
var button_index = cfg.get_value(action, "gamepad")
if button_index == null:
var button_index = cfg.get_value(action, "gamepad", -1)
if button_index == -1:
button_index = _get_default_button(action)
_apply_action_button(action, button_index)
var linked_action = LINKED_ACTIONS.get(action)

View file

@ -95,7 +95,7 @@ func _set_difficulty(value: int) -> void:
func instance_node(node:PackedScene,x:float,y:float,parent):
var Instance = node.instance()
Instance.global_position = Vector2(x,y)
parent.add_child(Instance)
parent.call_deferred("add_child", Instance)
#Get position in sectors
func get_sector(pos):
@ -122,12 +122,12 @@ func tally_scores() -> void:
shards_collected[5] = true
# 100% time bonus
if time < map.target_time_100:
time_bonus = max(2500 - int(2500.0 * time / map.target_time_100), 0)
time_bonus = max(2500 - int(2500.0 * time / map.target_time_100), 0) as int
shards_collected[6] = true
else:
# any% time bonus
if time < map.target_time_any:
time_bonus = max(2500 - int(2500.0 * time / map.target_time_any), 0)
time_bonus = max(2500 - int(2500.0 * time / map.target_time_any), 0) as int
shards_collected[6] = true
# life bonus
if deaths == 0:
@ -195,10 +195,10 @@ func save():
# save score and time depending on completion
if _get_shards() >= 5 && keys >= 50:
save_data.score_100 = max(save_data.score_100, final_score)
save_data.score_100 = max(save_data.score_100, final_score) as int
save_data.time_100 = min(save_data.time_100, time)
else:
save_data.score_any = max(save_data.score_any, final_score)
save_data.score_any = max(save_data.score_any, final_score) as int
save_data.time_any = min(save_data.time_any, time)
# set shards
@ -207,7 +207,7 @@ func save():
save_data.shards_collected[i] = true
# set keys
save_data.keys_collected = max(save_data.keys_collected, keys)
save_data.keys_collected = max(save_data.keys_collected, keys) as int
# mark as completed
save_data.completed = true
@ -272,9 +272,9 @@ func restart_level():
Audio.ac_music.stream_paused = false
#Freeze frame
func freeze_frame(time):
func freeze_frame(freeze_time):
get_tree().paused = true
var timer = get_tree().create_timer(time, true)
var timer = get_tree().create_timer(freeze_time, true)
timer.connect("timeout", get_tree(), "set_pause", [false])
return timer
@ -321,6 +321,6 @@ func _on_player_died() -> void:
Audio.play_sound(Audio.a_die, Audio.ac_die)
# death score penalty
if use_lives == false && lives < 0:
score = max(0, score - 500)
score = max(0, score - 500) as int
# freezeframe
Game.freeze_frame(0.3)

View file

@ -174,6 +174,8 @@ func request_execute(component: String, parameters: Dictionary = {}, echo: Strin
var body = "input=" + to_json(request).percent_encode()
# make request
var err = http.request(GATEWAY_URI, headers, true, HTTPClient.METHOD_POST, body)
if err != OK:
push_error("Invalid HTTP request")
# yield response
yield(http, "request_completed")
return _response

View file

@ -4,6 +4,10 @@ extends Light2D
onready var viewport: Viewport = $Viewport
func _ready() -> void:
texture = viewport.get_texture()
func _process(delta: float) -> void:
var main_viewport = get_viewport()
if viewport.canvas_transform != main_viewport.canvas_transform:

View file

@ -1,12 +1,8 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://autoloads/stain_layer.gd" type="Script" id=1]
[sub_resource type="ViewportTexture" id=1]
viewport_path = NodePath("Viewport")
[node name="StainLight" type="Light2D" groups=["viewport_autoload"]]
texture = SubResource( 1 )
offset = Vector2( 128, 96 )
mode = 2
range_item_cull_mask = 2

View file

@ -373,9 +373,6 @@ speed = 50.0
position = Vector2( 48, 1472 )
curve = SubResource( 14 )
[node name="Eel5" parent="Enemies/Eels" instance=ExtResource( 18 )]
position = Vector2( 272, 576 )
[node name="Eel6" parent="Enemies/Eels" instance=ExtResource( 18 )]
position = Vector2( 176, 240 )
curve = SubResource( 16 )

View file

@ -126,3 +126,4 @@ explosiveness = 1.0
randomness = 0.34
initial_velocity = 100.0
scale_amount = 2.0
spray_ammount = 0

View file

@ -69,7 +69,6 @@ func _process(delta: float) -> void:
if selected_level + 1 < LevelData.levels.size():
var save := Save.current_file
var level: LevelEntry = LevelData.levels[selected_level + 1]
var shards := save.get_total_shards()
if save.get_total_shards() < level.shards_required:
forward_arrow.visible = false
boss_block.visible = false
@ -144,7 +143,6 @@ func _select_level(level_id: int) -> void:
func _can_travel(index: int) -> bool:
var save := Save.current_file
var level: LevelEntry = LevelData.levels[index]
var shards := save.get_total_shards()
if save.get_total_shards() < level.shards_required:
return false
if level.boss_required != "":

View file

@ -16,8 +16,7 @@ func _ready():
$Panel/FileSelect.grab_focus()
if Game.last_mm_button != null:
get_node(Game.last_mm_button).grab_focus()
Vector2( 0.83205, 0.5547 )
func _on_Continue_button_down():
Game.last_mm_button = "Panel/Continue"

View file

@ -7,7 +7,6 @@ const LevelSelect := preload("res://menus/level_select_scholar.tscn")
onready var shards: Node2D = $ShardsAndBonuses/Shards
onready var score = $Score
onready var time = $Time
onready var final_score: Label = $FinalScore
onready var animation_player = $AnimationPlayer
#Score bonuses
onready var collection_bonus_score = $ShardsAndBonuses/Bonuses/CollectionBonus/CollectionBonusScore
@ -54,7 +53,7 @@ func _physics_process(delta: float) -> void:
animation_player.set_speed_scale(4)
func final_score():
func show_final_score():
animation_player.set_speed_scale(2)
text_3d.animation_player.set_speed_scale(1)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=2]
[gd_scene load_steps=19 format=2]
[ext_resource path="res://shaders/wibble_wobble.gdshader" type="Shader" id=1]
[ext_resource path="res://shaders/ska_plane.gdshader" type="Shader" id=2]
@ -40,11 +40,6 @@ shader_param/ammount = Vector2( 9, 8 )
shader_param/offset = Vector2( 0, 0 )
shader_param/delay = Vector2( 0, 0 )
[sub_resource type="Animation" id=3]
resource_name = "New Anim"
length = 2.0
loop = true
[sub_resource type="Animation" id=10]
length = 0.001
tracks/0/type = "value"
@ -319,7 +314,7 @@ tracks/14/keys = {
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "final_score"
"method": "show_final_score"
} ]
}
@ -556,7 +551,6 @@ texture = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "results"
playback_speed = 2.0
"anims/New Anim" = SubResource( 3 )
anims/RESET = SubResource( 10 )
anims/results = SubResource( 4 )

View file

@ -27,7 +27,8 @@ func _process(delta):
if scroll_h && current_sector.x != last_sector.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)
# TODO: decide whether to use offset with horizontal respawn
# 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:

View file

@ -22,8 +22,8 @@ func _ready():
#Change color
_set_color(color)
func _set_color(value):
color = value
func _set_color(new_color):
color = new_color
if is_inside_tree():
sprite.material.set_shader_param("palette", COLORS[color])
$Sparkles.color = particle_colors[color]

View file

@ -88,15 +88,9 @@ autostart = true
[node name="Position2D" type="Position2D" parent="."]
position = Vector2( 14, 29 )
[node name="ArrowSpawnTimer" type="Timer" parent="."]
wait_time = 5.0
one_shot = true
autostart = true
[node name="Sprite" type="AnimatedSprite" parent="."]
position = Vector2( 26, 27 )
frames = SubResource( 5 )
frame = 1
playing = true
[node name="BloodPosition" type="Position2D" parent="."]
@ -114,4 +108,3 @@ volume_db = -8.0
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
[connection signal="timeout" from="ShootTimer" to="." method="_on_ShootTimer_timeout"]
[connection signal="timeout" from="ArrowSpawnTimer" to="." method="_on_ArrowSpawnTimer_timeout"]

View file

@ -111,6 +111,7 @@ func hurt(amount: float, can_duck: bool = false) -> void:
emit_signal("health_changed", hp)
if state != State.DEAD and hp <= 0.0:
state = State.DEAD
emit_signal("died")
anims.play("die")

View file

@ -6,9 +6,13 @@ const BloodSpray := preload("res://objects/environment/blood/blood_spray.tscn")
export var spray_ammount: int = 16
export var spray_velocity: float = 80
export var autoplay: bool = false
func _ready() -> void:
if autoplay:
emitting = true
yield(get_tree(), "idle_frame")
for i in spray_ammount:
var spray = BloodSpray.instance()
spray.global_position = global_position

View file

@ -43,7 +43,7 @@ func die():
bone.global_position = global_position
bone.linear_velocity = Vector2(bones_speed * rand_range(0.5, 1.5), 0.0).rotated(rand_range(-PI, 0.0))
bone.angular_velocity = rand_range(-PI*2.0, PI*2.0)
var timer = get_tree().create_timer(3.0 + rand_range(0.0, 1.0), false)
timer.connect("timeout", bone, "queue_free")
var bone_timer = get_tree().create_timer(3.0 + rand_range(0.0, 1.0), false)
bone_timer.connect("timeout", bone, "queue_free")
get_parent().call_deferred("add_child", bone)
.die() # call rest of enemy.gd die() funciton

View file

@ -101,7 +101,7 @@ func die() -> void:
# reset animation
sprite.frame_coords.y = 3
Audio.play_sound(death_sound, Audio.ac_die)
$"%DeathSplatter".emitting = true
$"%DeathSplatter".replace_by_instance()
func _draw() -> void:
if Engine.editor_hint:

View file

@ -1,8 +1,7 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://graphics/enemy/turtle.png" type="Texture" id=1]
[ext_resource path="res://objects/enemy/turtle.gd" type="Script" id=2]
[ext_resource path="res://objects/enemy/death_particles.tscn" type="PackedScene" id=3]
[ext_resource path="res://shaders/1px_border.gdshader" type="Shader" id=4]
[sub_resource type="ShaderMaterial" id=6]
@ -82,8 +81,9 @@ position = Vector2( 8.5, 4 )
position = Vector2( 11, -0.5 )
shape = SubResource( 3 )
[node name="DeathSplatter" parent="HeadHitbox/HeadShape" instance=ExtResource( 3 )]
[node name="DeathSplatter" parent="HeadHitbox/HeadShape" instance_placeholder="res://objects/enemy/death_particles.tscn"]
unique_name_in_owner = true
autoplay = true
[node name="SpikeHitbox" type="Area2D" parent="."]
@ -94,6 +94,8 @@ shape = SubResource( 5 )
disabled = true
[node name="Platform" type="KinematicBody2D" parent="SpikeHitbox"]
collision_layer = 4
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="SpikeHitbox/Platform"]
position = Vector2( 8.5, 3 )

View file

@ -6,17 +6,11 @@
[ext_resource path="res://ui/Boba Date.otf" type="DynamicFontData" id=4]
[ext_resource path="res://ui/HooskaiChamferedSquare.ttf" type="DynamicFontData" id=5]
[sub_resource type="SpatialMaterial" id=11]
albedo_color = Color( 0.309804, 0.690196, 0.380392, 1 )
metallic = 0.35
metallic_specular = 0.11
[sub_resource type="DynamicFont" id=19]
font_data = ExtResource( 1 )
[sub_resource type="TextMesh" id=2]
resource_local_to_scene = true
material = SubResource( 11 )
text = "TEXT"
font = SubResource( 19 )
pixel_size = 0.05
@ -185,6 +179,11 @@ tracks/4/keys = {
"values": [ ExtResource( 4 ) ]
}
[sub_resource type="SpatialMaterial" id=11]
albedo_color = Color( 0.309804, 0.690196, 0.380392, 1 )
metallic = 0.35
metallic_specular = 0.11
[sub_resource type="Animation" id=20]
resource_name = "final score"
tracks/0/type = "value"
@ -658,7 +657,6 @@ anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
text = "TEXT"
text_material = SubResource( 11 )
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 256, 192 )

View file

@ -58,7 +58,7 @@ func _on_Hitbox_area_entered(area):
target.die()
#decrease arrows if enemy killed
if target_group == "enemy_hitbox":
Game.arrows = max(0, Game.arrows - 1) # clamp arrows above 0
Game.arrows = max(0, Game.arrows - 1) as int # clamp arrows above 0
_persist_trail()
queue_free()
elif area.is_in_group("arrow"):

View file

@ -106,6 +106,8 @@ Ngio="*res://autoloads/ngio.gd"
[debug]
gdscript/warnings/unused_argument=false
gdscript/warnings/return_value_discarded=false
shapes/collision/shape_color=Color( 0.564706, 0, 0.701961, 0.188235 )
shapes/collision/contact_color=Color( 0.101961, 1, 0.176471, 0.8 )
shapes/collision/draw_2d_outlines=false

View file

@ -38,5 +38,6 @@ func _process(delta):
frame = posmod(frame + int(sign(fps)), hframes * vframes)
if frame == stop_at_frame:
stopped = true
emit_signal("stopped")
if ping_pong and frame == 0:
fps = -fps