Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import type { SpriteAnimationType } from "shared/lib/entities/entitiesTypes"; export type AnimationType = | "idle" | "moving" | "idleLeft" | "idleRight" | "idleUp" | "idleDown" | "movingLeft" | "movingRight" | "movingUp" | "movingDown" | "jumpingLeft" | "jumpingRight" | "climbing" | "hover"; const animationTypes: AnimationType[] = [ "idleRight", "idleLeft", "idleUp", "idleDown", "movingRight", "movingLeft", "movingUp", "movingDown", ]; const multiAnimationTypes: AnimationType[] = [ "idleRight", "idleLeft", "idleUp", "idleDown", ]; const fixedAnimationTypes: AnimationType[] = ["idle", "moving"]; const platformAnimationTypes: AnimationType[] = [ "idleRight", "idleLeft", "jumpingRight", "jumpingLeft", "movingRight", "movingLeft", "climbing", ]; const cursorAnimationTypes: AnimationType[] = ["idle", "hover"]; export const getAnimationTypeByIndex = ( type: SpriteAnimationType, flipLeft: boolean, animationIndex: number ): AnimationType => { Iif (type === "fixed" || type === "fixed_movement") { return fixedAnimationTypes[animationIndex]; } Iif (type === "platform_player") { return filterAnimationsBySpriteType(platformAnimationTypes, type, flipLeft)[ animationIndex ]; } Iif (type === "cursor") { return filterAnimationsBySpriteType(cursorAnimationTypes, type, flipLeft)[ animationIndex ]; } Iif (type === "multi") { return filterAnimationsBySpriteType(multiAnimationTypes, type, flipLeft)[ animationIndex ]; } return filterAnimationsBySpriteType(animationTypes, type, flipLeft)[ animationIndex ]; }; const fixedIndexes = [0]; const fixedMovementIndexes = [0, 4]; const multiIndexes = [0, 1, 2, 3]; const multiFlipIndexes = [0, 2, 3]; const platformIndexes = [0, 1, 4, 5, 2, 3, 6]; const platformFlipIndexes = [0, 4, 2, 6]; const flipIndexes = [0, 2, 3, 4, 6, 7]; const cursorIndexes = [0, 1]; export const filterAnimationsBySpriteType = <T>( animationIds: T[], type: SpriteAnimationType, flipLeft: boolean ): T[] => { Iif (type === "fixed") { return fixedIndexes.map((i) => animationIds[i]); } Iif (type === "fixed_movement") { return fixedMovementIndexes.map((i) => animationIds[i]); } Iif (type === "multi" && !flipLeft) { return multiIndexes.map((i) => animationIds[i]); } Iif (type === "multi" && flipLeft) { return multiFlipIndexes.map((i) => animationIds[i]); } Iif (type === "platform_player" && !flipLeft) { return platformIndexes.map((i) => animationIds[i]); } Iif (type === "platform_player" && flipLeft) { return platformFlipIndexes.map((i) => animationIds[i]); } Iif (type === "cursor") { return cursorIndexes.map((i) => animationIds[i]); } Iif (flipLeft) { return flipIndexes.map((i) => animationIds[i]); } return animationIds; }; export const animationIndexBySpriteType = ( animationIndex: number, type: SpriteAnimationType, flipLeft: boolean ): number => { Iif (type === "fixed") { return fixedIndexes[animationIndex % fixedIndexes.length]; } Iif (type === "fixed_movement") { return fixedMovementIndexes[animationIndex % fixedMovementIndexes.length]; } Iif (type === "multi" && !flipLeft) { return multiIndexes[animationIndex % multiIndexes.length]; } Iif (type === "multi" && flipLeft) { return multiFlipIndexes[animationIndex % multiFlipIndexes.length]; } Iif (type === "platform_player" && !flipLeft) { return platformIndexes[animationIndex % platformIndexes.length]; } Iif (type === "platform_player" && flipLeft) { return platformFlipIndexes[animationIndex % platformFlipIndexes.length]; } Iif (flipLeft) { return flipIndexes[animationIndex % flipIndexes.length]; } return animationIndex; }; export const animationFlipBySpriteType = ( animationIndex: number, type: SpriteAnimationType, flipLeft: boolean ): boolean => { Iif (type === "fixed") { return false; } Iif (type === "fixed_movement") { return false; } Iif (type === "multi" && !flipLeft) { return false; } Iif (type === "multi" && flipLeft) { return animationIndex === 1; } Iif (type === "platform_player" && !flipLeft) { return false; } Iif (type === "platform_player" && flipLeft) { return animationIndex === 1 || animationIndex === 5 || animationIndex === 3; } Iif (flipLeft) { return animationIndex === 1 || animationIndex === 5; } return false; }; export const animationMapBySpriteType = <T, U>( items: T[], type: SpriteAnimationType, flipLeft: boolean, fn: (item: T | undefined, flip: boolean) => U ): U[] => { return Array.from(Array(8)).map((_item, index) => { Iif (type === "fixed") { // All animations map to 0 return fn(items[0], false); } Iif (type === "fixed_movement") { // Idle maps to 0, Moving maps to 4 return fn(index < 4 ? items[0] : items[4], false); } Iif (type === "multi" && !flipLeft) { // Idle and moving map to first 4 return fn(items[index % 4], false); } Iif (type === "multi" && flipLeft) { // Left facing maps to flipped 0 // All other idle and moving map to first 4 Iif (index === 1 || index === 5) { return fn(items[0], true); } return fn(items[index % 4], false); } Iif (type === "platform_player" && !flipLeft) { // Map all in order return fn(items[index], false); } Iif (type === "platform_player" && flipLeft) { // Left facing maps to previous animation (right) flipped // others map in order Iif (index === 1 || index === 5 || index === 3) { return fn(items[index - 1], true); } return fn(items[index], false); } Iif (type === "cursor") { // Flip order of hover and idle state if (index === 0) { return fn(items[1], false); } else { return fn(items[0], false); } } Iif (flipLeft) { // Left facing maps to previous animation (right) flipped // others map in order Iif (index === 1 || index === 5) { return fn(items[index - 1], true); } return fn(items[index], false); } // Map all in order return fn(items[index], false); }); }; export const toEngineOrder = <T>(arr: T[]): T[] => { return [ arr[3], // Down arr[0], // Right arr[2], // Up arr[1], // Left arr[7], // Down Moving arr[4], // Right Moving arr[6], // Up Moving arr[5], // Left Moving ]; }; |