Jam10/Scripts/Constants.gd

249 lines
5.4 KiB
GDScript

enum UnitType {
PLAYER,
NPC,
RIVAL,
}
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.NPC: [
ActionType.MOVE,
],
UnitType.RIVAL: [
ActionType.JUMP,
ActionType.MOVE,
],
}
const UNIT_TYPE_CURRENT_ACTIONS = {
UnitType.PLAYER: [
UnitCurrentAction.IDLE,
UnitCurrentAction.JUMPING,
UnitCurrentAction.RECOILING,
UnitCurrentAction.SPINNING,
],
UnitType.NPC: [
UnitCurrentAction.IDLE,
],
UnitType.RIVAL: [
UnitCurrentAction.IDLE,
UnitCurrentAction.JUMPING,
],
}
# 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.NPC: {
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
UnitCondition.IS_ON_GROUND: false,
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
},
UnitType.RIVAL: {
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.NPC: {
UnitCurrentAction.JUMPING: 0.4,
},
}
const UNIT_CONDITION_TIMERS = {
# condition type: [duration, on value, off value]
UnitType.PLAYER: {
UnitCondition.IS_INVINCIBLE: [2.5, true, false],
},
UnitType.NPC: {},
UnitType.RIVAL: {},
}
# 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.NPC: [
[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.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]],
],
}
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: [0, 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.NPC: {
SpriteClass.IDLE: [false, ["Idle"]],
SpriteClass.WALK: [true, ["Walk"]],
SpriteClass.JUMP: [false, ["Jump2"]],
},
UnitType.RIVAL: {
SpriteClass.IDLE: [false, ["Idle"]],
SpriteClass.WALK: [false, ["Move0", "Move-1", "Move-2", "Move+1", "Move+2"]],
SpriteClass.JUMP: [false, ["Move0"]],
},
}
const UNIT_TYPE_MOVE_SPEEDS = {
UnitType.PLAYER: 5,
UnitType.NPC: 3,
UnitType.RIVAL: 5,
}
const UNIT_TYPE_JUMP_SPEEDS = {
UnitType.PLAYER: 4.5,
UnitType.RIVAL: 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