Compare commits

...

4 Commits

Author SHA1 Message Date
gemdude46 fc5f9630bd replays 2023-01-30 19:49:06 +00:00
gemdude46 599dbb66e4 Merge branch 'alt-movement' 2023-01-30 19:10:58 +00:00
gemdude46 63a7788709 level 2 2023-01-30 19:10:26 +00:00
gemdude46 f4bbcb9bfb movement 2023-01-30 16:26:49 +00:00
15 changed files with 115 additions and 86 deletions

BIN
Replays/L1Easy.dat Normal file

Binary file not shown.

BIN
Replays/L2Easy.dat Normal file

Binary file not shown.

Binary file not shown.

View File

@ -6,6 +6,7 @@ var letty_snow = load("res://BGM/Letty_Snow_-_Utsuho.mp3")
var score_end = load("res://BGM/Score_End_-_Utsuho.mp3") var score_end = load("res://BGM/Score_End_-_Utsuho.mp3")
var player : AudioStreamPlayer var player : AudioStreamPlayer
var difficulty: String = "Easy"
func _ready(): func _ready():

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -61,6 +61,18 @@ enum MapElemType {
OOB_LOWER, OOB_LOWER,
} }
const ELEM_TYPE_SLOPE = [
2,
0,
4,
1,
1,
3,
3,
2,
2,
]
enum SpriteClass { enum SpriteClass {
IDLE, IDLE,
WALK, WALK,
@ -269,3 +281,27 @@ const SPAWN_DISTANCE = 20
# specialized constants # specialized constants
const FLASH_CYCLE = 0.15 const FLASH_CYCLE = 0.15
const SLOPE_SPEED = [
0.0,
0.0,
3.5,
7.3 * 1.118,
9.2 * 1.414,
]
const SLOPE_ACCEL = [
0.0,
0.0,
1.0,
2.2 * 1.118,
3.4 * 1.414,
]
const SLOPE_DECEL = [
5.0 * 1.414,
3.5 * 1.118,
0.3,
0.2,
0.1
]

View File

@ -108,7 +108,7 @@ func _process(delta):
if !stage_finished: if !stage_finished:
time_elapsed_in_race += delta time_elapsed_in_race += delta
# 1 grid unit = 2ft, 1 grid unit / s = 1.36 mph # 1 grid unit = 2ft, 1 grid unit / s = 1.36 mph
player_speed_mph = player.h_speed * 1.36 player_speed_mph = player.target_move_speed#player.h_speed * 1.36
if not race_over and player.pos.x >= finish_x_pos: if not race_over and player.pos.x >= finish_x_pos:
race_over = true race_over = true
@ -192,7 +192,7 @@ func handle_player_input():
if input_table[Constants.PlayerInput.GBA_A][I_T_PRESSED]: if input_table[Constants.PlayerInput.GBA_A][I_T_PRESSED]:
if (player.get_current_action() == Constants.UnitCurrentAction.JUMPING if (player.get_current_action() == Constants.UnitCurrentAction.JUMPING
or (player.get_current_action() == Constants.UnitCurrentAction.IDLE or ((player.get_current_action() == Constants.UnitCurrentAction.IDLE)
and input_table[Constants.PlayerInput.GBA_A][I_T_JUST_PRESSED])): and input_table[Constants.PlayerInput.GBA_A][I_T_JUST_PRESSED])):
if player.unit_conditions[Constants.UnitCondition.IS_ON_GROUND] or player.get_current_action() == Constants.UnitCurrentAction.JUMPING: if player.unit_conditions[Constants.UnitCondition.IS_ON_GROUND] or player.get_current_action() == Constants.UnitCurrentAction.JUMPING:
player.set_action(Constants.ActionType.JUMP) player.set_action(Constants.ActionType.JUMP)

View File

@ -2,7 +2,7 @@ extends Node
class_name PlayerRecorder class_name PlayerRecorder
var replay: ReplayRecording var replay: ReplayRecording
var this_frame: bool = true var this_frame: int = 0
var sprite: int = 0 var sprite: int = 0
var player: Node var player: Node
var scene: Node var scene: Node
@ -20,15 +20,15 @@ func _ready():
player.recorder = self player.recorder = self
scene = player.get_parent() scene = player.get_parent()
func _process(_delta): func _physics_process(_delta):
if this_frame: if this_frame == 0:
this_frame = false this_frame = 1
replay.positions.append(player.pos) replay.positions.append(player.pos)
replay.sprites.append(sprite) replay.sprites.append(sprite)
replay.frames += 1 replay.frames += 1
else: else:
this_frame = true this_frame -= 1
func save(): func save():
replay.save_to_uri(save_to) replay.save_to_uri(save_to)

View File

@ -160,10 +160,8 @@ func jump():
v_speed = max(Constants.UNIT_TYPE_JUMP_SPEEDS[unit_type], v_speed) v_speed = max(Constants.UNIT_TYPE_JUMP_SPEEDS[unit_type], v_speed)
else: else:
# airborne # airborne
print("airjump")
print(v_speed)
v_speed = max(Constants.UNIT_TYPE_JUMP_SPEEDS[unit_type], move_toward(v_speed, Constants.UNIT_TYPE_JUMP_SPEEDS[unit_type], get_process_delta_time() * Constants.GRAVITY)) v_speed = max(Constants.UNIT_TYPE_JUMP_SPEEDS[unit_type], move_toward(v_speed, Constants.UNIT_TYPE_JUMP_SPEEDS[unit_type], get_process_delta_time() * Constants.GRAVITY))
print(v_speed)
set_unit_condition(Constants.UnitCondition.IS_ON_GROUND, false) set_unit_condition(Constants.UnitCondition.IS_ON_GROUND, false)
if get_current_action() == Constants.UnitCurrentAction.JUMPING and v_speed > 0: if get_current_action() == Constants.UnitCurrentAction.JUMPING and v_speed > 0:
set_sprite(Constants.SpriteClass.JUMP, 0) set_sprite(Constants.SpriteClass.JUMP, 0)

View File

@ -5,11 +5,13 @@ class_name DownhillAutoscrollerPlayer
export var min_speed : float = 3 export var min_speed : float = 3
export var max_speed : float = 11 export var max_speed : float = 11
export var player_initiated_acceleration : float = 5 export var player_initiated_acceleration : float = 5
export var boost_per_second : float = 6 / 1.36 # 6 mph export var boost_per_second : float = 4 / 1.36 # 6 mph
var last_contacted_map_elem_type : int = Constants.MapElemType.SQUARE var last_contacted_map_elem_type : int = Constants.MapElemType.SQUARE
var boost : float = 0 # to movement speed var boost : float = 0 # to movement speed
var boost_effect: float = 0
var instant_accel: bool = false
var respawn_pos : Vector2 var respawn_pos : Vector2
@ -94,77 +96,59 @@ func handle_idle():
if boost == 0: if boost == 0:
.handle_idle() .handle_idle()
func handle_speed(delta):
if get_current_action() == Constants.UnitCurrentAction.RECOILING:
target_move_speed = min_speed
return
if scene.input_table[Constants.PlayerInput.LEFT][scene.I_T_PRESSED]:
target_move_speed = move_toward(target_move_speed, min_speed, player_initiated_acceleration * delta)
boost_effect = 0.0
return
var slope: int = Constants.ELEM_TYPE_SLOPE[last_contacted_map_elem_type]
var speed_limit: float = Constants.SLOPE_SPEED[slope]
var accel: float = player_initiated_acceleration
if not get_condition(Constants.UnitCondition.IS_ON_GROUND, true):
speed_limit = target_move_speed
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED] and speed_limit < Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type]:
speed_limit = Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type]
speed_limit = max(min_speed, speed_limit)
if get_condition(Constants.UnitCondition.IS_ON_GROUND, true):
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
speed_limit += 1.0
if boost_effect > 0:
speed_limit += boost_effect
if target_move_speed < boost_effect:
boost_effect = 0.0
elif slope < 2:
boost_effect -= delta
accel = (Constants.SLOPE_ACCEL if target_move_speed < speed_limit else Constants.SLOPE_DECEL)[slope]
target_move_speed = move_toward(target_move_speed, speed_limit, accel * delta)
if target_move_speed > speed_limit + 4.0:
target_move_speed -= speed_limit
target_move_speed *= pow(0.5, delta)
target_move_speed += speed_limit
func process_unit(delta, time_elapsed : float): func process_unit(delta, time_elapsed : float):
# always be movin' # always be movin'
facing = Constants.Direction.RIGHT facing = Constants.Direction.RIGHT
actions[Constants.ActionType.MOVE] = true actions[Constants.ActionType.MOVE] = true
# Fine tune the player's speed handle_speed(delta)
print(last_contacted_map_elem_type) if boost_effect > 0:
boost_effect -= delta
if get_current_action() == Constants.UnitCurrentAction.RECOILING:
target_move_speed = min_speed
else:
# override player input so that leftward movement is deceleration,
# right movement is acceleration
if scene.input_table[Constants.PlayerInput.LEFT][scene.I_T_PRESSED]:
target_move_speed = move_toward(target_move_speed, min_speed, player_initiated_acceleration * delta)
else:
if not get_condition(Constants.UnitCondition.IS_ON_GROUND, true):
if (target_move_speed < Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type]
and scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]):
target_move_speed = move_toward(target_move_speed, Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type], player_initiated_acceleration * delta)
if target_move_speed > max_speed:
target_move_speed = move_toward(target_move_speed, max_speed, player_initiated_acceleration * delta)
else:
# shallow slope: arctan(.5) = 27 degrees, sin(27) = 0.45
# steep slope: sin(45) = 0.71
var ground_influenced_acceleration = 0
var is_decel : bool = false
if (last_contacted_map_elem_type == Constants.MapElemType.SMALL_SLOPE_RIGHT_1
or last_contacted_map_elem_type == Constants.MapElemType.SMALL_SLOPE_RIGHT_2
or last_contacted_map_elem_type == Constants.MapElemType.SMALL_SLOPE_LEFT_1
or last_contacted_map_elem_type == Constants.MapElemType.SMALL_SLOPE_LEFT_2):
ground_influenced_acceleration = Constants.GRAVITY * 0.45
if (last_contacted_map_elem_type == Constants.MapElemType.SMALL_SLOPE_LEFT_1
or last_contacted_map_elem_type == Constants.MapElemType.SMALL_SLOPE_LEFT_2):
is_decel = true
elif (last_contacted_map_elem_type == Constants.MapElemType.SLOPE_RIGHT
or last_contacted_map_elem_type == Constants.MapElemType.SLOPE_LEFT):
ground_influenced_acceleration = Constants.GRAVITY * 0.71
if last_contacted_map_elem_type == Constants.MapElemType.SLOPE_LEFT:
is_decel = true
if is_decel or ground_influenced_acceleration == 0:
var end_speed
if ground_influenced_acceleration == 0:
# flat ground
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
end_speed = max(min(target_move_speed, max_speed), Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type])
else:
end_speed = min(target_move_speed, max_speed)
else:
# incline
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
end_speed = Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type]
else:
end_speed = min_speed
if target_move_speed < end_speed:
target_move_speed = move_toward(target_move_speed, end_speed, player_initiated_acceleration * delta)
else:
if ground_influenced_acceleration > 0:
target_move_speed = move_toward(target_move_speed, end_speed, ground_influenced_acceleration * delta)
else:
target_move_speed = move_toward(target_move_speed, end_speed, player_initiated_acceleration * delta)
else:
var acceleration = ground_influenced_acceleration
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
acceleration = max(acceleration, player_initiated_acceleration)
if target_move_speed < max_speed:
target_move_speed = move_toward(target_move_speed, max_speed, acceleration * delta)
else:
target_move_speed = move_toward(target_move_speed, max_speed, player_initiated_acceleration * delta)
.process_unit(delta, time_elapsed) .process_unit(delta, time_elapsed)
# treat all collisions as right-side collisions # treat all collisions as right-side collisions
@ -204,8 +188,8 @@ func landed():
return return
if boost > 0: if boost > 0:
scene.find_node("CanvasLayer").flash_boost = true scene.find_node("CanvasLayer").flash_boost = true
h_speed += boost boost_effect += boost
target_move_speed = h_speed target_move_speed += boost
boost = 0 boost = 0
func react(delta): func react(delta):
@ -249,7 +233,13 @@ func react(delta):
func respawn_from_pit(): func respawn_from_pit():
pos = respawn_pos pos = respawn_pos
hit(Constants.Direction.RIGHT) #hit(Constants.Direction.RIGHT)
set_unit_condition_with_timer(Constants.UnitCondition.IS_INVINCIBLE)
start_flash()
get_node("SpinningSprite").visible = false
get_node("SpinningSprite").rotation = 0
hit_audiostream_player.play()
boost = 0 boost = 0
boost_effect = 0
get_node("Camera2D").make_current() get_node("Camera2D").make_current()

View File

@ -7,7 +7,7 @@ export var replay_file: String
func _ready(): func _ready():
._ready() ._ready()
replay = ReplayRecording.new() replay = ReplayRecording.new()
replay.load_from_uri(replay_file) replay.load_from_uri(replay_file % MusicController.difficulty)
func process_unit(delta : float, time_elapsed : float): func process_unit(delta : float, time_elapsed : float):

View File

@ -15,6 +15,7 @@ extents = Vector2( 9, 34 )
z_index = 1 z_index = 1
collision_layer = 0 collision_layer = 0
script = ExtResource( 1 ) script = ExtResource( 1 )
unit_type = 1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, -36 ) position = Vector2( 0, -36 )

View File

@ -14,6 +14,7 @@ extents = Vector2( 9, 34 )
z_index = 1 z_index = 1
collision_layer = 0 collision_layer = 0
script = ExtResource( 1 ) script = ExtResource( 1 )
unit_type = 1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, -36 ) position = Vector2( 0, -36 )

View File

@ -63,7 +63,7 @@ _global_script_class_icons={
[application] [application]
config/name="Moriya's Wanton Winter Wager" config/name="Moriya's Wanton Winter Wager"
run/main_scene="res://Scenes/DownhillAutoscroller.tscn" run/main_scene="res://Scenes/DownhillAutoscroller2.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload] [autoload]