Start of level 2
This commit is contained in:
parent
a7be9cd657
commit
855332b44e
12 changed files with 263 additions and 19 deletions
|
@ -212,7 +212,7 @@ const TILE_SET_MAP_ELEMS = {
|
|||
MapElemType.OOB_LOWER: [23],
|
||||
},
|
||||
"SnowySlopes": {
|
||||
MapElemType.SQUARE: [0, 1, 2, 3, 4, 5, 6, 7, 8, 21],
|
||||
MapElemType.SQUARE: [1, 2, 3, 4, 5, 6, 7, 8, 21],
|
||||
MapElemType.SLOPE_LEFT: [9, 11],
|
||||
MapElemType.SLOPE_RIGHT: [10, 12],
|
||||
MapElemType.SMALL_SLOPE_LEFT_1: [13, 17],
|
||||
|
|
|
@ -15,6 +15,7 @@ export var finish_x_pos : int
|
|||
export var target_time : float
|
||||
export var defeat_cutscene : String
|
||||
export var victory_cutscene : String
|
||||
export var level : int
|
||||
const Constants = preload("res://Scripts/Constants.gd")
|
||||
const UNIT_DIRECTORY = {
|
||||
Constants.UnitType.CIRNO: preload("res://Units/DownhillAutoscrollerNPCCirno.tscn"),
|
||||
|
@ -22,7 +23,7 @@ const UNIT_DIRECTORY = {
|
|||
}
|
||||
|
||||
# positions to unit string
|
||||
export var spawning : Dictionary
|
||||
var spawning : Dictionary = {}
|
||||
var spawning_map = {} # keeps track of what's alive
|
||||
|
||||
var paused : bool = false
|
||||
|
@ -61,7 +62,10 @@ var rng = RandomNumberGenerator.new()
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
MusicController.play_kyouko_snow()
|
||||
if level == 1:
|
||||
MusicController.play_kyouko_snow()
|
||||
else:
|
||||
MusicController.play_letty_snow()
|
||||
|
||||
units.append($Player)
|
||||
player = units[0]
|
||||
|
@ -189,8 +193,10 @@ func handle_player_input():
|
|||
if input_table[Constants.PlayerInput.GBA_A][I_T_PRESSED]:
|
||||
if (player.get_current_action() == Constants.UnitCurrentAction.JUMPING
|
||||
or (player.get_current_action() == Constants.UnitCurrentAction.IDLE
|
||||
and player.unit_conditions[Constants.UnitCondition.IS_ON_GROUND]
|
||||
and input_table[Constants.PlayerInput.GBA_A][I_T_JUST_PRESSED])):
|
||||
player.set_action(Constants.ActionType.JUMP)
|
||||
if player.unit_conditions[Constants.UnitCondition.IS_ON_GROUND] or player.get_current_action() == Constants.UnitCurrentAction.JUMPING:
|
||||
player.set_action(Constants.ActionType.JUMP)
|
||||
else:
|
||||
player.buffer_jump()
|
||||
|
||||
player.custom_inputs()
|
||||
|
|
|
@ -50,6 +50,15 @@ func init_stage_grid(tilemap : TileMap):
|
|||
var stage_y = floor(-1 * tilemap.map_to_world(map_elem).y / Constants.GRID_SIZE) - 1
|
||||
var map_elem_type : int
|
||||
var cellv = tilemap.get_cellv(map_elem)
|
||||
|
||||
if cellv == 23 or cellv == 24:
|
||||
scene.spawning[Vector2(stage_x, stage_y)] = "CIRNO" if cellv == 23 else "SANAE"
|
||||
tilemap.set_cellv(map_elem, -1)
|
||||
continue
|
||||
|
||||
if cellv == 0:
|
||||
continue
|
||||
|
||||
var found_map_elem_type : bool = false
|
||||
for test_map_elem_type in [
|
||||
Constants.MapElemType.SQUARE,
|
||||
|
|
|
@ -37,6 +37,8 @@ var flash_start_timestamp : float
|
|||
|
||||
var recorder: PlayerRecorder = null
|
||||
|
||||
var jump_buffer: float = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time
|
||||
func _ready():
|
||||
for action_num in Constants.UNIT_TYPE_ACTIONS[unit_type]:
|
||||
|
@ -62,6 +64,9 @@ func _ready():
|
|||
func init_unit_w_scene(scene):
|
||||
self.scene = scene
|
||||
|
||||
func buffer_jump():
|
||||
jump_buffer = 0.07
|
||||
|
||||
func set_action(action : int):
|
||||
assert(action in Constants.UNIT_TYPE_ACTIONS[unit_type])
|
||||
actions[action] = true
|
||||
|
@ -93,6 +98,13 @@ func reset_actions():
|
|||
|
||||
func process_unit(delta, time_elapsed : float):
|
||||
current_action_time_elapsed += delta
|
||||
|
||||
if jump_buffer > 0:
|
||||
jump_buffer -= delta
|
||||
if unit_conditions[Constants.UnitCondition.IS_ON_GROUND]:
|
||||
set_action(Constants.ActionType.JUMP)
|
||||
jump_buffer = 0
|
||||
|
||||
execute_actions(delta)
|
||||
handle_idle()
|
||||
advance_timers(delta)
|
||||
|
@ -148,7 +160,10 @@ func jump():
|
|||
v_speed = max(Constants.UNIT_TYPE_JUMP_SPEEDS[unit_type], v_speed)
|
||||
else:
|
||||
# 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))
|
||||
print(v_speed)
|
||||
set_unit_condition(Constants.UnitCondition.IS_ON_GROUND, false)
|
||||
if get_current_action() == Constants.UnitCurrentAction.JUMPING and v_speed > 0:
|
||||
set_sprite(Constants.SpriteClass.JUMP, 0)
|
||||
|
|
|
@ -101,6 +101,8 @@ func process_unit(delta, time_elapsed : float):
|
|||
|
||||
# Fine tune the player's speed
|
||||
|
||||
print(last_contacted_map_elem_type)
|
||||
|
||||
if get_current_action() == Constants.UnitCurrentAction.RECOILING:
|
||||
target_move_speed = min_speed
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue