in-game UI, plus refine boost logic

This commit is contained in:
D L 2023-01-30 00:02:47 -08:00
parent ed6def77f5
commit b5da1cf566
14 changed files with 3214 additions and 18 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,10 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://Fonts/squares/Squares Bold Free.otf" type="DynamicFontData" id=1]
[resource]
size = 24
outline_size = 3
outline_color = Color( 0.0431373, 0.368627, 0.396078, 1 )
extra_spacing_char = 4
font_data = ExtResource( 1 )

View File

@ -0,0 +1,9 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://Fonts/squares/Squares Bold Free.otf" type="DynamicFontData" id=1]
[resource]
outline_size = 2
outline_color = Color( 0, 0, 0, 1 )
extra_spacing_char = 4
font_data = ExtResource( 1 )

View File

@ -181,7 +181,6 @@ anims/InitialFade = SubResource( 1 )
anims/RESET = SubResource( 2 )
[node name="ColorRect" type="ColorRect" parent="."]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 1 )

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=2]
[gd_scene load_steps=18 format=2]
[ext_resource path="res://Tile Sets/SnowySlopes.tres" type="TileSet" id=1]
[ext_resource path="res://Units/DownhillAutoscrollerPlayer.tscn" type="PackedScene" id=2]
@ -11,6 +11,9 @@
[ext_resource path="res://Sounds/sfx_jump_07-80241.mp3" type="AudioStream" id=9]
[ext_resource path="res://Sounds/land2-43790.mp3" type="AudioStream" id=10]
[ext_resource path="res://Sounds/ski-67717.wav" type="AudioStream" id=11]
[ext_resource path="res://Fonts/squares/squares.tres" type="DynamicFont" id=12]
[ext_resource path="res://Scripts/InGameUI.gd" type="Script" id=13]
[ext_resource path="res://Fonts/squares/squares_big.tres" type="DynamicFont" id=14]
[sub_resource type="Animation" id=3]
resource_name = "InitialFade"
@ -80,7 +83,6 @@ __meta__ = {
"_edit_vertical_guides_": [ 2134.0, 3833.0 ]
}
tile_set_name = "SnowySlopes"
camera_h_offset = 2.5
spawning = {
Vector2( 45, -6 ): "CIRNO",
Vector2( 80, -7 ): "SANAE",
@ -113,6 +115,7 @@ position = Vector2( 91, -197 )
[node name="Camera2D" type="Camera2D" parent="Player"]
offset = Vector2( 0, -15 )
smoothing_speed = 7.0
[node name="SpectatorCam" type="Camera2D" parent="."]
offset = Vector2( 0, -15 )
@ -121,12 +124,45 @@ offset = Vector2( 0, -15 )
position = Vector2( 91, -197 )
[node name="CanvasLayer" type="CanvasLayer" parent="."]
script = ExtResource( 13 )
[node name="Speedometer" type="RichTextLabel" parent="CanvasLayer"]
margin_left = 20.0
margin_top = 20.0
margin_right = 170.0
margin_bottom = 80.0
custom_colors/default_color = Color( 0.560784, 0.972549, 0.886275, 1 )
custom_fonts/normal_font = ExtResource( 14 )
text = "+00 MPH"
fit_content_height = true
scroll_active = false
[node name="Timer" type="RichTextLabel" parent="CanvasLayer"]
margin_left = 870.0
margin_top = 20.0
margin_right = 1020.0
margin_bottom = 80.0
custom_colors/default_color = Color( 0.560784, 0.972549, 0.886275, 1 )
custom_fonts/normal_font = ExtResource( 14 )
text = "+00 MPH"
fit_content_height = true
scroll_active = false
[node name="BoostLabel" type="RichTextLabel" parent="CanvasLayer"]
margin_left = 150.0
margin_top = 150.0
margin_right = 300.0
margin_bottom = 180.0
custom_fonts/normal_font = ExtResource( 12 )
text = "+00 MPH"
fit_content_height = true
scroll_active = false
[node name="ColorRect" type="ColorRect" parent="CanvasLayer"]
modulate = Color( 1, 1, 1, 0 )
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0.12549, 0.231373, 0.2, 1 )
color = Color( 0, 0, 0, 1 )
[node name="PitTransitionPlayer" type="AnimationPlayer" parent="CanvasLayer/ColorRect"]
anims/InitialFade = SubResource( 3 )

View File

@ -13,9 +13,6 @@
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 6 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="."]
margin_right = 1024.0

View File

@ -36,16 +36,11 @@ margin_right = 177.0
margin_bottom = 745.0
custom_fonts/font = ExtResource( 2 )
text = "Back"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CenterContainer" type="CenterContainer" parent="."]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 512.0

View File

@ -69,6 +69,7 @@ func dialogue_fade_done():
dialogue_fading_in = false
func final_fade_done():
get_node("ColorRect").modulate.a = 255
get_tree().change_scene("res://Scenes/" + next_scene_to_load + ".tscn")
func _process(delta):

View File

@ -9,7 +9,8 @@ extends Node
class_name GameScene
export var tile_set_name: String
export var camera_h_offset : float = 1
export var camera_h_offset : float = 3
export var camera_v_offset : float = 1
const Constants = preload("res://Scripts/Constants.gd")
const Unit = preload("res://Scripts/Unit.gd")
const UNIT_DIRECTORY = {
@ -26,6 +27,7 @@ var paused : bool = false
var units = []
var player : Player
var player_cam : Camera2D
var player_cam_easing_cum_time : float = 0
# [pressed?, just pressed?, just released?]
var input_table = {
@ -62,6 +64,7 @@ func _ready():
player.init_unit_w_scene(self)
player_cam = player.get_node("Camera2D")
player_cam.make_current()
player_cam.offset_v = camera_v_offset
units.append(get_node("Rival"))
get_node("Rival").init_unit_w_scene(self)
@ -74,7 +77,7 @@ func _ready():
find_node("PitTransitionPlayer").play("InitialFade")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _process(delta):
# visual effects
if (player.facing == Constants.Direction.RIGHT):
player_cam.offset_h = camera_h_offset

55
Scripts/InGameUI.gd Normal file
View File

@ -0,0 +1,55 @@
extends CanvasLayer
const Constants = preload("res://Scripts/Constants.gd")
const FLASH_BOOST_DUR : float = 1.0
const FLASH_BOOST_CYCLE : float = 0.1
var scene : GameScene
var player : DownhillAutoscrollerPlayer
var boost_label : RichTextLabel
var flash_boost : bool
var flash_time_elapsed : float
var speedometer : RichTextLabel
var timer : RichTextLabel
# Called when the node enters the scene tree for the first time.
func _ready():
scene = get_node("/root/Scene")
player = get_node("/root/Scene/Player")
speedometer = get_node("Speedometer")
timer = get_node("Timer")
boost_label = get_node("BoostLabel")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
speedometer.text = str(floor(scene.player_speed_mph)) + " MPH"
var dec_value : int = floor((scene.time_elapsed_in_race - floor(scene.time_elapsed_in_race))
* 100)
timer.text = str(floor(scene.time_elapsed_in_race)) + ":" + str(dec_value)
if player.get_current_action() == Constants.UnitCurrentAction.SPINNING:
flash_boost = false
flash_time_elapsed = 0
boost_label.remove_color_override("default_color")
boost_label.visible = true
boost_label.text = "+" + str(floor(player.boost * 1.36)) + " MPH"
else:
if flash_boost:
boost_label.add_color_override("default_color", Color.green)
flash_time_elapsed += delta
if flash_time_elapsed > FLASH_BOOST_DUR:
flash_boost = false
else:
if int(floor(flash_time_elapsed / FLASH_BOOST_CYCLE)) % 2 == 0:
boost_label.visible = true
else:
boost_label.visible = false
else:
boost_label.visible = false

View File

@ -271,8 +271,8 @@ func check_collision(unit : Unit, collider, collision_into_directions, delta):
if unit.get_current_action() != Constants.UnitCurrentAction.JUMPING:
unit.set_unit_condition(Constants.UnitCondition.IS_ON_GROUND, true)
# landed on ground, horizontal component to become magnitude
unit.v_speed = 0
unit.landed()
unit.v_speed = 0
reangle_move(unit, collider, false)
else:
if collider[0].x == collider[1].x:

View File

@ -5,7 +5,7 @@ class_name DownhillAutoscrollerPlayer
export var min_speed : float = 3
export var max_speed : float = 11
export var player_initiated_acceleration : float = 5
export var boost_per_second : float = 6
export var boost_per_second : float = 6 / 1.36 # 6 mph
var last_contacted_map_elem_type : int = Constants.MapElemType.SQUARE
@ -201,7 +201,10 @@ func landed():
boost = 0
spin_audiostream_player.stop()
return
target_move_speed += boost
if boost > 0:
scene.find_node("CanvasLayer").flash_boost = true
h_speed += boost
target_move_speed = h_speed
boost = 0
func react(delta):

Binary file not shown.