in-game UI, plus refine boost logic
This commit is contained in:
parent
ed6def77f5
commit
b5da1cf566
14 changed files with 3214 additions and 18 deletions
|
@ -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):
|
||||
|
|
|
@ -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
55
Scripts/InGameUI.gd
Normal 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
|
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue