diff --git a/js13k2024/game/src/game-states/gameplay/game-logic.ts b/js13k2024/game/src/game-states/gameplay/game-logic.ts index f84f03e1..c8037e3d 100644 --- a/js13k2024/game/src/game-states/gameplay/game-logic.ts +++ b/js13k2024/game/src/game-states/gameplay/game-logic.ts @@ -7,7 +7,11 @@ import { isInExplosionRange, } from './monster-logic'; import { generateLevel } from './level-generator'; -import { BLASTER_SHOT_DURATION, MOVE_ANIMATION_DURATION, OBSTACLE_DESTRUCTION_DURATION } from './animation-utils'; +import { + BLASTER_SHOT_DURATION, + MOVE_ANIMATION_DURATION, + OBSTACLE_DESTRUCTION_DURATION, +} from './render/animation-utils'; import { soundEngine } from '../../sound/sound-engine'; import { getDirectionFromKey, diff --git a/js13k2024/game/src/game-states/gameplay/game-render.ts b/js13k2024/game/src/game-states/gameplay/game-render.ts index f2293247..f3d00424 100644 --- a/js13k2024/game/src/game-states/gameplay/game-render.ts +++ b/js13k2024/game/src/game-states/gameplay/game-render.ts @@ -1,16 +1,16 @@ import { BonusType, GameState, LevelConfig } from './gameplay-types'; -import { drawObstacles, drawGoal } from './grid-objects-render'; -import { drawGrid } from './grid-render'; -import { drawPlayer } from './player-render'; -import { drawMonsters } from './monster-render'; -import { drawBonuses, drawLandMines, drawTimeBombs } from './bonus-render'; -import { drawExplosions } from './explosion-render'; -import { calculateDrawingOrder } from './isometric-utils'; -import { calculateShakeOffset, interpolatePosition } from './animation-utils'; -import { drawTooltip } from './tooltip-render'; -import { drawElectricalDischarges } from './discharges-render'; -import { drawPlatform } from './grid-render'; -import { drawBlasterShot, drawSlideTrail, drawTsunamiEffect } from './bonus-effect-render'; +import { drawObstacles, drawGoal } from './render/grid-objects-render'; +import { drawGrid } from './render/grid-render'; +import { drawPlayer } from './render/player-render'; +import { drawMonsters } from './render/monster-render'; +import { drawBonuses, drawLandMines, drawTimeBombs } from './render/bonus-render'; +import { drawExplosions } from './render/explosion-render'; +import { calculateDrawingOrder } from './render/isometric-utils'; +import { calculateShakeOffset, interpolatePosition } from './render/animation-utils'; +import { drawTooltip } from './render/tooltip-render'; +import { drawElectricalDischarges } from './render/discharges-render'; +import { drawPlatform } from './render/grid-render'; +import { drawBlasterShot, drawSlideTrail, drawTsunamiEffect } from './render/bonus-effect-render'; export const PLATFORM_HEIGHT = 20; diff --git a/js13k2024/game/src/game-states/gameplay/gameplay.tsx b/js13k2024/game/src/game-states/gameplay/gameplay.tsx index f5728d4d..fa55d653 100644 --- a/js13k2024/game/src/game-states/gameplay/gameplay.tsx +++ b/js13k2024/game/src/game-states/gameplay/gameplay.tsx @@ -1,6 +1,6 @@ import { FunctionComponent, useState, useRef, useEffect } from 'react'; import { drawGameState } from './game-render'; -import { drawMoveArrows } from './move-arrows-render'; +import { drawMoveArrows } from './render/move-arrows-render'; import { doGameUpdate, handleKeyPress, isGameEnding } from './game-logic'; import { getMoveFromClick, getValidMoves } from './move-utils'; import { HUD } from './hud'; diff --git a/js13k2024/game/src/game-states/gameplay/move-utils.ts b/js13k2024/game/src/game-states/gameplay/move-utils.ts index 0268d638..fe123821 100644 --- a/js13k2024/game/src/game-states/gameplay/move-utils.ts +++ b/js13k2024/game/src/game-states/gameplay/move-utils.ts @@ -1,5 +1,5 @@ import { BonusType, Direction, GameState, LevelConfig, Position } from './gameplay-types'; -import { getArrowShape } from './move-arrows-render'; +import { getArrowShape } from './render/move-arrows-render'; export const isPositionEqual = (pos1: Position, pos2: Position): boolean => pos1.x === pos2.x && pos1.y === pos2.y; diff --git a/js13k2024/game/src/game-states/gameplay/animation-utils.ts b/js13k2024/game/src/game-states/gameplay/render/animation-utils.ts similarity index 98% rename from js13k2024/game/src/game-states/gameplay/animation-utils.ts rename to js13k2024/game/src/game-states/gameplay/render/animation-utils.ts index 1b1400b8..419267b3 100644 --- a/js13k2024/game/src/game-states/gameplay/animation-utils.ts +++ b/js13k2024/game/src/game-states/gameplay/render/animation-utils.ts @@ -1,4 +1,4 @@ -import { ElectricalDischarge } from './gameplay-types'; +import { ElectricalDischarge } from '../gameplay-types'; export const MOVE_ANIMATION_DURATION = 250; // 1/4 second export const TELEPORT_ANIMATION_DURATION = 500; // 1/2 second diff --git a/js13k2024/game/src/game-states/gameplay/bonus-effect-render.ts b/js13k2024/game/src/game-states/gameplay/render/bonus-effect-render.ts similarity index 97% rename from js13k2024/game/src/game-states/gameplay/bonus-effect-render.ts rename to js13k2024/game/src/game-states/gameplay/render/bonus-effect-render.ts index 2b2b9a34..6b475bc2 100644 --- a/js13k2024/game/src/game-states/gameplay/bonus-effect-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/bonus-effect-render.ts @@ -1,5 +1,5 @@ import { interpolatePosition } from './animation-utils'; -import { BlasterShot, Direction, GameState, Position } from './gameplay-types'; +import { BlasterShot, Direction, GameState, Position } from '../gameplay-types'; import { toIsometric } from './isometric-utils'; export const drawTsunamiEffect = ( diff --git a/js13k2024/game/src/game-states/gameplay/bonus-render.ts b/js13k2024/game/src/game-states/gameplay/render/bonus-render.ts similarity index 98% rename from js13k2024/game/src/game-states/gameplay/bonus-render.ts rename to js13k2024/game/src/game-states/gameplay/render/bonus-render.ts index e6b7377f..1d2e9dc9 100644 --- a/js13k2024/game/src/game-states/gameplay/bonus-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/bonus-render.ts @@ -1,4 +1,4 @@ -import { Position, Bonus, BonusType } from './gameplay-types'; +import { Position, Bonus, BonusType } from '../gameplay-types'; import { toIsometric, TILE_WIDTH, TILE_HEIGHT } from './isometric-utils'; import { drawShadow } from './grid-render'; diff --git a/js13k2024/game/src/game-states/gameplay/discharges-render.ts b/js13k2024/game/src/game-states/gameplay/render/discharges-render.ts similarity index 100% rename from js13k2024/game/src/game-states/gameplay/discharges-render.ts rename to js13k2024/game/src/game-states/gameplay/render/discharges-render.ts diff --git a/js13k2024/game/src/game-states/gameplay/entity-render-utils.ts b/js13k2024/game/src/game-states/gameplay/render/entity-render-utils.ts similarity index 100% rename from js13k2024/game/src/game-states/gameplay/entity-render-utils.ts rename to js13k2024/game/src/game-states/gameplay/render/entity-render-utils.ts diff --git a/js13k2024/game/src/game-states/gameplay/entity-render.ts b/js13k2024/game/src/game-states/gameplay/render/entity-render.ts similarity index 100% rename from js13k2024/game/src/game-states/gameplay/entity-render.ts rename to js13k2024/game/src/game-states/gameplay/render/entity-render.ts diff --git a/js13k2024/game/src/game-states/gameplay/explosion-render.ts b/js13k2024/game/src/game-states/gameplay/render/explosion-render.ts similarity index 97% rename from js13k2024/game/src/game-states/gameplay/explosion-render.ts rename to js13k2024/game/src/game-states/gameplay/render/explosion-render.ts index 27229f7b..7b72bc93 100644 --- a/js13k2024/game/src/game-states/gameplay/explosion-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/explosion-render.ts @@ -1,4 +1,4 @@ -import { Explosion } from './gameplay-types'; +import { Explosion } from '../gameplay-types'; import { toIsometric, TILE_WIDTH, TILE_HEIGHT } from './isometric-utils'; export const drawExplosions = (ctx: CanvasRenderingContext2D, explosions: Explosion[]) => { diff --git a/js13k2024/game/src/game-states/gameplay/grid-objects-render.ts b/js13k2024/game/src/game-states/gameplay/render/grid-objects-render.ts similarity index 98% rename from js13k2024/game/src/game-states/gameplay/grid-objects-render.ts rename to js13k2024/game/src/game-states/gameplay/render/grid-objects-render.ts index 2b4e2766..c9b24998 100644 --- a/js13k2024/game/src/game-states/gameplay/grid-objects-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/grid-objects-render.ts @@ -1,4 +1,4 @@ -import { Position, Obstacle } from './gameplay-types'; +import { Position, Obstacle } from '../gameplay-types'; import { toIsometric, TILE_WIDTH, TILE_HEIGHT } from './isometric-utils'; import { calculateObstacleHeight } from './animation-utils'; diff --git a/js13k2024/game/src/game-states/gameplay/grid-render.ts b/js13k2024/game/src/game-states/gameplay/render/grid-render.ts similarity index 93% rename from js13k2024/game/src/game-states/gameplay/grid-render.ts rename to js13k2024/game/src/game-states/gameplay/render/grid-render.ts index 187d221f..22d2dcdc 100644 --- a/js13k2024/game/src/game-states/gameplay/grid-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/grid-render.ts @@ -1,6 +1,6 @@ -import { PLATFORM_HEIGHT } from './game-render'; +import { PLATFORM_HEIGHT } from '../game-render'; import { TILE_HEIGHT, TILE_WIDTH, toIsometric } from './isometric-utils'; -import { GameState } from './gameplay-types'; +import { GameState } from '../gameplay-types'; export const drawPlatform = (ctx: CanvasRenderingContext2D, gridSize: number) => { const topLeft = toIsometric(0, 0); @@ -94,7 +94,10 @@ const drawTsunamiTile = (ctx: CanvasRenderingContext2D, x: number, y: number, ts ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(isoX - TILE_WIDTH / 2, isoY + TILE_HEIGHT / 2 - waterHeight + Math.sin(Date.now() / 200 + x * 0.5) * 3); - ctx.lineTo(isoX + TILE_WIDTH / 2, isoY + TILE_HEIGHT / 2 - waterHeight + Math.sin(Date.now() / 200 + (x + 1) * 0.5) * 3); + ctx.lineTo( + isoX + TILE_WIDTH / 2, + isoY + TILE_HEIGHT / 2 - waterHeight + Math.sin(Date.now() / 200 + (x + 1) * 0.5) * 3, + ); ctx.stroke(); }; @@ -102,10 +105,7 @@ const drawSlideTile = (ctx: CanvasRenderingContext2D, x: number, y: number) => { const { x: isoX, y: isoY } = toIsometric(x, y); // Draw a subtle ice-like effect - const gradient = ctx.createLinearGradient( - isoX - TILE_WIDTH / 2, isoY, - isoX + TILE_WIDTH / 2, isoY + TILE_HEIGHT - ); + const gradient = ctx.createLinearGradient(isoX - TILE_WIDTH / 2, isoY, isoX + TILE_WIDTH / 2, isoY + TILE_HEIGHT); gradient.addColorStop(0, 'rgba(200, 200, 255, 0.2)'); gradient.addColorStop(0.5, 'rgba(220, 220, 255, 0.3)'); gradient.addColorStop(1, 'rgba(200, 200, 255, 0.2)'); @@ -140,4 +140,4 @@ export const drawShadow = (ctx: CanvasRenderingContext2D, x: number, y: number, ctx.beginPath(); ctx.ellipse(x + width / 2, y + height / 2 + SHADOW_OFFSET, width / 2, height / 4, 0, 0, Math.PI * 2); ctx.fill(); -}; \ No newline at end of file +}; diff --git a/js13k2024/game/src/game-states/gameplay/isometric-utils.ts b/js13k2024/game/src/game-states/gameplay/render/isometric-utils.ts similarity index 98% rename from js13k2024/game/src/game-states/gameplay/isometric-utils.ts rename to js13k2024/game/src/game-states/gameplay/render/isometric-utils.ts index c2f34105..e2950e2e 100644 --- a/js13k2024/game/src/game-states/gameplay/isometric-utils.ts +++ b/js13k2024/game/src/game-states/gameplay/render/isometric-utils.ts @@ -1,4 +1,4 @@ -import { Position } from './gameplay-types'; +import { Position } from '../gameplay-types'; // Constants for isometric tile dimensions export const TILE_WIDTH = 60; diff --git a/js13k2024/game/src/game-states/gameplay/monster-render.ts b/js13k2024/game/src/game-states/gameplay/render/monster-render.ts similarity index 92% rename from js13k2024/game/src/game-states/gameplay/monster-render.ts rename to js13k2024/game/src/game-states/gameplay/render/monster-render.ts index c3a1812b..160930f3 100644 --- a/js13k2024/game/src/game-states/gameplay/monster-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/monster-render.ts @@ -1,10 +1,15 @@ -import { Monster } from './gameplay-types'; +import { Monster } from '../gameplay-types'; import { toIsometric } from './isometric-utils'; import { interpolatePosition } from './animation-utils'; import { EntityRenderParams } from './entity-render-utils'; import { renderEntity } from './entity-render'; -export const drawMonsters = (ctx: CanvasRenderingContext2D, monsters: Monster[], cellSize: number, isPlayerMonster: boolean) => { +export const drawMonsters = ( + ctx: CanvasRenderingContext2D, + monsters: Monster[], + cellSize: number, + isPlayerMonster: boolean, +) => { monsters.forEach((monster) => { const interpolatedPosition = interpolatePosition(monster.position, monster.previousPosition, monster.moveTimestamp); @@ -67,4 +72,4 @@ const drawPlayerFeatures = (ctx: CanvasRenderingContext2D, x: number, y: number, } ctx.restore(); -}; \ No newline at end of file +}; diff --git a/js13k2024/game/src/game-states/gameplay/move-arrows-render.ts b/js13k2024/game/src/game-states/gameplay/render/move-arrows-render.ts similarity index 92% rename from js13k2024/game/src/game-states/gameplay/move-arrows-render.ts rename to js13k2024/game/src/game-states/gameplay/render/move-arrows-render.ts index 1f4ecdb7..305fbd78 100644 --- a/js13k2024/game/src/game-states/gameplay/move-arrows-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/move-arrows-render.ts @@ -1,6 +1,6 @@ -import { Position, Direction } from './gameplay-types'; +import { Position, Direction } from '../gameplay-types'; import { toIsometric } from './isometric-utils'; -import { getNewPosition, getOrthogonalDirection } from './move-utils'; +import { getNewPosition, getOrthogonalDirection } from '../move-utils'; // Updated function to draw move arrows diff --git a/js13k2024/game/src/game-states/gameplay/player-render.ts b/js13k2024/game/src/game-states/gameplay/render/player-render.ts similarity index 99% rename from js13k2024/game/src/game-states/gameplay/player-render.ts rename to js13k2024/game/src/game-states/gameplay/render/player-render.ts index 539b39aa..6dc60c1b 100644 --- a/js13k2024/game/src/game-states/gameplay/player-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/player-render.ts @@ -1,4 +1,4 @@ -import { Obstacle, Player } from './gameplay-types'; +import { Obstacle, Player } from '../gameplay-types'; import { toIsometric } from './isometric-utils'; import { interpolatePosition, diff --git a/js13k2024/game/src/game-states/gameplay/tooltip-render.ts b/js13k2024/game/src/game-states/gameplay/render/tooltip-render.ts similarity index 98% rename from js13k2024/game/src/game-states/gameplay/tooltip-render.ts rename to js13k2024/game/src/game-states/gameplay/render/tooltip-render.ts index a3c557c5..1937018e 100644 --- a/js13k2024/game/src/game-states/gameplay/tooltip-render.ts +++ b/js13k2024/game/src/game-states/gameplay/render/tooltip-render.ts @@ -1,4 +1,4 @@ -import { Position, BonusType, getBonusDescription } from './gameplay-types'; +import { Position, BonusType, getBonusDescription } from '../gameplay-types'; import { toIsometric } from './isometric-utils'; export const drawTooltip = ( diff --git a/js13k2024/game/src/game-states/intro/game-preview.tsx b/js13k2024/game/src/game-states/intro/game-preview.tsx index 594428e9..5c6fe4a1 100644 --- a/js13k2024/game/src/game-states/intro/game-preview.tsx +++ b/js13k2024/game/src/game-states/intro/game-preview.tsx @@ -1,6 +1,6 @@ import { FunctionComponent, useEffect, useRef } from 'react'; import { drawGameState } from '../gameplay/game-render'; -import { drawGrid } from '../gameplay/grid-render'; +import { drawGrid } from '../gameplay/render/grid-render'; import { GameState, BonusType } from '../gameplay/gameplay-types'; const PREVIEW_WIDTH = 300;