Jam10/Scripts/Constants.gd

308 lines
6.4 KiB
GDScript3
Raw Normal View History

2023-01-26 18:25:40 +00:00
enum UnitType {
PLAYER,
2023-01-29 07:24:33 +00:00
RIVAL,
2023-01-29 22:46:06 +00:00
CIRNO,
SANAE,
2023-01-26 18:25:40 +00:00
}
enum ActionType {
JUMP,
MOVE,
RECOIL,
2023-01-28 01:56:15 +00:00
SPIN,
2023-01-26 18:25:40 +00:00
}
enum UnitCondition {
CURRENT_ACTION,
IS_ON_GROUND,
MOVING_STATUS,
IS_INVINCIBLE,
}
enum UnitCurrentAction {
IDLE,
JUMPING,
RECOILING,
2023-01-28 01:56:15 +00:00
SPINNING,
2023-01-26 18:25:40 +00:00
}
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,
2023-01-28 09:25:49 +00:00
OOB_LOWER,
2023-01-26 18:25:40 +00:00
}
2023-01-30 16:26:49 +00:00
const ELEM_TYPE_SLOPE = [
2,
0,
4,
1,
1,
3,
3,
2,
2,
]
2023-01-26 18:25:40 +00:00
enum SpriteClass {
IDLE,
WALK,
JUMP,
RECOIL,
}
const UNIT_TYPE_ACTIONS = {
UnitType.PLAYER: [
ActionType.JUMP,
ActionType.MOVE,
ActionType.RECOIL,
2023-01-28 01:56:15 +00:00
ActionType.SPIN,
2023-01-26 18:25:40 +00:00
],
2023-01-29 07:24:33 +00:00
UnitType.RIVAL: [
ActionType.JUMP,
ActionType.MOVE,
],
2023-01-29 22:46:06 +00:00
UnitType.CIRNO: [],
UnitType.SANAE: [],
2023-01-26 18:25:40 +00:00
}
const UNIT_TYPE_CURRENT_ACTIONS = {
UnitType.PLAYER: [
UnitCurrentAction.IDLE,
UnitCurrentAction.JUMPING,
UnitCurrentAction.RECOILING,
2023-01-28 01:56:15 +00:00
UnitCurrentAction.SPINNING,
2023-01-26 18:25:40 +00:00
],
2023-01-29 07:24:33 +00:00
UnitType.RIVAL: [
UnitCurrentAction.IDLE,
UnitCurrentAction.JUMPING,
],
2023-01-29 22:46:06 +00:00
UnitType.CIRNO: [
UnitCurrentAction.IDLE,
],
UnitType.SANAE: [
UnitCurrentAction.IDLE,
],
2023-01-26 18:25:40 +00:00
}
# 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,
},
2023-01-29 22:46:06 +00:00
UnitType.RIVAL: {
2023-01-26 18:25:40 +00:00
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
UnitCondition.IS_ON_GROUND: false,
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
},
2023-01-29 22:46:06 +00:00
UnitType.CIRNO: {
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
UnitCondition.IS_ON_GROUND: false,
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
},
UnitType.SANAE: {
2023-01-29 07:24:33 +00:00
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
UnitCondition.IS_ON_GROUND: false,
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
},
2023-01-26 18:25:40 +00:00
}
# in seconds
const CURRENT_ACTION_TIMERS = {
UnitType.PLAYER: {
UnitCurrentAction.JUMPING: 0.4,
UnitCurrentAction.RECOILING: 0.67,
},
2023-01-29 22:46:06 +00:00
UnitType.RIVAL: {
2023-01-29 07:24:33 +00:00
UnitCurrentAction.JUMPING: 0.4,
},
2023-01-29 22:46:06 +00:00
UnitType.CIRNO: {},
UnitType.SANAE: {},
2023-01-26 18:25:40 +00:00
}
const UNIT_CONDITION_TIMERS = {
# condition type: [duration, on value, off value]
UnitType.PLAYER: {
UnitCondition.IS_INVINCIBLE: [2.5, true, false],
},
2023-01-29 07:24:33 +00:00
UnitType.RIVAL: {},
2023-01-29 22:46:06 +00:00
UnitType.CIRNO: {},
UnitType.SANAE: {},
2023-01-26 18:25:40 +00:00
}
# 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]],
],
2023-01-29 22:46:06 +00:00
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: [
2023-01-26 18:25:40 +00:00
[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]],
],
2023-01-29 22:46:06 +00:00
UnitType.SANAE: [
2023-01-29 07:24:33 +00:00
[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]],
],
2023-01-26 18:25:40 +00:00
}
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],
2023-01-28 09:25:49 +00:00
MapElemType.OOB_LOWER: [23],
2023-01-26 18:25:40 +00:00
},
2023-01-28 07:13:06 +00:00
"SnowySlopes": {
2023-01-30 13:54:29 +00:00
MapElemType.SQUARE: [1, 2, 3, 4, 5, 6, 7, 8, 21],
2023-01-28 07:13:06 +00:00
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: [],
2023-01-28 09:39:00 +00:00
MapElemType.OOB_LOWER: [22],
2023-01-28 07:13:06 +00:00
},
2023-01-26 18:25:40 +00:00
}
const UNIT_SPRITES = {
# Sprite-class: [Is-animation?, Nodes]
UnitType.PLAYER: {
SpriteClass.IDLE: [false, ["Idle"]],
2023-01-29 03:21:34 +00:00
SpriteClass.WALK: [false, ["Move0", "Move-1", "Move-2", "Move+1", "Move+2"]],
2023-01-26 18:25:40 +00:00
SpriteClass.JUMP: [false, ["Jump1", "Jump2"]],
SpriteClass.RECOIL: [false, ["Recoil"]],
},
2023-01-29 07:24:33 +00:00
UnitType.RIVAL: {
SpriteClass.IDLE: [false, ["Idle"]],
SpriteClass.WALK: [false, ["Move0", "Move-1", "Move-2", "Move+1", "Move+2"]],
SpriteClass.JUMP: [false, ["Move0"]],
},
2023-01-29 22:46:06 +00:00
UnitType.CIRNO: {
SpriteClass.IDLE: [false, ["Idle"]],
SpriteClass.JUMP: [false, ["Idle"]],
},
UnitType.SANAE: {
SpriteClass.IDLE: [false, ["Idle"]],
SpriteClass.JUMP: [false, ["Idle"]],
},
2023-01-26 18:25:40 +00:00
}
const UNIT_TYPE_MOVE_SPEEDS = {
2023-01-28 07:13:06 +00:00
UnitType.PLAYER: 5,
2023-01-29 07:24:33 +00:00
UnitType.RIVAL: 5,
2023-01-29 22:46:06 +00:00
UnitType.CIRNO: 0,
UnitType.SANAE: 0,
2023-01-26 18:25:40 +00:00
}
const UNIT_TYPE_JUMP_SPEEDS = {
2023-01-29 07:24:33 +00:00
UnitType.RIVAL: 4.5,
2023-01-29 22:46:06 +00:00
UnitType.PLAYER: 4.5,
2023-01-26 18:25:40 +00:00
}
2023-01-28 07:13:06 +00:00
const SCALE_FACTOR = 1
const GRID_SIZE = 48 # pixels
2023-01-27 22:30:20 +00:00
const GRAVITY = 16.1 # gravity = 32.17 ft/s^2, grid unit is 2ft
const MAX_FALL_SPEED = -37
2023-01-26 18:25:40 +00:00
const ACCELERATION = 35
const QUANTUM_DIST = 0.001
2023-01-29 00:19:29 +00:00
const SPAWN_DISTANCE = 20
2023-01-26 18:25:40 +00:00
# specialized constants
const FLASH_CYCLE = 0.15
2023-01-30 16:26:49 +00:00
const SLOPE_SPEED = [
0.0,
0.0,
3.5,
7.3 * 1.118,
9.2 * 1.414,
]
const SLOPE_ACCEL = [
0.0,
0.0,
1.0,
2.2 * 1.118,
3.4 * 1.414,
]
const SLOPE_DECEL = [
5.0 * 1.414,
3.5 * 1.118,
0.3,
0.2,
0.1
]