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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x | // Underground dojang background for Korean martial arts import { extend } from "@pixi/react"; import * as PIXI from "pixi.js"; import { Container, Graphics, Sprite, Text, Texture } from "pixi.js"; import React, { useCallback, useEffect, useState } from "react"; import { KOREAN_COLORS } from "../../types/constants"; extend({ Container, Graphics, Text, Sprite, }); export interface DojangBackgroundProps { width: number; height: number; lighting?: "normal" | "dim" | "bright" | "cyberpunk" | "traditional"; animate?: boolean; "data-testid"?: string; } export const DojangBackground: React.FC<DojangBackgroundProps> = ({ width, height, lighting = "normal", animate = true, ...props }) => { const [floorTexture, setFloorTexture] = useState<Texture | null>(null); const [wallTexture, setWallTexture] = useState<Texture | null>(null); // Enhanced texture loading with proper async/await pattern like IntroScreen useEffect(() => { let destroyed = false; const loadTextures = async () => { try { const [floor, wall] = await Promise.all([ PIXI.Assets.load("/assets/visual/bg/dojang/dojang_floor_tex.png"), PIXI.Assets.load("/assets/visual/bg/dojang/dojang_wall_tex.png"), ]); if (!destroyed) { setFloorTexture(floor as Texture); setWallTexture(wall as Texture); } } catch (error) { console.warn("Failed to load dojang textures:", error); // Continue without textures - fallback graphics will be used } }; loadTextures(); return () => { destroyed = true; }; }, []); const getLightingSettings = useCallback((lightingMode: string) => { switch (lightingMode) { case "dim": return { backgroundAlpha: 0.7, gridAlpha: 0.2, accentAlpha: 0.3, ambientColor: KOREAN_COLORS.UI_BACKGROUND_DARK, tintColor: 0x444444, }; case "bright": return { backgroundAlpha: 1.0, gridAlpha: 0.5, accentAlpha: 0.7, ambientColor: KOREAN_COLORS.UI_BACKGROUND_LIGHT, tintColor: 0xffffff, }; case "cyberpunk": return { backgroundAlpha: 0.95, gridAlpha: 0.4, accentAlpha: 0.8, ambientColor: KOREAN_COLORS.NEON_CYAN, tintColor: 0x00ffff, }; case "traditional": return { backgroundAlpha: 0.9, gridAlpha: 0.3, accentAlpha: 0.6, ambientColor: KOREAN_COLORS.KOREAN_RED, tintColor: 0xaa8866, }; default: // "normal" return { backgroundAlpha: 0.9, gridAlpha: 0.3, accentAlpha: 0.4, ambientColor: KOREAN_COLORS.UI_BACKGROUND_DARK, tintColor: 0xffffff, }; } }, []); const drawFallbackBackground = useCallback( (g: any) => { g.clear(); const settings = getLightingSettings(lighting); // Fallback solid background g.fill({ color: settings.ambientColor, alpha: settings.backgroundAlpha }); g.rect(0, 0, width, height); g.fill(); }, [width, height, lighting, getLightingSettings] ); const drawOverlay = useCallback( (g: any) => { g.clear(); const settings = getLightingSettings(lighting); // Traditional Korean mat pattern overlay g.stroke({ width: 1, color: lighting === "cyberpunk" ? KOREAN_COLORS.NEON_CYAN : KOREAN_COLORS.ACCENT_GOLD, alpha: settings.gridAlpha, }); const gridSize = 60; for (let i = 0; i < width; i += gridSize) { g.moveTo(i, 0); g.lineTo(i, height); } for (let j = 0; j < height; j += gridSize) { g.moveTo(0, j); g.lineTo(width, j); } g.stroke(); }, [width, height, lighting, getLightingSettings] ); const settings = getLightingSettings(lighting); return ( <pixiContainer {...props}> {floorTexture ? ( // Dojang Floor Texture Background <pixiSprite texture={floorTexture} x={0} y={0} width={width} height={height} alpha={settings.backgroundAlpha} tint={settings.tintColor} data-testid="dojang-floor-texture" /> ) : ( <pixiGraphics draw={drawFallbackBackground} data-testid="dojang-fallback-background" /> )} {wallTexture && lighting === "traditional" && ( <pixiSprite texture={wallTexture} x={width * 0.8} y={0} width={width * 0.3} height={height} alpha={0.3} tint={settings.tintColor} data-testid="dojang-wall-texture" /> )} <pixiGraphics draw={drawOverlay} data-testid="dojang-overlay" /> </pixiContainer> ); }; export default DojangBackground; |