272 lines
6.1 KiB
GDScript
272 lines
6.1 KiB
GDScript
enum UnitType {
|
|
PLAYER,
|
|
RIVAL,
|
|
CIRNO,
|
|
SANAE,
|
|
}
|
|
|
|
enum ActionType {
|
|
JUMP,
|
|
MOVE,
|
|
RECOIL,
|
|
SPIN,
|
|
}
|
|
|
|
enum UnitCondition {
|
|
CURRENT_ACTION,
|
|
IS_ON_GROUND,
|
|
MOVING_STATUS,
|
|
IS_INVINCIBLE,
|
|
}
|
|
|
|
enum UnitCurrentAction {
|
|
IDLE,
|
|
JUMPING,
|
|
RECOILING,
|
|
SPINNING,
|
|
}
|
|
|
|
enum UnitMovingStatus {
|
|
IDLE,
|
|
MOVING,
|
|
}
|
|
|
|
enum PlayerInput {
|
|
UP,
|
|
DOWN,
|
|
LEFT,
|
|
RIGHT,
|
|
GBA_A,
|
|
GBA_B,
|
|
GBA_START,
|
|
GBA_SELECT,
|
|
}
|
|
|
|
enum Direction {
|
|
UP,
|
|
DOWN,
|
|
LEFT,
|
|
RIGHT,
|
|
}
|
|
|
|
enum MapElemType {
|
|
SQUARE,
|
|
SLOPE_LEFT,
|
|
SLOPE_RIGHT,
|
|
SMALL_SLOPE_LEFT_1,
|
|
SMALL_SLOPE_LEFT_2,
|
|
SMALL_SLOPE_RIGHT_1,
|
|
SMALL_SLOPE_RIGHT_2,
|
|
LEDGE,
|
|
OOB_LOWER,
|
|
}
|
|
|
|
enum SpriteClass {
|
|
IDLE,
|
|
WALK,
|
|
JUMP,
|
|
RECOIL,
|
|
}
|
|
|
|
const UNIT_TYPE_ACTIONS = {
|
|
UnitType.PLAYER: [
|
|
ActionType.JUMP,
|
|
ActionType.MOVE,
|
|
ActionType.RECOIL,
|
|
ActionType.SPIN,
|
|
],
|
|
UnitType.RIVAL: [
|
|
ActionType.JUMP,
|
|
ActionType.MOVE,
|
|
],
|
|
UnitType.CIRNO: [],
|
|
UnitType.SANAE: [],
|
|
}
|
|
|
|
const UNIT_TYPE_CURRENT_ACTIONS = {
|
|
UnitType.PLAYER: [
|
|
UnitCurrentAction.IDLE,
|
|
UnitCurrentAction.JUMPING,
|
|
UnitCurrentAction.RECOILING,
|
|
UnitCurrentAction.SPINNING,
|
|
],
|
|
UnitType.RIVAL: [
|
|
UnitCurrentAction.IDLE,
|
|
UnitCurrentAction.JUMPING,
|
|
],
|
|
UnitType.CIRNO: [
|
|
UnitCurrentAction.IDLE,
|
|
],
|
|
UnitType.SANAE: [
|
|
UnitCurrentAction.IDLE,
|
|
],
|
|
}
|
|
|
|
# default conditions
|
|
const UNIT_TYPE_CONDITIONS = {
|
|
UnitType.PLAYER: {
|
|
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
|
|
UnitCondition.IS_ON_GROUND: false,
|
|
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
|
|
UnitCondition.IS_INVINCIBLE: false,
|
|
},
|
|
UnitType.RIVAL: {
|
|
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
|
|
UnitCondition.IS_ON_GROUND: false,
|
|
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
|
|
},
|
|
UnitType.CIRNO: {
|
|
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
|
|
UnitCondition.IS_ON_GROUND: false,
|
|
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
|
|
},
|
|
UnitType.SANAE: {
|
|
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
|
|
UnitCondition.IS_ON_GROUND: false,
|
|
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
|
|
},
|
|
}
|
|
|
|
# in seconds
|
|
const CURRENT_ACTION_TIMERS = {
|
|
UnitType.PLAYER: {
|
|
UnitCurrentAction.JUMPING: 0.4,
|
|
UnitCurrentAction.RECOILING: 0.67,
|
|
},
|
|
UnitType.RIVAL: {
|
|
UnitCurrentAction.JUMPING: 0.4,
|
|
},
|
|
UnitType.CIRNO: {},
|
|
UnitType.SANAE: {},
|
|
}
|
|
|
|
const UNIT_CONDITION_TIMERS = {
|
|
# condition type: [duration, on value, off value]
|
|
UnitType.PLAYER: {
|
|
UnitCondition.IS_INVINCIBLE: [2.5, true, false],
|
|
},
|
|
UnitType.RIVAL: {},
|
|
UnitType.CIRNO: {},
|
|
UnitType.SANAE: {},
|
|
}
|
|
|
|
# Position relative to player's origin, list of directions to check for collision
|
|
const ENV_COLLIDERS = {
|
|
UnitType.PLAYER: [
|
|
[Vector2(0, 1.5), [Direction.LEFT, Direction.UP, Direction.RIGHT]],
|
|
[Vector2(-.25, .25), [Direction.LEFT]],
|
|
[Vector2(.25, .25), [Direction.RIGHT]],
|
|
[Vector2(-.25, 1.25), [Direction.LEFT]],
|
|
[Vector2(.25, 1.25), [Direction.RIGHT]],
|
|
# contact with ground is at (0, 0)
|
|
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
|
|
],
|
|
UnitType.RIVAL: [
|
|
[Vector2(0, 1.5), [Direction.LEFT, Direction.UP, Direction.RIGHT]],
|
|
[Vector2(-.25, .25), [Direction.LEFT]],
|
|
[Vector2(.25, .25), [Direction.RIGHT]],
|
|
[Vector2(-.25, 1.25), [Direction.LEFT]],
|
|
[Vector2(.25, 1.25), [Direction.RIGHT]],
|
|
# contact with ground is at (0, 0)
|
|
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
|
|
],
|
|
UnitType.CIRNO: [
|
|
[Vector2(0, 1.5), [Direction.LEFT, Direction.UP, Direction.RIGHT]],
|
|
[Vector2(-.25, .25), [Direction.LEFT]],
|
|
[Vector2(.25, .25), [Direction.RIGHT]],
|
|
[Vector2(-.25, 1.25), [Direction.LEFT]],
|
|
[Vector2(.25, 1.25), [Direction.RIGHT]],
|
|
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
|
|
],
|
|
UnitType.SANAE: [
|
|
[Vector2(0, 1.5), [Direction.LEFT, Direction.UP, Direction.RIGHT]],
|
|
[Vector2(-.25, .25), [Direction.LEFT]],
|
|
[Vector2(.25, .25), [Direction.RIGHT]],
|
|
[Vector2(-.25, 1.25), [Direction.LEFT]],
|
|
[Vector2(.25, 1.25), [Direction.RIGHT]],
|
|
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
|
|
],
|
|
}
|
|
|
|
const INPUT_MAP = {
|
|
PlayerInput.UP: "ui_up",
|
|
PlayerInput.DOWN: "ui_down",
|
|
PlayerInput.LEFT: "ui_left",
|
|
PlayerInput.RIGHT: "ui_right",
|
|
PlayerInput.GBA_A: "gba_a",
|
|
PlayerInput.GBA_B: "gba_b",
|
|
PlayerInput.GBA_START: "gba_start",
|
|
PlayerInput.GBA_SELECT: "gba_select",
|
|
}
|
|
|
|
const TILE_SET_MAP_ELEMS = {
|
|
"TestTileSet": {
|
|
MapElemType.SQUARE: [0, 1, 2, 3, 4, 5, 6, 7, 8],
|
|
MapElemType.SLOPE_LEFT: [15, 16],
|
|
MapElemType.SLOPE_RIGHT: [17, 18],
|
|
MapElemType.SMALL_SLOPE_LEFT_1: [9],
|
|
MapElemType.SMALL_SLOPE_LEFT_2: [10, 11],
|
|
MapElemType.SMALL_SLOPE_RIGHT_1: [12],
|
|
MapElemType.SMALL_SLOPE_RIGHT_2: [13, 14],
|
|
MapElemType.LEDGE: [19, 20, 21, 22],
|
|
MapElemType.OOB_LOWER: [23],
|
|
},
|
|
"SnowySlopes": {
|
|
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],
|
|
MapElemType.SMALL_SLOPE_LEFT_2: [15, 19],
|
|
MapElemType.SMALL_SLOPE_RIGHT_1: [14, 18],
|
|
MapElemType.SMALL_SLOPE_RIGHT_2: [16, 20],
|
|
MapElemType.LEDGE: [],
|
|
MapElemType.OOB_LOWER: [22],
|
|
},
|
|
}
|
|
|
|
const UNIT_SPRITES = {
|
|
# Sprite-class: [Is-animation?, Nodes]
|
|
UnitType.PLAYER: {
|
|
SpriteClass.IDLE: [false, ["Idle"]],
|
|
SpriteClass.WALK: [false, ["Move0", "Move-1", "Move-2", "Move+1", "Move+2"]],
|
|
SpriteClass.JUMP: [false, ["Jump1", "Jump2"]],
|
|
SpriteClass.RECOIL: [false, ["Recoil"]],
|
|
},
|
|
UnitType.RIVAL: {
|
|
SpriteClass.IDLE: [false, ["Idle"]],
|
|
SpriteClass.WALK: [false, ["Move0", "Move-1", "Move-2", "Move+1", "Move+2"]],
|
|
SpriteClass.JUMP: [false, ["Move0"]],
|
|
},
|
|
UnitType.CIRNO: {
|
|
SpriteClass.IDLE: [false, ["Idle"]],
|
|
SpriteClass.JUMP: [false, ["Idle"]],
|
|
},
|
|
UnitType.SANAE: {
|
|
SpriteClass.IDLE: [false, ["Idle"]],
|
|
SpriteClass.JUMP: [false, ["Idle"]],
|
|
},
|
|
}
|
|
|
|
const UNIT_TYPE_MOVE_SPEEDS = {
|
|
UnitType.PLAYER: 5,
|
|
UnitType.RIVAL: 5,
|
|
UnitType.CIRNO: 0,
|
|
UnitType.SANAE: 0,
|
|
}
|
|
|
|
const UNIT_TYPE_JUMP_SPEEDS = {
|
|
UnitType.RIVAL: 4.5,
|
|
UnitType.PLAYER: 4.5,
|
|
}
|
|
|
|
const SCALE_FACTOR = 1
|
|
const GRID_SIZE = 48 # pixels
|
|
const GRAVITY = 16.1 # gravity = 32.17 ft/s^2, grid unit is 2ft
|
|
const MAX_FALL_SPEED = -37
|
|
const ACCELERATION = 35
|
|
const QUANTUM_DIST = 0.001
|
|
const SPAWN_DISTANCE = 20
|
|
|
|
# specialized constants
|
|
const FLASH_CYCLE = 0.15
|