diff --git a/assets/HUD/time_hud.png b/assets/HUD/time_hud.png new file mode 100644 index 0000000..3f286d9 Binary files /dev/null and b/assets/HUD/time_hud.png differ diff --git a/assets/HUD/time_hud.png.import b/assets/HUD/time_hud.png.import new file mode 100644 index 0000000..fc9e5d2 --- /dev/null +++ b/assets/HUD/time_hud.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/time_hud.png-0544f5cdebd62aa844aeedf56f01d694.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/HUD/time_hud.png" +dest_files=[ "res://.import/time_hud.png-0544f5cdebd62aa844aeedf56f01d694.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot index 4816a2d..ed446b4 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,16 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://src/Items/Coin.gd" }, { +"base": "Node2D", +"class": "CutScene", +"language": "GDScript", +"path": "res://src/Scripts/CutScene.gd" +}, { +"base": "Control", +"class": "DialogBubble", +"language": "GDScript", +"path": "res://src/CutScenes/DialogBubble/DialogBubble.gd" +}, { "base": "KinematicBody2D", "class": "Enemy", "language": "GDScript", @@ -42,6 +52,8 @@ _global_script_classes=[ { _global_script_class_icons={ "CheckPoint": "", "Coin": "", +"CutScene": "", +"DialogBubble": "", "Enemy": "", "HUD": "", "Player": "", @@ -61,11 +73,13 @@ config/icon="res://icon.png" AudioManager="*res://src/Singletons/AudioManager.tscn" GameState="*res://src/Singletons/GameState.gd" +Utils="*res://src/Singletons/Utils.gd" [display] window/size/width=480 window/size/height=270 +window/size/fullscreen=true window/stretch/mode="viewport" window/stretch/aspect="keep" @@ -79,6 +93,15 @@ theme/custom="res://assets/Theme/Theme.tres" [input] +ui_accept={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null) + ] +} direction_up={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) diff --git a/src/Actors/LightBeam.gd b/src/Actors/LightBeam.gd new file mode 100644 index 0000000..88c76fd --- /dev/null +++ b/src/Actors/LightBeam.gd @@ -0,0 +1,26 @@ +extends Particles2D + +export var direction = Vector2.LEFT +export var speed = 300 + +func _ready() -> void: + $AnimationPlayer.play("lights_on") + +func _physics_process(delta: float) -> void: + if emitting: + position = position + (direction * speed * delta) + + + + +func _on_Area2D_body_entered(body: Node) -> void: + call_deferred("_disable_area") + emitting = false + $AnimationPlayer.play("lights_out") + yield($AnimationPlayer, "animation_finished") + queue_free() + pass # Replace with function body. + +func _disable_area(): + print("beam area off") + $Area2D/CollisionShape2D.disabled = true diff --git a/src/Actors/LightBeam.tscn b/src/Actors/LightBeam.tscn new file mode 100644 index 0000000..98afef5 --- /dev/null +++ b/src/Actors/LightBeam.tscn @@ -0,0 +1,138 @@ +[gd_scene load_steps=11 format=2] + +[ext_resource path="res://src/Actors/ligt_beam.png" type="Texture" id=1] +[ext_resource path="res://src/Actors/LightBeam.gd" type="Script" id=2] + +[sub_resource type="Gradient" id=1] +offsets = PoolRealArray( 0, 0.189655, 0.366379, 0.616379, 1 ) +colors = PoolColorArray( 1, 1, 1, 1, 0, 0.992157, 0.894118, 1, 0.844238, 0.964844, 0.95297, 0.826387, 0.0330963, 0.941406, 0.852792, 0.712057, 0.0627451, 0.992157, 0.901961, 0.203922 ) + +[sub_resource type="GradientTexture" id=2] +gradient = SubResource( 1 ) + +[sub_resource type="Curve" id=3] +_data = [ Vector2( 0.00784314, 0.894318 ), 0.0, 1.34604, 0, 0, Vector2( 1, 0.237591 ), 0.0, 0.0, 0, 0 ] + +[sub_resource type="CurveTexture" id=4] +curve = SubResource( 3 ) + +[sub_resource type="ParticlesMaterial" id=5] +emission_shape = 1 +emission_sphere_radius = 1.0 +flag_disable_z = true +direction = Vector3( 0, 0, 0 ) +gravity = Vector3( 0, 0, 0 ) +angular_velocity = 0.2 +angular_velocity_random = 1.0 +orbit_velocity = 0.0 +orbit_velocity_random = 0.0 +angle = 90.0 +angle_random = 0.6 +scale = 0.7 +scale_random = 0.5 +scale_curve = SubResource( 4 ) +color_ramp = SubResource( 2 ) + +[sub_resource type="CircleShape2D" id=6] +radius = 3.0 + +[sub_resource type="Animation" id=8] +resource_name = "lights_on" +length = 0.5 +loop = true +tracks/0/type = "value" +tracks/0/path = NodePath("Light2D:texture_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.25, 0.5 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ 1.0, 1.5, 1.0 ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Light2D:rotation_degrees") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 0.25, 0.5 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ 0.0, -86.4, 33.4 ] +} + +[sub_resource type="Animation" id=7] +resource_name = "lights_out" +length = 0.5 +step = 0.25 +tracks/0/type = "value" +tracks/0/path = NodePath("Light2D:energy") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.5 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ 2.0, 0.0 ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Light2D:texture_scale") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 0.25, 0.5 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ 2.0, 1.5, 2.0 ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("Light2D:rotation_degrees") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.25, 0.5 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ 0.0, -86.4, 0.0 ] +} + +[node name="LightBeam" type="Particles2D"] +amount = 50 +lifetime = 0.4 +explosiveness = 0.1 +local_coords = false +process_material = SubResource( 5 ) +texture = ExtResource( 1 ) +script = ExtResource( 2 ) + +[node name="Light2D" type="Light2D" parent="."] +rotation = -0.253422 +texture = ExtResource( 1 ) +texture_scale = 0.8 +energy = 2.0 +range_item_cull_mask = 15375 +shadow_enabled = true +shadow_item_cull_mask = 28 + +[node name="Area2D" type="Area2D" parent="."] +collision_layer = 0 +collision_mask = 2147483660 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource( 6 ) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +autoplay = "lights_on" +anims/lights_on = SubResource( 8 ) +anims/lights_out = SubResource( 7 ) +[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"] diff --git a/src/Actors/Player.gd b/src/Actors/Player.gd index b66b819..2af2651 100644 --- a/src/Actors/Player.gd +++ b/src/Actors/Player.gd @@ -9,12 +9,13 @@ export var gravity: = 500.0 export var max_gravity:= 450.0 export var respawn_position:=Vector2.ZERO export var wall_slide_friction:=.2 -export var wall_jump_speed_factor := Vector2(2.5 ,.85) +export var wall_jump_speed_factor := Vector2(1 ,.8) export var dash_thrust = 500.0 export var max_wall_slide_gravity := 100.0 var LandingDust = load("res://src/Actors/LandingDust.tscn") var JumpDust = load("res://src/Actors/JumpDust.tscn") +var LightBeam = load("res://src/Actors/LightBeam.tscn") signal landed @@ -23,13 +24,21 @@ signal died var _velocity: Vector2 = Vector2.ZERO var _landing_position:Vector2 = Vector2.ZERO -var _in_air = false; var _is_wall_jumping := false -var _alive := false; -var _is_wall_sliding := false; -var _is_dashing := false; -var _can_dash := true; -var _is_attaking := false; +var _alive := false +var _can_dash := true +var _is_jump_canceled := false +var _direction := Vector2.ZERO + +enum States { + IDLE, + IN_AIR, + DASHING, + WALL_SLIDING, + ATTACKING +} + +var _state = States.IDLE enum Direction{ RIGHT = 1, @@ -39,7 +48,8 @@ enum Direction{ export var abilities:= { "dash": false, "wall_jump": false, - "attack": false + "attack": false, + "light_beam": false } func _ready() -> void: $AnimationPlayer.play("fade_in") @@ -47,92 +57,142 @@ func _ready() -> void: func _physics_process(delta: float) -> void: if _alive: - var is_jump_canceled: = Input.is_action_just_released("jump") and !_is_wall_jumping and _velocity.y < 0.0 - var direction: = get_direction() - var prev_wall_slide_state = _is_wall_sliding - _is_wall_sliding = _velocity.y >=0 and is_on_wall() and _in_air - _velocity = calculate_move_velocity(direction,is_jump_canceled, delta) - if _is_wall_sliding and not prev_wall_slide_state: - _velocity.y=0 + _update_state() + _input_check() + _velocity = calculate_move_velocity(_direction,_is_jump_canceled, delta) _velocity = move_and_slide(_velocity, Vector2.UP) - update_sprite(direction) - if is_on_floor() and !_is_dashing: _can_dash = true; - if is_on_floor() and _in_air and !_is_dashing: - var dust = LandingDust.instance() - dust.position = position - get_parent().add_child(dust) - _in_air = false - _is_wall_jumping = false - emit_signal("landed", position) - if _is_wall_sliding: - _is_wall_jumping = false - -func get_direction() -> Vector2: - var right_strength = min(Input.get_action_strength("direction_right") , 1) - var left_strength = min(Input.get_action_strength("direction_left"), 1) - return Vector2( - right_strength - left_strength if _in_air or not _is_attaking else 0, - -1.0 if Input.is_action_just_pressed("jump") and (is_on_floor() or _is_wall_sliding) else 1.0 - ) - -func calculate_move_velocity(direction:Vector2, is_jump_canceled:bool, delta:float)->Vector2: - var output: = _velocity - - var current_gravity = gravity * wall_slide_friction if _is_wall_sliding else gravity - - output.x = lerp(_velocity.x, run_speed * direction.x, .09 if _in_air else .5) - - output.y += current_gravity * delta - - if direction.y == -1.0: # we are jumping - _in_air = true - if _is_wall_sliding: - # wall jump - var walljump__x_direction = -1 * direction.x - _is_wall_jumping = true - var desired = (run_speed * wall_jump_speed_factor.x * walljump__x_direction) - output.x = desired - output.y = jump_power * wall_jump_speed_factor.y * direction.y - else: - #jump - output.y = jump_power * direction.y - var dust = JumpDust.instance() - dust.position = position; - get_parent().add_child(dust) - emit_signal("jumping", position) - - if not _is_dashing: - if is_jump_canceled: - output.y = 0 - if output.y < max_gravity * -1: - output.y = max_gravity - if output.y > 0 and !is_on_floor(): - _in_air = true; - if _is_dashing: - return _velocity - - if _is_wall_sliding and output.y > max_wall_slide_gravity: - output.y = max_wall_slide_gravity - - var dash_velocity := Vector2( - $Sprite.scale.x * dash_thrust, - 0 - ) - - if Input.is_action_just_pressed("dash") and _can_dash: + update_sprite(_direction) + +func _input_check() -> void: + if GameState.get_state() == GameState.States.GAME: + _is_jump_canceled = Input.is_action_just_released("jump") and !_is_wall_jumping and _velocity.y < 0.0; + _get_direction() + _check_dash() + if Input.is_action_just_pressed("attack") and abilities.attack: + _attack() + else: + _direction = Vector2.ZERO + + + + + +func _update_state(new_state:int = -1): + var auto_update = new_state == -1; + if new_state == -1: + new_state = _state + if _state == States.DASHING: return + if _state == States.ATTACKING: return + if _state == States.IDLE: + if _velocity.y > 0 and not is_on_floor(): + # Falling from ground + new_state = States.IN_AIR + elif _state == States.IN_AIR: + if is_on_floor(): + _on_landed() + new_state = States.IDLE + elif _velocity.y >=0 and is_on_wall(): + if _state != States.WALL_SLIDING: + _velocity.y=0 + new_state = States.WALL_SLIDING + elif _state == States.WALL_SLIDING: + if is_on_floor() or not is_on_wall(): + new_state = States.IDLE + else: new_state = States.IDLE + _transition_state(_state, new_state, auto_update) + +func _transition_state(old_state, new_state, auto_update): + if new_state != old_state: + print("[Player]: State Update: [%s] -> [%s] | Automatic: %s" % [old_state, new_state, auto_update]) + _state = new_state + if old_state == States.IDLE: + # idle -> attak = ground attack - stop _velocity.x + if new_state == States.ATTACKING: + _direction.x = 0; + _velocity.x = 0; + if old_state == States.DASHING: + if new_state == States.IDLE: + _can_dash = true + if old_state == States.WALL_SLIDING: + if new_state == States.IDLE: + _on_landed() + +func _on_landed(): + _can_dash = true + var dust = LandingDust.instance() + dust.position = position + get_parent().add_child(dust) + emit_signal("landed", position) + +func _on_jump(wall_jump:bool = false): + var dust:Node = JumpDust.instance() + dust.position = position; + get_parent().add_child(dust) + if wall_jump: + dust.position.x += 2 * -$Sprite.scale.x + dust.get_node("Sprite").rotate(deg2rad(90) * -$Sprite.scale.x) + emit_signal("jumping", position) + +func _get_direction() -> void: + var right_strength = round(Input.get_action_strength("direction_right")) + var left_strength = round(Input.get_action_strength("direction_left")) + var vertical_movement = right_strength - left_strength if not _state == States.DASHING else 0 + var is_in_jumpable_state = _state == States.IDLE or _state == States.WALL_SLIDING + _direction = Vector2( + vertical_movement, + -1.0 if Input.is_action_just_pressed("jump") and is_in_jumpable_state else 1.0 + ) +func _check_dash(): + if Input.is_action_just_pressed("dash") and _can_dash and abilities.dash: + var dash_velocity := Vector2($Sprite.scale.x * dash_thrust,0) _can_dash = false - _is_dashing = true # turn off gravity while dashing # Wall dash first - if _is_wall_sliding: + if _state == States.WALL_SLIDING: dash_velocity.x = $Sprite.scale.x * dash_thrust * -1 if dash_velocity.x < 0 : $DashParticlesLeft.emitting = true; else: $DashParticlesRight.emitting = true - output = dash_velocity + _velocity = dash_velocity $DashTimeout.start() + _update_state(States.DASHING) # turn off gravity while dashing + +func calculate_move_velocity(direction:Vector2, is_jump_canceled:bool, delta:float)->Vector2: + var output: = _velocity + var current_gravity = gravity * wall_slide_friction if _state == States.WALL_SLIDING else gravity + + output.x = lerp(_velocity.x, run_speed * direction.x, .1 if _state == States.IN_AIR else .5) + + output.y += current_gravity * delta + + if _state == States.DASHING: + return _velocity + + if direction.y == -1.0: # we are jumping + var wall_jump := false + if _state == States.WALL_SLIDING and abilities.wall_jump: + # wall jump + wall_jump = true + var walljump__x_direction = -1 * direction.x + var desired = (run_speed * wall_jump_speed_factor.x * walljump__x_direction) + output.x = desired + output.y = jump_power * wall_jump_speed_factor.y * direction.y + else: + #jump + output.y = jump_power * direction.y + _update_state(States.IN_AIR) + _on_jump(wall_jump) + else: + if is_jump_canceled: + output.y = 0 + if output.y < max_gravity * -1: + output.y = max_gravity + + + if _state == States.WALL_SLIDING and output.y > max_wall_slide_gravity: + output.y = max_wall_slide_gravity return output; @@ -147,40 +207,45 @@ func _revive(): func update_sprite(_direction:Vector2) -> void: var air_animation = "jump" if _velocity.y <= 0 else "fall" - if _is_attaking: return + if _state == States.ATTACKING: return var attack = Input.is_action_just_pressed("attack") and abilities.attack - if _velocity.x > .5 and not _is_wall_sliding: + if _velocity.x > .5 and not _state == States.WALL_SLIDING: $Sprite.scale = Vector2(1,1) $AnimationPlayer.play("run" if is_on_floor() else air_animation) - elif _velocity.x < -.5 and not _is_wall_sliding: + elif _velocity.x < -.5 and not _state == States.WALL_SLIDING: $Sprite.scale = Vector2(-1,1) $AnimationPlayer.play("run" if is_on_floor() else air_animation) else: - if not _in_air: $AnimationPlayer.play("idle") + if not _state == States.IN_AIR: $AnimationPlayer.play("idle") - if _is_wall_sliding: + if _state == States.WALL_SLIDING: $AnimationPlayer.play("wall_slide") return - if attack: - _is_attaking = true - AudioManager.play_sfx(AudioManager.Sfx.PLAYER_ATTACK) - var attack_animation = "attack_right" if $Sprite.scale.x > 0 else "attack_left" - $AnimationPlayer.play(attack_animation) - $AnimationPlayer.playback_speed = 2.5 - $AnimationPlayer.seek(0) - yield($AnimationPlayer, "animation_finished") - $AnimationPlayer.playback_speed = 1 - _is_attaking = false - return - if _in_air: + if _state == States.IN_AIR: $AnimationPlayer.play(air_animation) return - if _is_dashing: + if _state == States.DASHING: $AnimationPlayer.play("jump") return - +func _attack(): + if _state == States.DASHING: + var beam = LightBeam.instance() + beam.direction = Vector2($Sprite.scale.x, 0) + beam.position = $Sprite/LightBeamInitPoint.get_global_transform().get_origin() + get_parent().add_child(beam) + $DashTimeout.stop() + _on_DashTimeout_timeout(false) + _update_state(States.ATTACKING) + AudioManager.play_sfx(AudioManager.Sfx.PLAYER_ATTACK) + var attack_animation = "attack_right" if $Sprite.scale.x > 0 else "attack_left" + $AnimationPlayer.play(attack_animation) + $AnimationPlayer.playback_speed = 2.5 + yield($AnimationPlayer, "animation_finished") + $AnimationPlayer.seek(0) + $AnimationPlayer.playback_speed = 1 + _update_state(States.IDLE) func _on_die_animation_done(): emit_signal("died") @@ -201,11 +266,12 @@ func setAbility(ability:String, enabled:bool=false): else: pass -func _on_DashTimeout_timeout() -> void: +func _on_DashTimeout_timeout(timed_out=true) -> void: + $AnimationPlayer.playback_speed = 1 $DashParticlesLeft.emitting = false $DashParticlesRight.emitting = false _velocity.x = run_speed * _velocity.normalized().x; - _is_dashing = false + if timed_out: _update_state(States.IN_AIR) pass # Replace with function body. diff --git a/src/Actors/Player.tscn b/src/Actors/Player.tscn index 23b1d6a..294bcd9 100644 --- a/src/Actors/Player.tscn +++ b/src/Actors/Player.tscn @@ -836,6 +836,9 @@ collision_mask = 2 position = Vector2( 14, -6 ) shape = SubResource( 2 ) +[node name="LightBeamInitPoint" type="Position2D" parent="Sprite"] +position = Vector2( 14, 2 ) + [node name="AnimationPlayer" type="AnimationPlayer" parent="."] autoplay = "idle" anims/attack_left = SubResource( 3 ) @@ -881,5 +884,15 @@ position = Vector2( 0, -8.04107 ) enabled = true cast_to = Vector2( -5.2, 0 ) collision_mask = 8 + +[node name="Camera2D" type="Camera2D" parent="."] +current = true +limit_left = -45 +limit_smoothed = true +drag_margin_h_enabled = true +drag_margin_v_enabled = true +smoothing_enabled = true +drag_margin_left = 0.09 +drag_margin_right = 0.09 [connection signal="body_entered" from="Sprite/SordRange" to="." method="_on_SordRange_body_entered"] [connection signal="timeout" from="DashTimeout" to="." method="_on_DashTimeout_timeout"] diff --git a/src/Actors/WiseOldDude/WiseOldDude.tscn b/src/Actors/WiseOldDude/WiseOldDude.tscn new file mode 100644 index 0000000..94b673e --- /dev/null +++ b/src/Actors/WiseOldDude/WiseOldDude.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://src/Actors/WiseOldDude/wize_old_dude.png" type="Texture" id=1] + +[sub_resource type="Animation" id=1] +resource_name = "idle" +length = 0.8 +loop = true +tracks/0/type = "value" +tracks/0/path = NodePath("Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.2, 0.4, 0.6, 0.8 ), +"transitions": PoolRealArray( 1, 1, 1, 1, 1 ), +"update": 1, +"values": [ 17, 18, 19, 20, 21 ] +} + +[node name="WiseOldDude" type="Node2D"] + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 0, -16 ) +texture = ExtResource( 1 ) +vframes = 6 +hframes = 9 +frame = 18 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +autoplay = "idle" +anims/idle = SubResource( 1 ) diff --git a/src/Actors/WiseOldDude/wize_old_dude.png b/src/Actors/WiseOldDude/wize_old_dude.png new file mode 100644 index 0000000..8eee12a Binary files /dev/null and b/src/Actors/WiseOldDude/wize_old_dude.png differ diff --git a/src/Actors/WiseOldDude/wize_old_dude.png.import b/src/Actors/WiseOldDude/wize_old_dude.png.import new file mode 100644 index 0000000..30cbfd9 --- /dev/null +++ b/src/Actors/WiseOldDude/wize_old_dude.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/wize_old_dude.png-2d29b22f4c54a0aed9056fec7199f29e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/Actors/WiseOldDude/wize_old_dude.png" +dest_files=[ "res://.import/wize_old_dude.png-2d29b22f4c54a0aed9056fec7199f29e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/src/Actors/ligt_beam.png b/src/Actors/ligt_beam.png new file mode 100644 index 0000000..bf1be27 Binary files /dev/null and b/src/Actors/ligt_beam.png differ diff --git a/src/Actors/ligt_beam.png.import b/src/Actors/ligt_beam.png.import new file mode 100644 index 0000000..908491a --- /dev/null +++ b/src/Actors/ligt_beam.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/ligt_beam.png-10d3dd70473d3611e41e8dbba9e0477b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/Actors/ligt_beam.png" +dest_files=[ "res://.import/ligt_beam.png-10d3dd70473d3611e41e8dbba9e0477b.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/src/CutScenes/ChallengeCutscene.gd b/src/CutScenes/ChallengeCutscene.gd new file mode 100644 index 0000000..0b2cbeb --- /dev/null +++ b/src/CutScenes/ChallengeCutscene.gd @@ -0,0 +1,101 @@ +extends CutScene +var _dialog_bubble = load("res://src/CutScenes/DialogBubble/DialogBubble.tscn") +var _old_man_dialog = [ + { + "text": "Hi there young one!", + "callback": null + }, + { + "text": "You do look stupid enough\nfor my challenge...", + "callback": null + }, + { + "text": "You see that tree over there?", + "callback": null + }, + ] +var _old_man_dialog2 = [ + { + "text": "Oh, yeah - not there...", + "callback": null + }, + { + "text": "Forgive me, never thought you would really take a look", + "callback": null + }, + { + "text": "Never mind Bro. See the path ahead? There is a tree in that cave.", + "callback": null + }, + ] + +func start_scene(camera:Camera2D): + _main_camera_ref = camera + position = camera.get_global_transform().get_origin() + _camera = camera.duplicate() + add_child(_camera) + _main_camera_ref.current = false + _camera.current = true + + $AnimationPlayer.play("start") + yield($AnimationPlayer, "animation_finished") + + yield(get_tree().create_timer(.5), "timeout") + + + # Dialog 1 + $AnimationPlayer.play("old_dude_slide_in") + yield($AnimationPlayer, "animation_finished") + + var dialog_bubble:DialogBubble = _dialog_bubble.instance() + dialog_bubble.allow_fast_skip = bool(GameState.get_statistics().total_time_played) + dialog_bubble.dialog = _old_man_dialog + $Overlay.add_child(dialog_bubble) + dialog_bubble.start_dialog() + yield(dialog_bubble, "dialog_finished") + + $AnimationPlayer.play("old_dude_slide_out") + yield($AnimationPlayer, "animation_finished") + + # pan Camera + $Tween.interpolate_property(_camera, "position", _camera.position, Vector2( _camera.position.x - 400, _camera.position.y), 2) + $Tween.start() + yield($Tween, "tween_completed") + + # wait a bit to get a "haha" timing + yield(get_tree().create_timer(2), "timeout") + + #pan back + $Tween.interpolate_property(_camera, "position", _camera.position, _camera.get_parent().position, 2, Tween.TRANS_BOUNCE, Tween.EASE_OUT) + $Tween.start() + yield($Tween, "tween_completed") + camera.get_parent()._velocity.y = -100 + # Dialog 2 + $AnimationPlayer.play("old_dude_slide_in") + yield($AnimationPlayer, "animation_finished") + + dialog_bubble = _dialog_bubble.instance() + dialog_bubble.dialog = _old_man_dialog2 + $Overlay.add_child(dialog_bubble) + dialog_bubble.start_dialog() + yield(dialog_bubble, "dialog_finished") + + $AnimationPlayer.play("old_dude_slide_out") + yield($AnimationPlayer, "animation_finished") + + # + + + _on_scene_exited() + pass + + + +func _on_scene_exited(): + $Tween.interpolate_property(_camera, "position", _camera.position, _camera.get_parent().position, 2, Tween.TRANS_BOUNCE, Tween.EASE_OUT) + $Tween.start() + yield($Tween, "tween_completed") + _main_camera_ref.current = true + $AnimationPlayer.play_backwards("start") + yield($AnimationPlayer, "animation_finished") + end_scene() diff --git a/src/CutScenes/ChallengeCutscene.tscn b/src/CutScenes/ChallengeCutscene.tscn new file mode 100644 index 0000000..5b67f1a --- /dev/null +++ b/src/CutScenes/ChallengeCutscene.tscn @@ -0,0 +1,112 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://src/CutScenes/ChallengeCutscene.gd" type="Script" id=1] +[ext_resource path="res://src/CutScenes/red-wizzard-large.png" type="Texture" id=2] + +[sub_resource type="Animation" id=1] +resource_name = "old_dude_slide_in" +length = 0.5 +tracks/0/type = "value" +tracks/0/path = NodePath("Overlay/FigureOldDude:offset") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.5 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 900, 50 ), Vector2( 600, 50 ) ] +} + +[sub_resource type="Animation" id=2] +resource_name = "old_dude_slide_out" +length = 0.5 +tracks/0/type = "value" +tracks/0/path = NodePath("Overlay/FigureOldDude:offset") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.5 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 600, 50 ), Vector2( 900, 50 ) ] +} + +[sub_resource type="Animation" id=3] +length = 0.2 +tracks/0/type = "value" +tracks/0/path = NodePath("Overlay/ColorRect2:rect_position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.2 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 0, 270 ), Vector2( 0, 245 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Overlay/ColorRect:rect_position") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 0.2 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 0, -25 ), Vector2( 0, 0 ) ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("Overlay/FigureOldDude:offset") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 900, 50 ) ] +} + +[node name="ChallengeCutscene" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Overlay" type="CanvasLayer" parent="."] +layer = 2 + +[node name="FigureOldDude" type="Sprite" parent="Overlay"] +scale = Vector2( 0.533333, 0.533333 ) +texture = ExtResource( 2 ) +centered = false +offset = Vector2( 600, 50 ) +flip_h = true + +[node name="ColorRect" type="ColorRect" parent="Overlay"] +margin_top = -25.0 +margin_right = 480.0 +color = Color( 0, 0, 0, 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ColorRect2" type="ColorRect" parent="Overlay"] +margin_top = 270.0 +margin_right = 480.0 +margin_bottom = 295.0 +color = Color( 0, 0, 0, 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +anims/old_dude_slide_in = SubResource( 1 ) +anims/old_dude_slide_out = SubResource( 2 ) +anims/start = SubResource( 3 ) + +[node name="Tween" type="Tween" parent="."] diff --git a/src/CutScenes/DialogBubble/DialogBubble.gd b/src/CutScenes/DialogBubble/DialogBubble.gd new file mode 100644 index 0000000..431507e --- /dev/null +++ b/src/CutScenes/DialogBubble/DialogBubble.gd @@ -0,0 +1,49 @@ +extends Control +class_name DialogBubble +signal dialog_finished + +var allow_fast_skip := false + +var dialog = [] # Dictionary[] {text:string, callback:function}[] +var _position := 0 +var _done := false +var _paused := false +var _started :=false +func resume_dialog(): + _paused = false +func start_dialog(): + $AnimationPlayer.play("slide_in") + yield($AnimationPlayer, "animation_finished") + _started = true + _show_text() + +func _show_text(): + if _position >= dialog.size(): + # we are done + _done = true + dismiss() + return + var sentence = dialog[_position] + $NinePatchRect/Label.text = sentence.text + $AnimationPlayer.play("show_text") + yield($AnimationPlayer, "animation_finished") + if sentence.callback != null: + sentence.callback() + +func _input(event: InputEvent) -> void: + if not _started: return + if Input.is_action_just_pressed("jump"): + if allow_fast_skip: dismiss() + else: + _position += 1 + $AnimationPlayer.play_backwards("show_text") + yield($AnimationPlayer, "animation_finished") + _show_text() + + + +func dismiss(): + $AnimationPlayer.play_backwards("slide_in") + yield($AnimationPlayer, "animation_finished") + emit_signal("dialog_finished") + queue_free() diff --git a/src/CutScenes/DialogBubble/DialogBubble.tscn b/src/CutScenes/DialogBubble/DialogBubble.tscn new file mode 100644 index 0000000..7b12424 --- /dev/null +++ b/src/CutScenes/DialogBubble/DialogBubble.tscn @@ -0,0 +1,107 @@ +[gd_scene load_steps=7 format=2] + +[ext_resource path="res://src/CutScenes/DialogBubble/DialogBubble.gd" type="Script" id=1] +[ext_resource path="res://src/CutScenes/DialogBubble/hud_stats_bg.png" type="Texture" id=2] +[ext_resource path="res://assets/Theme/slkscr.ttf" type="DynamicFontData" id=3] + +[sub_resource type="DynamicFont" id=1] +size = 17 +outline_size = 1 +outline_color = Color( 0, 0, 0, 1 ) +font_data = ExtResource( 3 ) + +[sub_resource type="Animation" id=2] +resource_name = "show_text" +length = 0.2 +tracks/0/type = "value" +tracks/0/path = NodePath("NinePatchRect/Label:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.2 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] +} + +[sub_resource type="Animation" id=3] +length = 0.5 +tracks/0/type = "value" +tracks/0/path = NodePath("NinePatchRect:margin_bottom") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.5 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ 135.0, -15.0 ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("NinePatchRect:margin_top") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 0.5 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ 300.0, 150.0 ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("NinePatchRect/Label:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ) ] +} + +[node name="DialogBubble" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="NinePatchRect" type="NinePatchRect" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 40.0 +margin_top = 300.0 +margin_right = -40.0 +margin_bottom = 135.0 +texture = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="NinePatchRect"] +modulate = Color( 1, 1, 1, 0 ) +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 20.0 +margin_top = 20.0 +margin_right = -20.0 +margin_bottom = -20.0 +custom_fonts/font = SubResource( 1 ) +custom_colors/font_color = Color( 1, 1, 1, 0.890196 ) +text = "Hello there young one!" +align = 1 +autowrap = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +anims/show_text = SubResource( 2 ) +anims/slide_in = SubResource( 3 ) diff --git a/src/CutScenes/DialogBubble/hud_stats_bg.png b/src/CutScenes/DialogBubble/hud_stats_bg.png new file mode 100644 index 0000000..becfd71 Binary files /dev/null and b/src/CutScenes/DialogBubble/hud_stats_bg.png differ diff --git a/src/CutScenes/DialogBubble/hud_stats_bg.png.import b/src/CutScenes/DialogBubble/hud_stats_bg.png.import new file mode 100644 index 0000000..dda0838 --- /dev/null +++ b/src/CutScenes/DialogBubble/hud_stats_bg.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/hud_stats_bg.png-52f55fa7703387ba6f7baf17aea738e4.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/CutScenes/DialogBubble/hud_stats_bg.png" +dest_files=[ "res://.import/hud_stats_bg.png-52f55fa7703387ba6f7baf17aea738e4.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/src/CutScenes/red-wizzard-large.png b/src/CutScenes/red-wizzard-large.png new file mode 100644 index 0000000..b59788d Binary files /dev/null and b/src/CutScenes/red-wizzard-large.png differ diff --git a/src/CutScenes/red-wizzard-large.png.import b/src/CutScenes/red-wizzard-large.png.import new file mode 100644 index 0000000..0f52f69 --- /dev/null +++ b/src/CutScenes/red-wizzard-large.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/red-wizzard-large.png-bc152bcfbf1b2206bc916eefc4b9a5e6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/CutScenes/red-wizzard-large.png" +dest_files=[ "res://.import/red-wizzard-large.png-bc152bcfbf1b2206bc916eefc4b9a5e6.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/src/GameWorld/GameWorld.gd b/src/GameWorld/GameWorld.gd new file mode 100644 index 0000000..ed47002 --- /dev/null +++ b/src/GameWorld/GameWorld.gd @@ -0,0 +1,27 @@ +extends Node2D + + +var _Cutscenes = { + "old_man_intro": "res://src/CutScenes/ChallengeCutscene.tscn" +} + + +func _ready() -> void: + $Player/Camera2D.limit_bottom = 250 + $Player/Camera2D.limit_left = -45 + $Player/Camera2D.limit_right = 700 + + + + + +func _on_OldDudeIntroArea_body_entered(body: Node) -> void: + if body.name == 'Player': + AudioManager.play_music(AudioManager.Music.Abandon) + GameState.start_cutscene() + var scene = (load(_Cutscenes.old_man_intro)).instance() + add_child(scene) + scene.start_scene($Player/Camera2D) + yield(scene, "cutscene_finished") + GameState.end_cutscene() + pass # Replace with function body. diff --git a/src/GameWorld/GameWorld.tscn b/src/GameWorld/GameWorld.tscn new file mode 100644 index 0000000..a6ee253 --- /dev/null +++ b/src/GameWorld/GameWorld.tscn @@ -0,0 +1,121 @@ +[gd_scene load_steps=11 format=2] + +[ext_resource path="res://src/HUD/HUD.tscn" type="PackedScene" id=1] +[ext_resource path="res://assets/Tiles/SolidsTileMap.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/Actors/Player.tscn" type="PackedScene" id=3] +[ext_resource path="res://assets/Tiles/background_0.png" type="Texture" id=4] +[ext_resource path="res://src/GameWorld/GameWorld.gd" type="Script" id=5] +[ext_resource path="res://assets/Tiles/background_1.png" type="Texture" id=6] +[ext_resource path="res://assets/Tiles/background_2.png" type="Texture" id=7] +[ext_resource path="res://src/Actors/WiseOldDude/WiseOldDude.tscn" type="PackedScene" id=8] +[ext_resource path="res://assets/Tiles/SemiSolidsTileMap.tscn" type="PackedScene" id=9] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 7, 37 ) + +[node name="GameWorld" type="Node2D"] +script = ExtResource( 5 ) + +[node name="HUD" parent="." instance=ExtResource( 1 )] + +[node name="ParallaxBackground" type="ParallaxBackground" parent="."] + +[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"] +motion_scale = Vector2( 0.6, 1 ) + +[node name="NinePatchRect" type="NinePatchRect" parent="ParallaxBackground/ParallaxLayer"] +margin_left = -142.0 +margin_top = -103.0 +margin_right = 443.0 +margin_bottom = 255.0 +texture = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="NinePatchRect2" type="NinePatchRect" parent="ParallaxBackground/ParallaxLayer"] +margin_left = 443.0 +margin_top = -103.0 +margin_right = 1028.0 +margin_bottom = 255.0 +texture = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ParallaxLayer2" type="ParallaxLayer" parent="ParallaxBackground"] +motion_scale = Vector2( 0.8, 1 ) + +[node name="NinePatchRect" type="NinePatchRect" parent="ParallaxBackground/ParallaxLayer2"] +margin_left = -142.0 +margin_top = -103.0 +margin_right = 443.0 +margin_bottom = 255.0 +texture = ExtResource( 6 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="NinePatchRect2" type="NinePatchRect" parent="ParallaxBackground/ParallaxLayer2"] +margin_left = 443.0 +margin_top = -103.0 +margin_right = 1028.0 +margin_bottom = 255.0 +texture = ExtResource( 6 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ParallaxLayer3" type="ParallaxLayer" parent="ParallaxBackground"] +motion_scale = Vector2( 0.9, 1 ) + +[node name="NinePatchRect" type="NinePatchRect" parent="ParallaxBackground/ParallaxLayer3"] +margin_left = -142.0 +margin_top = -103.0 +margin_right = 443.0 +margin_bottom = 255.0 +texture = ExtResource( 7 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="NinePatchRect2" type="NinePatchRect" parent="ParallaxBackground/ParallaxLayer3"] +margin_left = 443.0 +margin_top = -103.0 +margin_right = 1028.0 +margin_bottom = 255.0 +texture = ExtResource( 7 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="SolidPlatforms" type="Node2D" parent="."] + +[node name="SemiSolidsTileMap" parent="SolidPlatforms" instance=ExtResource( 9 )] +tile_data = PoolIntArray( 524316, 1, 0, 524317, 1, 1, 524318, 1, 1, 524319, 1, 1, 524320, 1, 1, 524321, 1, 1, 524322, 1, 2, 589852, 1, 65536, 589853, 1, 65537, 589854, 1, 65537, 589855, 1, 65537, 589856, 1, 65537, 589857, 1, 65537, 589858, 1, 65538, 655375, 0, 0, 655376, 0, 131076, 655377, 0, 1, 655378, 0, 1, 655379, 0, 131076, 655380, 0, 1, 655381, 0, 1, 655382, 0, 1, 655383, 0, 131076, 655384, 0, 131076, 655385, 0, 1, 655386, 0, 131076, 655387, 0, 2, 655388, 1, 65536, 655389, 1, 65537, 655390, 1, 65537, 655391, 1, 65537, 655392, 1, 65537, 655393, 1, 65537, 655394, 1, 65538, 720911, 0, 65541, 720912, 0, 65537, 720913, 0, 65537, 720914, 0, 65537, 720915, 0, 65537, 720916, 0, 65537, 720917, 0, 65537, 720918, 0, 65537, 720919, 0, 65537, 720920, 0, 3, 720921, 0, 131073, 720922, 0, 4, 720923, 0, 131074, 720924, 1, 65536, 720925, 1, 0, 720926, 1, 131073, 720927, 1, 131073, 720928, 1, 131073, 720929, 1, 0, 720930, 1, 65538, 786447, 0, 65541, 786448, 0, 65537, 786449, 0, 65537, 786450, 0, 65537, 786451, 0, 65537, 786452, 0, 65537, 786453, 0, 65537, 786454, 0, 65537, 786455, 0, 65537, 786456, 0, 65538, 786457, 1, 0, 786458, 1, 1, 786459, 1, 1, 786460, 1, 0, 786461, 1, 65538, 786462, 0, 0, 786463, 0, 131076, 786464, 0, 2, 786465, 1, 65536, 786466, 1, 65538, 851983, 0, 65541, 851984, 0, 65537, 851985, 0, 65537, 851986, 0, 65537, 851987, 0, 65537, 851988, 0, 65537, 851989, 0, 65537, 851990, 0, 65537, 851991, 0, 65537, 851992, 0, 65538, 851993, 1, 65536, 851994, 1, 65537, 851995, 1, 65537, 851996, 1, 65537, 851997, 1, 65538, 851998, 0, 65541, 851999, 0, 65537, 852000, 0, 65539, 852001, 1, 65536, 852002, 1, 65538, 917519, 0, 131072, 917520, 0, 4, 917521, 0, 131073, 917522, 0, 131073, 917523, 0, 4, 917524, 0, 4, 917525, 0, 131073, 917526, 0, 131073, 917527, 0, 4, 917528, 0, 131074, 917529, 1, 131072, 917530, 1, 131073, 917531, 1, 131073, 917532, 1, 131073, 917533, 1, 131074, 917534, 0, 65541, 917535, 0, 65537, 917536, 0, 65539, 917537, 1, 131072, 917538, 1, 131074, 983070, 0, 131072, 983071, 0, 131073, 983072, 0, 131074 ) + +[node name="SolidsTileMap" parent="SolidPlatforms" instance=ExtResource( 2 )] +tile_data = PoolIntArray( -65544, 0, 0, -65543, 0, 1, -65542, 0, 1, -65541, 0, 131076, -65540, 0, 1, -65539, 0, 1, -65538, 0, 1, -65537, 0, 2, -131041, 0, 0, -131040, 0, 131076, -131039, 0, 131076, -131038, 0, 1, -131037, 0, 131076, -131036, 0, 1, -131035, 0, 1, -131034, 0, 1, -131033, 0, 131076, -131032, 0, 1, -131031, 0, 1, -131030, 0, 131076, -131029, 0, 1, -131028, 0, 2, -8, 0, 65541, -7, 0, 65537, -6, 0, 65537, -5, 0, 65537, -4, 0, 65537, -3, 0, 65537, -2, 0, 65537, -1, 0, 65539, -65505, 0, 131072, -65504, 0, 4, -65503, 0, 5, -65502, 0, 3, -65501, 0, 4, -65500, 0, 131073, -65499, 0, 5, -65498, 0, 65537, -65497, 0, 65537, -65496, 0, 65537, -65495, 0, 65537, -65494, 0, 65537, -65493, 0, 65537, -65492, 0, 65538, 65528, 0, 65541, 65529, 0, 65537, 65530, 0, 65537, 65531, 0, 65537, 65532, 0, 65537, 65533, 0, 65537, 65534, 0, 65537, 65535, 0, 65538, 33, 0, 131072, 34, 0, 131074, 37, 0, 65536, 38, 0, 65537, 39, 0, 65537, 40, 0, 65537, 41, 0, 65537, 42, 0, 65537, 43, 0, 65537, 44, 0, 65539, 131064, 0, 65536, 131065, 0, 65537, 131066, 0, 65537, 131067, 0, 65537, 131068, 0, 65537, 131069, 0, 65537, 131070, 0, 65537, 131071, 0, 65538, 65573, 0, 65536, 65574, 0, 65537, 65575, 0, 65537, 65576, 0, 65537, 65577, 0, 65537, 65578, 0, 65537, 65579, 0, 65537, 65580, 0, 65539, 196600, 0, 65541, 196601, 0, 65537, 196602, 0, 65537, 196603, 0, 65537, 196604, 0, 65537, 196605, 0, 65537, 196606, 0, 65537, 196607, 0, 65539, 131109, 0, 65536, 131110, 0, 65537, 131111, 0, 65537, 131112, 0, 65537, 131113, 0, 65537, 131114, 0, 65537, 131115, 0, 65537, 131116, 0, 65538, 262136, 0, 65541, 262137, 0, 65537, 262138, 0, 65537, 262139, 0, 65537, 262140, 0, 65537, 262141, 0, 65537, 262142, 0, 65537, 262143, 0, 65538, 196645, 0, 65541, 196646, 0, 65537, 196647, 0, 65537, 196648, 0, 65537, 196649, 0, 65537, 196650, 0, 65537, 196651, 0, 65537, 196652, 0, 65539, 327672, 0, 65541, 327673, 0, 65537, 327674, 0, 65537, 327675, 0, 65537, 327676, 0, 65537, 327677, 0, 65537, 327678, 0, 65537, 327679, 0, 65538, 262181, 0, 65541, 262182, 0, 65537, 262183, 0, 65537, 262184, 0, 65537, 262185, 0, 65537, 262186, 0, 65537, 262187, 0, 65537, 262188, 0, 65539, 393208, 0, 65536, 393209, 0, 65537, 393210, 0, 65537, 393211, 0, 65537, 393212, 0, 65537, 393213, 0, 65537, 393214, 0, 65537, 393215, 0, 65538, 327717, 0, 131072, 327718, 0, 131073, 327719, 0, 5, 327720, 0, 65537, 327721, 0, 65537, 327722, 0, 65537, 327723, 0, 65537, 327724, 0, 65538, 458744, 0, 65541, 458745, 0, 65537, 458746, 0, 65537, 458747, 0, 65537, 458748, 0, 65537, 458749, 0, 65537, 458750, 0, 65537, 458751, 0, 65538, 393255, 0, 65536, 393256, 0, 65537, 393257, 0, 65537, 393258, 0, 65537, 393259, 0, 65537, 393260, 0, 65539, 524280, 0, 65541, 524281, 0, 65537, 524282, 0, 65537, 524283, 0, 65537, 524284, 0, 65537, 524285, 0, 65537, 524286, 0, 65537, 524287, 0, 65538, 458791, 0, 131072, 458792, 0, 131073, 458793, 0, 131073, 458794, 0, 4, 458795, 0, 5, 458796, 0, 65538, 589816, 0, 65541, 589817, 0, 65537, 589818, 0, 65537, 589819, 0, 65537, 589820, 0, 65537, 589821, 0, 65537, 589822, 0, 65537, 589823, 0, 65538, 524331, 0, 65541, 524332, 0, 65538, 655352, 0, 65536, 655353, 0, 65537, 655354, 0, 65537, 655355, 0, 65537, 655356, 0, 65537, 655357, 0, 65537, 655358, 0, 65537, 655359, 0, 65539, 589867, 0, 65541, 589868, 0, 65538, 720888, 0, 65541, 720889, 0, 65537, 720890, 0, 65537, 720891, 0, 65537, 720892, 0, 65537, 720893, 0, 65537, 720894, 0, 65537, 720895, 0, 131075, 655360, 0, 2, 655399, 0, 0, 655400, 0, 1, 655401, 0, 1, 655402, 0, 131076, 655403, 0, 131077, 655404, 0, 65539, 786424, 0, 65541, 786425, 0, 65537, 786426, 0, 65537, 786427, 0, 65537, 786428, 0, 65537, 786429, 0, 65537, 786430, 0, 65537, 786431, 0, 65537, 720896, 0, 131075, 720897, 0, 2, 720920, 0, 0, 720921, 0, 2, 720935, 0, 131072, 720936, 0, 131073, 720937, 0, 131073, 720938, 0, 4, 720939, 0, 4, 720940, 0, 131074, 851960, 0, 65536, 851961, 0, 65537, 851962, 0, 65537, 851963, 0, 65537, 851964, 0, 65537, 851965, 0, 65537, 851966, 0, 65537, 851967, 0, 65537, 786432, 0, 65537, 786433, 0, 131075, 786434, 0, 2, 786456, 0, 65541, 786457, 0, 65538, 786466, 0, 0, 786467, 0, 2, 917496, 0, 65541, 917497, 0, 65537, 917498, 0, 65537, 917499, 0, 65537, 917500, 0, 65537, 917501, 0, 65537, 917502, 0, 65537, 917503, 0, 65537, 851968, 0, 65537, 851969, 0, 65537, 851970, 0, 131075, 851971, 0, 2, 851987, 0, 0, 851988, 0, 2, 851992, 0, 65536, 851993, 0, 65539, 852002, 0, 65541, 852003, 0, 65539, 983032, 0, 65541, 983033, 0, 65537, 983034, 0, 65537, 983035, 0, 65537, 983036, 0, 65537, 983037, 0, 65537, 983038, 0, 65537, 983039, 0, 65537, 917504, 0, 65537, 917505, 0, 65537, 917506, 0, 65537, 917507, 0, 131075, 917508, 0, 1, 917509, 0, 131076, 917510, 0, 1, 917511, 0, 1, 917512, 0, 1, 917513, 0, 131076, 917514, 0, 131076, 917515, 0, 131076, 917516, 0, 131076, 917517, 0, 131076, 917518, 0, 1, 917519, 0, 131076, 917520, 0, 131076, 917521, 0, 1, 917522, 0, 1, 917523, 0, 131077, 917524, 0, 131075, 917525, 0, 1, 917526, 0, 131076, 917527, 0, 1, 917528, 0, 131077, 917529, 0, 131075, 917530, 0, 131076, 917531, 0, 1, 917532, 0, 1, 917533, 0, 131076, 917534, 0, 1, 917535, 0, 1, 917536, 0, 131076, 917537, 0, 131076, 917538, 0, 131077, 917539, 0, 131075, 917540, 0, 1, 917541, 0, 1, 917542, 0, 131076, 917543, 0, 1, 917544, 0, 1, 917545, 0, 1, 917546, 0, 1, 917547, 0, 1, 917548, 0, 2, 1048568, 0, 65536, 1048569, 0, 65537, 1048570, 0, 65537, 1048571, 0, 65537, 1048572, 0, 65537, 1048573, 0, 65537, 1048574, 0, 65537, 1048575, 0, 65537, 983040, 0, 65537, 983041, 0, 65537, 983042, 0, 65537, 983043, 0, 65537, 983044, 0, 65537, 983045, 0, 65537, 983046, 0, 65537, 983047, 0, 65537, 983048, 0, 65537, 983049, 0, 65537, 983050, 0, 65537, 983051, 0, 65537, 983052, 0, 65537, 983053, 0, 65537, 983054, 0, 65537, 983055, 0, 65537, 983056, 0, 65537, 983057, 0, 65537, 983058, 0, 65537, 983059, 0, 65537, 983060, 0, 65537, 983061, 0, 65537, 983062, 0, 65537, 983063, 0, 65537, 983064, 0, 65537, 983065, 0, 65537, 983066, 0, 65537, 983067, 0, 65537, 983068, 0, 65537, 983069, 0, 65537, 983070, 0, 65537, 983071, 0, 65537, 983072, 0, 65537, 983073, 0, 65537, 983074, 0, 65537, 983075, 0, 65537, 983076, 0, 65537, 983077, 0, 65537, 983078, 0, 65537, 983079, 0, 65537, 983080, 0, 65537, 983081, 0, 65537, 983082, 0, 65537, 983083, 0, 65537, 983084, 0, 65539, 1114104, 0, 131072, 1114105, 0, 131073, 1114106, 0, 131073, 1114107, 0, 131073, 1114108, 0, 131073, 1114109, 0, 131073, 1114110, 0, 131073, 1114111, 0, 4, 1048576, 0, 131073, 1048577, 0, 131073, 1048578, 0, 131073, 1048579, 0, 131073, 1048580, 0, 131073, 1048581, 0, 131073, 1048582, 0, 131073, 1048583, 0, 4, 1048584, 0, 131073, 1048585, 0, 131073, 1048586, 0, 131073, 1048587, 0, 4, 1048588, 0, 4, 1048589, 0, 131073, 1048590, 0, 4, 1048591, 0, 131073, 1048592, 0, 4, 1048593, 0, 4, 1048594, 0, 4, 1048595, 0, 131073, 1048596, 0, 131073, 1048597, 0, 131073, 1048598, 0, 131073, 1048599, 0, 4, 1048600, 0, 4, 1048601, 0, 131073, 1048602, 0, 4, 1048603, 0, 131073, 1048604, 0, 4, 1048605, 0, 131073, 1048606, 0, 131073, 1048607, 0, 4, 1048608, 0, 131073, 1048609, 0, 4, 1048610, 0, 131073, 1048611, 0, 4, 1048612, 0, 4, 1048613, 0, 131073, 1048614, 0, 131073, 1048615, 0, 4, 1048616, 0, 4, 1048617, 0, 131073, 1048618, 0, 4, 1048619, 0, 131073, 1048620, 0, 131074 ) + +[node name="WiseOldDude" parent="." instance=ExtResource( 8 )] +position = Vector2( 643, 161 ) + +[node name="CutsceneAreas" type="Node2D" parent="."] + +[node name="OldDudeIntroArea" type="Area2D" parent="CutsceneAreas"] +position = Vector2( 560, 182 ) +collision_layer = 0 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CutsceneAreas/OldDudeIntroArea"] +position = Vector2( 0, -27 ) +shape = SubResource( 1 ) + +[node name="Player" parent="." instance=ExtResource( 3 )] +position = Vector2( 77, 218 ) +abilities = { +"attack": true, +"dash": true, +"light_beam": true, +"wall_jump": true +} +[connection signal="body_entered" from="CutsceneAreas/OldDudeIntroArea" to="." method="_on_OldDudeIntroArea_body_entered"] diff --git a/src/HUD/HUD.gd b/src/HUD/HUD.gd index 74768c5..a30f3ca 100644 --- a/src/HUD/HUD.gd +++ b/src/HUD/HUD.gd @@ -16,18 +16,24 @@ func _physics_process(delta: float) -> void: var fresh_data = GameState.get_run_data() for key in fresh_data: if not fresh_data[key] == _data_ref[key]: - print("[%s]: %s -> %s" % [str(key), str(_data_ref[key]), str(fresh_data[key])]) match(str(key)): "coins": $UI/CoinLabel.text = str(fresh_data.coins) - $UI/CoinLabel/AnimationPlayer.seek(0) - $UI/CoinLabel/AnimationPlayer.play("updated") + _play_update_label_animation($UI/CoinLabel/AnimationPlayer) "deaths": $UI/DeathsLabel.text = str(fresh_data.deaths) + _play_update_label_animation($UI/DeathsLabel/AnimationPlayer) + "time": + var time_remaining = (GameState.GAME_TIMEOUT_MIN * 60) - fresh_data.time + $UI/TimeLabel.text = Utils.parse_seconds_to_display_str(time_remaining) pass _data_ref = fresh_data +func _play_update_label_animation(player:AnimationPlayer): + player.seek(0) + player.play("updated") + func _handle_pause(): if Input.is_action_just_pressed("pause"): if _paused: diff --git a/src/HUD/HUD.tscn b/src/HUD/HUD.tscn index cef3a4f..dcfc0ed 100644 --- a/src/HUD/HUD.tscn +++ b/src/HUD/HUD.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=9 format=2] [ext_resource path="res://src/HUD/HUD.gd" type="Script" id=1] [ext_resource path="res://src/Menu/PauseMenu.tscn" type="PackedScene" id=2] [ext_resource path="res://assets/Theme/Theme.tres" type="Theme" id=3] [ext_resource path="res://assets/HUD/coins_hud.png" type="Texture" id=4] [ext_resource path="res://assets/HUD/lifes_icon.png" type="Texture" id=5] +[ext_resource path="res://assets/HUD/time_hud.png" type="Texture" id=6] [sub_resource type="Animation" id=1] resource_name = "updated" @@ -22,6 +23,22 @@ tracks/0/keys = { "values": [ Vector2( 2, 2 ), Vector2( 1, 1 ) ] } +[sub_resource type="Animation" id=2] +resource_name = "updated" +length = 0.2 +tracks/0/type = "value" +tracks/0/path = NodePath(".:rect_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.2 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 2, 2 ), Vector2( 1, 1 ) ] +} + [node name="HUD" type="CanvasLayer"] script = ExtResource( 1 ) PauseMenu = ExtResource( 2 ) @@ -35,10 +52,11 @@ __meta__ = { [node name="Coin" type="TextureRect" parent="UI"] margin_left = 18.0 -margin_top = 13.0 -margin_right = 27.0 +margin_top = 8.0 +margin_right = 32.0 margin_bottom = 22.0 texture = ExtResource( 4 ) +expand = true __meta__ = { "_edit_use_anchors_": false } @@ -58,18 +76,18 @@ __meta__ = { anims/updated = SubResource( 1 ) [node name="Deaths" type="TextureRect" parent="UI"] -margin_left = 11.0 -margin_top = 22.0 -margin_right = 33.0 -margin_bottom = 44.0 +margin_left = 80.0 +margin_top = 4.0 +margin_right = 102.0 +margin_bottom = 26.0 texture = ExtResource( 5 ) expand = true [node name="DeathsLabel" type="Label" parent="UI"] -margin_left = 38.0 -margin_top = 30.0 -margin_right = 78.0 -margin_bottom = 44.0 +margin_left = 107.0 +margin_top = 13.0 +margin_right = 147.0 +margin_bottom = 27.0 theme = ExtResource( 3 ) text = "0" __meta__ = { @@ -77,3 +95,26 @@ __meta__ = { } [node name="AnimationPlayer" type="AnimationPlayer" parent="UI/DeathsLabel"] +anims/updated = SubResource( 2 ) + +[node name="Time" type="TextureRect" parent="UI"] +margin_left = 152.0 +margin_top = 8.0 +margin_right = 167.0 +margin_bottom = 23.0 +texture = ExtResource( 6 ) +expand = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TimeLabel" type="Label" parent="UI"] +margin_left = 174.0 +margin_top = 13.0 +margin_right = 214.0 +margin_bottom = 27.0 +theme = ExtResource( 3 ) +text = "0" +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/Menu/MainMenu.tscn b/src/Menu/MainMenu.tscn index e914348..a9b78ea 100644 --- a/src/Menu/MainMenu.tscn +++ b/src/Menu/MainMenu.tscn @@ -8,27 +8,27 @@ [ext_resource path="res://src/Menu/MainMenu.gd" type="Script" id=6] [ext_resource path="res://assets/Theme/menu_font.tres" type="DynamicFont" id=7] -[sub_resource type="Gradient" id=2] +[sub_resource type="Gradient" id=1] colors = PoolColorArray( 0.996094, 0.996094, 0.996094, 1, 1, 1, 1, 0 ) -[sub_resource type="GradientTexture" id=3] -gradient = SubResource( 2 ) +[sub_resource type="GradientTexture" id=2] +gradient = SubResource( 1 ) -[sub_resource type="Curve" id=7] +[sub_resource type="Curve" id=3] min_value = -200.0 max_value = 200.0 _data = [ Vector2( 0, 7.83957 ), 0.0, 166.434, 0, 0, Vector2( 1, 44.2032 ), -4.82953, 0.0, 0, 0 ] -[sub_resource type="CurveTexture" id=8] -curve = SubResource( 7 ) +[sub_resource type="CurveTexture" id=4] +curve = SubResource( 3 ) -[sub_resource type="Curve" id=4] +[sub_resource type="Curve" id=5] _data = [ Vector2( 0, 0.285227 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ] -[sub_resource type="CurveTexture" id=5] -curve = SubResource( 4 ) +[sub_resource type="CurveTexture" id=6] +curve = SubResource( 5 ) -[sub_resource type="ParticlesMaterial" id=6] +[sub_resource type="ParticlesMaterial" id=7] emission_shape = 2 emission_box_extents = Vector3( 10, 1, 1 ) flag_disable_z = true @@ -39,14 +39,13 @@ initial_velocity = 20.0 initial_velocity_random = 0.7 orbit_velocity = 0.0 orbit_velocity_random = 0.0 -linear_accel_curve = SubResource( 8 ) +linear_accel_curve = SubResource( 4 ) scale = 3.0 scale_random = 1.0 -scale_curve = SubResource( 5 ) -color_ramp = SubResource( 3 ) +scale_curve = SubResource( 6 ) +color_ramp = SubResource( 2 ) -[sub_resource type="Animation" id=1] -resource_name = "main" +[sub_resource type="Animation" id=8] length = 6.0 loop = true step = 1.0 @@ -160,7 +159,7 @@ amount = 50 lifetime = 2.5 speed_scale = 0.4 explosiveness = 0.1 -process_material = SubResource( 6 ) +process_material = SubResource( 7 ) [node name="Sprite3" type="Sprite" parent="Node2D"] light_mask = 4 @@ -170,7 +169,7 @@ centered = false [node name="AnimationPlayer" type="AnimationPlayer" parent="Node2D"] autoplay = "main" -anims/main = SubResource( 1 ) +anims/main = SubResource( 8 ) [node name="CanvasLayer" type="CanvasLayer" parent="."] diff --git a/src/Menu/PauseMenu.tscn b/src/Menu/PauseMenu.tscn index f09e86b..b8a885b 100644 --- a/src/Menu/PauseMenu.tscn +++ b/src/Menu/PauseMenu.tscn @@ -68,6 +68,7 @@ pause_mode = 2 script = ExtResource( 3 ) [node name="CanvasLayer" type="CanvasLayer" parent="."] +layer = 3 [node name="TextureRect" type="TextureRect" parent="CanvasLayer"] self_modulate = Color( 1, 1, 1, 0 ) diff --git a/src/Scripts/CutScene.gd b/src/Scripts/CutScene.gd new file mode 100644 index 0000000..b5033a1 --- /dev/null +++ b/src/Scripts/CutScene.gd @@ -0,0 +1,21 @@ +extends Node2D + +class_name CutScene + +signal cutscene_finished + +export var scene:PackedScene + +var _main_camera_ref:Camera2D +var _camera:Camera2D + + +func start_scene(camera:Camera2D): + var scene_inst = scene.instance() + add_child(scene_inst) + scene_inst.connect("tree_exited", self, "_on_scene_exited") + pass + +func end_scene(): + emit_signal("cutscene_finished") + queue_free() diff --git a/src/Singletons/GameState.gd b/src/Singletons/GameState.gd index a851290..bbc7901 100644 --- a/src/Singletons/GameState.gd +++ b/src/Singletons/GameState.gd @@ -8,7 +8,7 @@ enum States{ GAME, PUSE, STATS, - CUT_SCENE, + CUTSCENE, } var _SAVE_FILE_PATH = "user://data" # Change key in release @@ -16,9 +16,11 @@ var _ENCRYPTION_KEY = "fas3uyf076HJsiUDs24dfI9" var _SCENES := { States.MAIN_MENU: "res://src/Menu/MainMenu.tscn", - States.GAME: "res://src/Levels/LevelTemplate/LevelTemplate.tscn", + States.GAME: "res://src/GameWorld/GameWorld.tscn", } +var GAME_TIMEOUT_MIN = 10 + var _data := { "statistics": { "deaths": 0, @@ -51,6 +53,11 @@ var _state = States.INTRO func _ready() -> void: load_data() print(get_statistics()) + +func _physics_process(delta: float) -> void: + if _state == States.GAME: + _run_data.time += delta + _data.statistics.total_time_played += delta func load_data(): var data_file = File.new() @@ -77,13 +84,18 @@ func start_new_game(): _data.statistics.runs += 1 save_data() get_tree().change_scene_to(load(_SCENES[_state])) +func start_cutscene(): + _state = States.CUTSCENE +func end_cutscene(): + _state = States.GAME func get_heigh_score(): return _data.heigh_score.duplicate() func get_statistics(): return _data.statistics.duplicate() func get_run_data(): return _run_data.duplicate() - +func get_state(): + return int(_state) func go_to_main_menu(): _state = States.MAIN_MENU save_data() diff --git a/src/Singletons/Utils.gd b/src/Singletons/Utils.gd new file mode 100644 index 0000000..9fd1eb8 --- /dev/null +++ b/src/Singletons/Utils.gd @@ -0,0 +1,13 @@ +extends Node + +func parse_seconds_to_display_str(_seconds:float, show_hours:bool=false)->String: + var rounded_input = int(floor(_seconds)) + var hours_in_seconds = 3600 + var minute_in_seconds = 60 + + var hours = 0 + var minutes_seconds_str = "%02d:%02d" % [(rounded_input / minute_in_seconds) % 60, rounded_input % 60] + if show_hours: + return "%02d:%s" % [floor(rounded_input / hours_in_seconds), minutes_seconds_str] + return minutes_seconds_str +