continued from previous commit

This commit is contained in:
D L 2023-01-28 16:19:29 -08:00
parent 4cfa04e490
commit 34927f93ea
5 changed files with 117 additions and 32 deletions

View File

@ -1,16 +1,67 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://Tile Sets/SnowySlopes.tres" type="TileSet" id=1] [ext_resource path="res://Tile Sets/SnowySlopes.tres" type="TileSet" id=1]
[ext_resource path="res://Units/DownhillAutoscrollerPlayer.tscn" type="PackedScene" id=2] [ext_resource path="res://Units/DownhillAutoscrollerPlayer.tscn" type="PackedScene" id=2]
[ext_resource path="res://Tile Sets/SnowySlopesExtra.tres" type="TileSet" id=3] [ext_resource path="res://Tile Sets/SnowySlopesExtra.tres" type="TileSet" id=3]
[ext_resource path="res://Scripts/GameScene.gd" type="Script" id=5] [ext_resource path="res://Scripts/GameScene.gd" type="Script" id=5]
[sub_resource type="Animation" id=1]
resource_name = "PitTransition"
length = 1.5
tracks/0/type = "value"
tracks/0/path = NodePath(".: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.9, 1.5 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 0, 0, 0, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("../../Player")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.9 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "respawn_from_pit"
} ]
}
[sub_resource type="Animation" id=2]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ) ]
}
[node name="Scene" type="Node"] [node name="Scene" type="Node"]
script = ExtResource( 5 ) script = ExtResource( 5 )
__meta__ = {
"_edit_horizontal_guides_": [ 214.0, 332.0, 1379.0 ],
"_edit_vertical_guides_": [ 2134.0, 3833.0, 10449.0 ]
}
tile_set_name = "SnowySlopes" tile_set_name = "SnowySlopes"
camera_h_offset = 2.5 camera_h_offset = 2.5
spawning = { spawning = {
Vector2( 1, 1 ): "NPC" Vector2( 45, -6 ): "NPC",
Vector2( 80, -7 ): "NPC",
Vector2( 218, -29 ): "NPC"
} }
[node name="Stage" type="TileMap" parent="."] [node name="Stage" type="TileMap" parent="."]
@ -31,4 +82,18 @@ position = Vector2( 10, -150 )
[node name="Camera2D" type="Camera2D" parent="Player"] [node name="Camera2D" type="Camera2D" parent="Player"]
offset = Vector2( 0, -15 ) offset = Vector2( 0, -15 )
smoothing_speed = 6.0
[node name="SpectatorCam" type="Camera2D" parent="."]
offset = Vector2( 0, -15 )
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[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 )
[node name="PitTransitionPlayer" type="AnimationPlayer" parent="CanvasLayer/ColorRect"]
anims/PitTransition = SubResource( 1 )
anims/RESET = SubResource( 2 )

View File

@ -208,7 +208,7 @@ const GRAVITY = 16.1 # gravity = 32.17 ft/s^2, grid unit is 2ft
const MAX_FALL_SPEED = -37 const MAX_FALL_SPEED = -37
const ACCELERATION = 35 const ACCELERATION = 35
const QUANTUM_DIST = 0.001 const QUANTUM_DIST = 0.001
const SPAWN_DISTANCE = 10 const SPAWN_DISTANCE = 20
# specialized constants # specialized constants
const FLASH_CYCLE = 0.15 const FLASH_CYCLE = 0.15

View File

@ -253,6 +253,15 @@ func check_collision(unit : Unit, collider, collision_into_directions, delta):
if intersects_results[0]: if intersects_results[0]:
if is_ground_collision: if is_ground_collision:
if unit_env_collider[0] == Vector2(0, 0): if unit_env_collider[0] == Vector2(0, 0):
# slope acceleration for DownhillAutoscroller:
# set the player's last_contacted_map_elem_type field
if unit is DownhillAutoscrollerPlayer:
unit.last_contacted_map_elem_type = collider_to_map_elem_type[collider]
if collider_to_map_elem_type[collider] == Constants.MapElemType.OOB_LOWER:
# this collision should have no effect
return false
unit.pos.y = intersects_results[1].y + Constants.QUANTUM_DIST unit.pos.y = intersects_results[1].y + Constants.QUANTUM_DIST
unit.pos.x = intersects_results[1].x unit.pos.x = intersects_results[1].x
if unit.unit_conditions[Constants.UnitCondition.IS_ON_GROUND]: if unit.unit_conditions[Constants.UnitCondition.IS_ON_GROUND]:
@ -265,12 +274,6 @@ func check_collision(unit : Unit, collider, collision_into_directions, delta):
unit.v_speed = 0 unit.v_speed = 0
unit.landed() unit.landed()
reangle_move(unit, collider, false) reangle_move(unit, collider, false)
# slope acceleration for DownhillAutoscroller:
# set the player's last_contacted_map_elem_type field
if unit is DownhillAutoscrollerPlayer:
unit.last_contacted_map_elem_type = collider_to_map_elem_type[collider]
else: else:
if collider[0].x == collider[1].x: if collider[0].x == collider[1].x:
# vertical wall collision # vertical wall collision

View File

@ -11,6 +11,8 @@ 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 respawn_pos : Vector2
func execute_actions(delta): func execute_actions(delta):
.execute_actions(delta) .execute_actions(delta)
for action_num in Constants.UNIT_TYPE_ACTIONS[Constants.UnitType.PLAYER]: for action_num in Constants.UNIT_TYPE_ACTIONS[Constants.UnitType.PLAYER]:
@ -46,10 +48,6 @@ func process_unit(delta, time_elapsed : float):
facing = Constants.Direction.RIGHT facing = Constants.Direction.RIGHT
actions[Constants.ActionType.MOVE] = true actions[Constants.ActionType.MOVE] = true
# Check if fallen off
if last_contacted_map_elem_type == Constants.MapElemType.OOB_LOWER:
oob_lower()
# Fine tune the player's speed # Fine tune the player's speed
if get_current_action() == Constants.UnitCurrentAction.RECOILING: if get_current_action() == Constants.UnitCurrentAction.RECOILING:
@ -145,7 +143,11 @@ func landed():
target_move_speed += boost target_move_speed += boost
boost = 0 boost = 0
func oob_lower(): func react(delta):
.react(delta)
# Check if fallen off
if last_contacted_map_elem_type == Constants.MapElemType.OOB_LOWER:
# Called when the player falls in a hole # Called when the player falls in a hole
# Calculate respawn point # Calculate respawn point
@ -156,13 +158,28 @@ func oob_lower():
tile += Vector2.RIGHT tile += Vector2.RIGHT
while tilemap.get_cellv(tile) >= 0: while tilemap.get_cellv(tile) >= 0:
tile += Vector2.UP tile += Vector2.UP
pos = tile respawn_pos = tile
pos.x += 0.5 respawn_pos.x += 0.5
pos.y *= -1 respawn_pos.y *= -1
last_contacted_map_elem_type = Constants.MapElemType.SLOPE_LEFT last_contacted_map_elem_type = Constants.MapElemType.SLOPE_LEFT
# ======================= # =======================
# reset speed # reset speed
# should other things be done here? # should other things be done here?
h_speed = 0 # - player's ongoing trick has to be reset
# - camera has to freeze its y position as player drops offscreen
# - a smooth transition has to play
# - player starts off recoiling and slowed down (they are hit)
var spectator_cam : Camera2D = get_node("../SpectatorCam")
spectator_cam.position = get_node("Camera2D").get_camera_screen_center()
spectator_cam.offset = get_node("Camera2D").offset
spectator_cam.make_current()
var anim_player : AnimationPlayer = scene.find_node("PitTransitionPlayer")
anim_player.play("PitTransition")
func respawn_from_pit():
pos = respawn_pos
hit(Constants.Direction.RIGHT)
boost = 0
get_node("Camera2D").make_current()

Binary file not shown.