Added fall zones

This commit is contained in:
gemdude46 2023-01-28 09:25:49 +00:00
parent d02d369c13
commit c257f9c1ad
8 changed files with 64 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@ Vector2( 12, 3 ): "NPC"
tile_set = ExtResource( 1 ) tile_set = ExtResource( 1 )
cell_size = Vector2( 20, 20 ) cell_size = Vector2( 20, 20 )
format = 1 format = 1
tile_data = PoolIntArray( -786410, 0, 0, -786409, 2, 0, -720874, 6, 0, -720873, 8, 0, -655335, 19, 0, -655334, 21, 0, -524272, 0, 0, -524271, 2, 0, -524262, 19, 0, -524261, 20, 0, -524260, 21, 0, -458736, 6, 0, -458735, 8, 0, -393193, 19, 0, -393192, 20, 0, -393191, 20, 0, -393190, 21, 0, -327660, 16, 0, -327648, 0, 0, -327647, 1, 0, -327646, 1, 0, -327645, 2, 0, -262128, 0, 0, -262127, 2, 0, -262126, 9, 0, -262125, 10, 0, -262124, 5, 0, -262113, 15, 0, -262112, 4, 0, -262111, 4, 0, -262110, 4, 0, -262109, 5, 0, -196596, 9, 0, -196595, 10, 0, -196594, 1, 0, -196593, 1, 0, -196592, 4, 0, -196591, 4, 0, -196590, 4, 0, -196589, 4, 0, -196588, 5, 0, -196586, 0, 0, -196585, 2, 0, -196578, 15, 0, -196577, 4, 0, -196576, 4, 0, -196575, 4, 0, -196574, 4, 0, -196573, 5, 0, -131061, 15, 0, -131060, 4, 0, -131059, 4, 0, -131058, 4, 0, -131057, 4, 0, -131056, 4, 0, -131055, 4, 0, -131054, 4, 0, -131053, 4, 0, -131052, 5, 0, -131050, 3, 0, -131049, 5, 0, -131043, 15, 0, -131042, 4, 0, -131041, 4, 0, -131040, 4, 0, -131039, 4, 0, -131038, 4, 0, -131037, 5, 0, -65532, 0, 0, -65531, 2, 0, -65527, 9, 0, -65526, 10, 0, -65525, 4, 0, -65524, 4, 0, -65523, 4, 0, -65522, 4, 0, -65521, 4, 0, -65520, 4, 0, -65519, 4, 0, -65518, 4, 0, -65517, 4, 0, -65516, 5, 0, -65514, 3, 0, -65513, 4, 0, -65512, 13, 0, -65511, 12, 0, -65508, 15, 0, -65507, 4, 0, -65506, 4, 0, -65505, 4, 0, -65504, 4, 0, -65503, 4, 0, -65502, 4, 0, -65501, 5, 0, 0, 0, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 4, 4, 0, 5, 5, 0, 6, 22, 0, 7, 22, 0, 8, 0, 0, 9, 4, 0, 10, 4, 0, 11, 4, 0, 12, 4, 0, 13, 4, 0, 14, 4, 0, 15, 4, 0, 16, 4, 0, 17, 4, 0, 18, 4, 0, 19, 4, 0, 20, 5, 0, 22, 3, 0, 23, 4, 0, 24, 4, 0, 25, 4, 0, 26, 1, 0, 27, 1, 0, 28, 4, 0, 29, 4, 0, 30, 4, 0, 31, 4, 0, 32, 4, 0, 33, 4, 0, 34, 4, 0, 35, 5, 0 ) tile_data = PoolIntArray( -786410, 0, 0, -786409, 2, 0, -720874, 6, 0, -720873, 8, 0, -655335, 19, 0, -655334, 21, 0, -524272, 0, 0, -524271, 2, 0, -524262, 19, 0, -524261, 20, 0, -524260, 21, 0, -458736, 6, 0, -458735, 8, 0, -393193, 19, 0, -393192, 20, 0, -393191, 20, 0, -393190, 21, 0, -327660, 16, 0, -327648, 0, 0, -327647, 1, 0, -327646, 1, 0, -327645, 2, 0, -262128, 0, 0, -262127, 2, 0, -262126, 9, 0, -262125, 10, 0, -262124, 5, 0, -262113, 15, 0, -262112, 4, 0, -262111, 4, 0, -262110, 4, 0, -262109, 5, 0, -196596, 9, 0, -196595, 10, 0, -196594, 1, 0, -196593, 1, 0, -196592, 4, 0, -196591, 4, 0, -196590, 4, 0, -196589, 4, 0, -196588, 5, 0, -196586, 0, 0, -196585, 2, 0, -196578, 15, 0, -196577, 4, 0, -196576, 4, 0, -196575, 4, 0, -196574, 4, 0, -196573, 5, 0, -131061, 15, 0, -131060, 4, 0, -131059, 4, 0, -131058, 4, 0, -131057, 4, 0, -131056, 4, 0, -131055, 4, 0, -131054, 4, 0, -131053, 4, 0, -131052, 5, 0, -131051, 23, 0, -131050, 3, 0, -131049, 5, 0, -131043, 15, 0, -131042, 4, 0, -131041, 4, 0, -131040, 4, 0, -131039, 4, 0, -131038, 4, 0, -131037, 5, 0, -65532, 0, 0, -65531, 2, 0, -65527, 9, 0, -65526, 10, 0, -65525, 4, 0, -65524, 4, 0, -65523, 4, 0, -65522, 4, 0, -65521, 4, 0, -65520, 4, 0, -65519, 4, 0, -65518, 4, 0, -65517, 4, 0, -65516, 5, 0, -65514, 3, 0, -65513, 4, 0, -65512, 13, 0, -65511, 12, 0, -65508, 15, 0, -65507, 4, 0, -65506, 4, 0, -65505, 4, 0, -65504, 4, 0, -65503, 4, 0, -65502, 4, 0, -65501, 5, 0, 0, 0, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 4, 4, 0, 5, 5, 0, 6, 22, 0, 7, 22, 0, 8, 0, 0, 9, 4, 0, 10, 4, 0, 11, 4, 0, 12, 4, 0, 13, 4, 0, 14, 4, 0, 15, 4, 0, 16, 4, 0, 17, 4, 0, 18, 4, 0, 19, 4, 0, 20, 5, 0, 22, 3, 0, 23, 4, 0, 24, 4, 0, 25, 4, 0, 26, 1, 0, 27, 1, 0, 28, 4, 0, 29, 4, 0, 30, 4, 0, 31, 4, 0, 32, 4, 0, 33, 4, 0, 34, 4, 0, 35, 5, 0 )
[node name="Player" parent="." instance=ExtResource( 6 )] [node name="Player" parent="." instance=ExtResource( 6 )]
position = Vector2( 10, -150 ) position = Vector2( 10, -150 )

View File

@ -56,6 +56,7 @@ enum MapElemType {
SMALL_SLOPE_RIGHT_1, SMALL_SLOPE_RIGHT_1,
SMALL_SLOPE_RIGHT_2, SMALL_SLOPE_RIGHT_2,
LEDGE, LEDGE,
OOB_LOWER,
} }
enum SpriteClass { enum SpriteClass {
@ -162,6 +163,7 @@ const TILE_SET_MAP_ELEMS = {
MapElemType.SMALL_SLOPE_RIGHT_1: [12], MapElemType.SMALL_SLOPE_RIGHT_1: [12],
MapElemType.SMALL_SLOPE_RIGHT_2: [13, 14], MapElemType.SMALL_SLOPE_RIGHT_2: [13, 14],
MapElemType.LEDGE: [19, 20, 21, 22], MapElemType.LEDGE: [19, 20, 21, 22],
MapElemType.OOB_LOWER: [23],
}, },
} }

View File

@ -59,7 +59,8 @@ func init_stage_grid(tilemap : TileMap):
Constants.MapElemType.SMALL_SLOPE_LEFT_2, Constants.MapElemType.SMALL_SLOPE_LEFT_2,
Constants.MapElemType.SMALL_SLOPE_RIGHT_1, Constants.MapElemType.SMALL_SLOPE_RIGHT_1,
Constants.MapElemType.SMALL_SLOPE_RIGHT_2, Constants.MapElemType.SMALL_SLOPE_RIGHT_2,
Constants.MapElemType.LEDGE]: Constants.MapElemType.LEDGE,
Constants.MapElemType.OOB_LOWER]:
for test_cell_v in Constants.TILE_SET_MAP_ELEMS[scene.tile_set_name][test_map_elem_type]: for test_cell_v in Constants.TILE_SET_MAP_ELEMS[scene.tile_set_name][test_map_elem_type]:
if test_cell_v == cellv: if test_cell_v == cellv:
map_elem_type = test_map_elem_type map_elem_type = test_map_elem_type
@ -131,6 +132,8 @@ func init_stage_grid(tilemap : TileMap):
insert_grid_collider(stage_x, stage_y, Constants.Direction.UP, 1, map_elem_type) insert_grid_collider(stage_x, stage_y, Constants.Direction.UP, 1, map_elem_type)
Constants.MapElemType.LEDGE: Constants.MapElemType.LEDGE:
insert_grid_collider(stage_x, stage_y, Constants.Direction.DOWN, 1, map_elem_type) insert_grid_collider(stage_x, stage_y, Constants.Direction.DOWN, 1, map_elem_type)
Constants.MapElemType.OOB_LOWER:
insert_grid_collider(stage_x, stage_y, Constants.Direction.DOWN, 1, map_elem_type)
func insert_grid_collider(stage_x, stage_y, direction : int, fractional_height : float, map_elem_type : int): func insert_grid_collider(stage_x, stage_y, direction : int, fractional_height : float, map_elem_type : int):
var check_colliders = [] var check_colliders = []

View File

@ -51,7 +51,7 @@ func _ready():
for node_name in Constants.UNIT_SPRITES[unit_type][sprite_class][1]: for node_name in Constants.UNIT_SPRITES[unit_type][sprite_class][1]:
sprite_class_nodes[sprite_class].append(get_node(node_name)) sprite_class_nodes[sprite_class].append(get_node(node_name))
pos = Vector2(position.x / Constants.GRID_SIZE, -1 * position.y / Constants.GRID_SIZE) pos = Vector2(position.x / Constants.GRID_SIZE, position.y / -Constants.GRID_SIZE)
position.x = position.x * Constants.SCALE_FACTOR position.x = position.x * Constants.SCALE_FACTOR
position.y = position.y * Constants.SCALE_FACTOR position.y = position.y * Constants.SCALE_FACTOR
scale.x = Constants.SCALE_FACTOR scale.x = Constants.SCALE_FACTOR
@ -266,7 +266,7 @@ func react(delta):
pos.x = pos.x + h_speed * delta pos.x = pos.x + h_speed * delta
pos.y = pos.y + v_speed * delta pos.y = pos.y + v_speed * delta
position.x = pos.x * Constants.GRID_SIZE * Constants.SCALE_FACTOR position.x = pos.x * Constants.GRID_SIZE * Constants.SCALE_FACTOR
position.y = -1 * pos.y * Constants.GRID_SIZE * Constants.SCALE_FACTOR position.y = pos.y * Constants.GRID_SIZE *-Constants.SCALE_FACTOR
func hit(dir : int): func hit(dir : int):
# implemented in subclass # implemented in subclass

View File

@ -46,6 +46,10 @@ 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:
@ -140,3 +144,25 @@ func landed():
return return
target_move_speed += boost target_move_speed += boost
boost = 0 boost = 0
func oob_lower():
# Called when the player falls in a hole
# Calculate respawn point
var tilemap : TileMap = get_node("../Stage")
var tile : Vector2 = pos.floor()
tile.y *= -1
while tilemap.get_cellv(tile) == 23 or tilemap.get_cellv(tile) < 0:
tile += Vector2.RIGHT
while tilemap.get_cellv(tile) >= 0:
tile += Vector2.UP
pos = tile
pos.x += 0.5
pos.y *= -1
last_contacted_map_elem_type = Constants.MapElemType.SLOPE_LEFT
# =======================
# reset speed
# should other things be done here?
h_speed = 0

View File

@ -1,4 +1,4 @@
[gd_resource type="TileSet" load_steps=10 format=2] [gd_resource type="TileSet" load_steps=11 format=2]
[ext_resource path="res://Graphics/Tiles/PalaceTileSet.png" type="Texture" id=1] [ext_resource path="res://Graphics/Tiles/PalaceTileSet.png" type="Texture" id=1]
[ext_resource path="res://Graphics/Tiles/slope/SlopeLeft2Borderless.png" type="Texture" id=2] [ext_resource path="res://Graphics/Tiles/slope/SlopeLeft2Borderless.png" type="Texture" id=2]
@ -10,7 +10,11 @@
[ext_resource path="res://Graphics/Tiles/ledge/LedgeRight.png" type="Texture" id=8] [ext_resource path="res://Graphics/Tiles/ledge/LedgeRight.png" type="Texture" id=8]
[ext_resource path="res://Graphics/Tiles/ledge/LedgeSingle.png" type="Texture" id=9] [ext_resource path="res://Graphics/Tiles/ledge/LedgeSingle.png" type="Texture" id=9]
[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 0, 0, 20, 0, 20, 20, 0, 20 )
[resource] [resource]
resource_local_to_scene = true
0/name = "PalaceTileSet.png 0" 0/name = "PalaceTileSet.png 0"
0/texture = ExtResource( 1 ) 0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 ) 0/tex_offset = Vector2( 0, 0 )
@ -333,3 +337,24 @@
22/shape_one_way_margin = 0.0 22/shape_one_way_margin = 0.0
22/shapes = [ ] 22/shapes = [ ]
22/z_index = 0 22/z_index = 0
23/name = "OutOfBoundsLower"
23/texture = ExtResource( 1 )
23/tex_offset = Vector2( 0, 0 )
23/modulate = Color( 1, 1, 1, 1 )
23/region = Rect2( 275, 1, 1, 1 )
23/tile_mode = 0
23/occluder_offset = Vector2( 0, 0 )
23/navigation_offset = Vector2( 0, 0 )
23/shape_offset = Vector2( 0, 0 )
23/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
23/shape = SubResource( 1 )
23/shape_one_way = false
23/shape_one_way_margin = 1.0
23/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
23/z_index = 0

View File

@ -51,7 +51,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/SandboxScene.tscn" run/main_scene="res://Scenes/DownhillAutoscroller.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[display] [display]