/** * ============================================================================================== * Modul: DTIM-ZEC THE CUBE DOOM — 3D TOPOLOGICAL LABYRINTH & PROBANDEN-ARENA (OHNE P3D) * Datei: DTIM_ZEC_Cube_Doom.pde * Framework: DTIM-ZEC MODULAR PHYSICS FRAMEWORK (DAMTP ACADEMIC STANDARD) * Version: 2.1.0 (Flicker-Free Solid Billboards, Depth Sort & Debounced Lobby Sync) * Features: Pure Software 3D DDA-Raycaster (3 Z-Ebenen), DVL-Raumverschiebung [F], * Quanten-Arsenal [1-8] inkl. Teleport-Anker [7] & T-Gun [8], * 3 KI-Probanden & Offene +1/-1 Lobby (cube_lobby.php) * Copyright: (c) 2026 Jan Bühring & Adaptive Intelligence Synthesis Network (Google AI) * Lizenz: MIT License * Plattform: Processing 4.5.6 (Linux x64) & Processing.js (processing.min.js) * * Steuerung: * [W/A/S/D] oder [Pfeile] : Laufen & Drehen (Maus ziehen im 3D-Fenster dreht ebenfalls) * [Q / E] : Cube-Ebene (Z = 0, 1, 2) wechseln * [F] : DVL-Raumverschiebung (schiebt Reihe/Spalte vor dir!) * [1-8] + [Linksklick] : Waffe wählen & feuern ([5] Wand sprengen, [7] Anker, [8] T-Gun) * [H] : Sehhilfe (Standard / Farbenblind / Max-Kontrast) * ============================================================================================== */ // ============================================================================================== // MODUL 1: GLOBALE SYSTEMKONSTANTEN & CUBE-MATRIX (100% PROCESSING.JS-SICHER) // ============================================================================================== int GRID_N = 16; int GRID_Z = 3; int WIN_CORES = 4; // 4 Cube-Kerne sammeln = Ausbruch / Sieg int VIEW_X = 360; int VIEW_Y = 38; int VIEW_W = 760; // 360 + 760 = 1120 exakte Fensterbreite int VIEW_H = 664; // 38 + 664 + 38 = 740 exakte Fensterhöhe // 3D-Cube-Zellen [x + y*16 + z*256]: // 0=Frei, 1..6=Partikel-Wände, 7=Teleport-Anker, 8=Cube-Kern (Ziel), 9=Food, 10=Stone(+Anker), 11=Speed int[] cubeGrid = new int[16 * 16 * 3]; float[] zBuffer = new float[760]; // 4 Probanden (0 = Standard-Spieler, 1..3 = KI-Probanden oder übernommene Mitspieler) Proband[] probands = new Proband[4]; boolean[] isAiSlot = { false, true, true, true }; int localSeat = 0; // 0..3 = eigener Proband, -1 = Zuschauer (kann KI ersetzen!) // Arsenal [1..8] String[] weaponNames = { "Nix", "Proton (Wall)", "Neutron (Wall)", "Elektron (Push)", "Photon (Pulse)", "Positron (Break)", "Neutrino (Phase)", "Anker (Setzen)", "T-Gun (Beam)" }; int activeWeapon = 5; ArrayList cubeShots; int a11yTheme = 0; // 0: DTIM Standard (Schwarz/Blutrot/Nachtblau), 1: Farbenblind, 2: Max-Kontrast int winnerSeat = -1; // Visueller Teleport- & Treffer-Blitz float flashAlpha = 0.0; int flashR = 255; int flashG = 255; int flashB = 255; // Tastatur-Flags boolean keyW = false; boolean keyS = false; boolean keyA = false; boolean keyD = false; boolean keyTurnL = false; boolean keyTurnR = false; // Offene +1 / -1 Lobby (cube_lobby.php) mit gebündelter Synchronisation (kein Frame-Stottern) String myClientId = ""; boolean lobbyConnected = false; boolean lobbyDirty = false; int lobbyHumans = 1; int roomRevision = 0; int lobbyCooldown = 120; String lobbyNotice = ""; String cubeStatusMsg = "Willkommen im DTIM-ZEC Cube! Sammle 4 Cube-Kerne oder nutze [F] zum Raum-Verschieben."; // ============================================================================================== // MODUL 2: DATENSTRUKTUREN (PROBANDEN & QUANTEN-PROJEKTILE) // ============================================================================================== class Proband { int id; String label; float x; float y; int z; float dirX; float dirY; float planeX; float planeY; float speedBoost; int energy; int anchorAmmo; int coresCollected; int aiTimer; float aiTurnGoal; Proband(int idx, String title, float sx, float sy, int sz, float dx, float dy) { id = idx; label = title; x = sx; y = sy; z = sz; dirX = dx; dirY = dy; planeX = -dy * 0.66; planeY = dx * 0.66; speedBoost = 1.0; energy = 100; anchorAmmo = 3; coresCollected = 0; aiTimer = int(random(15, 45)); aiTurnGoal = 0.0; } void rotateBy(float ang) { float oldDirX = dirX; dirX = dirX * cos(ang) - dirY * sin(ang); dirY = oldDirX * sin(ang) + dirY * cos(ang); float oldPlaneX = planeX; planeX = planeX * cos(ang) - planeY * sin(ang); planeY = oldPlaneX * sin(ang) + planeY * cos(ang); } } class CubeProjectile { float x; float y; int z; float vx; float vy; int kind; // 1..6 int ownerId; int life; int phaseLeft; CubeProjectile(float sx, float sy, int sz, float svx, float svy, int k, int owner) { x = sx; y = sy; z = sz; vx = svx; vy = svy; kind = k; ownerId = owner; life = 95; phaseLeft = (k == 6) ? 1 : 0; } } class BillboardItem { float wx; float wy; float distSq; float scaleRel; float vShift; int col; boolean isHumanoid; BillboardItem(float x, float y, float d2, float sc, float vs, int c, boolean hum) { wx = x; wy = y; distSq = d2; scaleRel = sc; vShift = vs; col = c; isHumanoid = hum; } } // ============================================================================================== // MODUL 3: FARB-PALETTEN (SCHWARZ / BLUTROT / NACHTBLAU / SILBERGRAU + SEHHILFE) // ============================================================================================== int getUiPalette(int theme, int role) { if (theme == 1) { if (role == 0) return color(5, 9, 17); if (role == 1) return color(11, 17, 29); if (role == 2) return color(180, 120, 10); if (role == 3) return color(10, 75, 130); if (role == 4) return color(251, 191, 36); return color(255, 255, 255); } if (theme == 2) { if (role == 0) return color(0, 0, 0); if (role == 1) return color(0, 0, 0); if (role == 2) return color(0, 0, 0); if (role == 3) return color(0, 0, 0); if (role == 4) return color(255, 255, 0); return color(255, 255, 255); } if (role == 0) return color(6, 8, 14); if (role == 1) return color(13, 16, 26); if (role == 2) return color(122, 16, 38); if (role == 3) return color(18, 46, 98); if (role == 4) return color(225, 55, 85); return color(242, 246, 255); } int getTypeColor(int theme, int t) { if (theme == 1) { if (t == 1) return color(230, 159, 0); if (t == 2) return color(195, 210, 230); if (t == 3) return color(56, 189, 248); if (t == 4) return color(253, 224, 71); if (t == 5) return color(244, 114, 182); if (t == 6) return color(45, 212, 191); if (t == 7) return color(251, 191, 36); if (t == 8) return color(255, 255, 255); if (t == 9) return color(52, 211, 153); if (t == 10) return color(148, 163, 184); return color(168, 85, 247); } if (theme == 2) { if (t == 7 || t == 8) return color(255, 255, 0); if (t == 9 || t == 11) return color(0, 255, 255); return color(255, 255, 255); } if (t == 1) return color(210, 38, 68); // Proton: Blutrot if (t == 2) return color(175, 190, 215); // Neutron: Silbergrau if (t == 3) return color(58, 125, 235); // Elektron: Nachtblau if (t == 4) return color(250, 210, 65); // Photon: Gold if (t == 5) return color(235, 65, 165); // Positron: Magenta if (t == 6) return color(55, 215, 210); // Neutrino: Cyan if (t == 7) return color(255, 40, 190); // Teleport-Anker: Leucht-Pink if (t == 8) return color(255, 220, 60); // Cube-Kern: Gold-Relikt if (t == 9) return color(40, 225, 145); // Food: Smaragd if (t == 10) return color(135, 150, 175); // Stone: Titan-Grau return color(175, 95, 255); // Speed: Violett } int getProbandColor(int theme, int pIdx) { if (theme == 1) { if (pIdx == 0) return color(56, 189, 248); if (pIdx == 1) return color(251, 191, 36); if (pIdx == 2) return color(52, 211, 153); return color(244, 114, 182); } if (theme == 2) { if (pIdx == 0) return color(0, 255, 255); if (pIdx == 1) return color(255, 255, 0); if (pIdx == 2) return color(0, 255, 120); return color(255, 120, 255); } if (pIdx == 0) return color(65, 145, 255); if (pIdx == 1) return color(40, 220, 130); if (pIdx == 2) return color(0, 225, 245); return color(235, 55, 85); } // ============================================================================================== // MODUL 4: INITIALISIERUNG & 3D-CUBE-GENERATOR (3 EBENEN) // ============================================================================================== void setup() { size(1120, 740); noSmooth(); frameRate(60); myClientId = "C" + int(random(100000, 999999)) + "_" + millis(); cubeShots = new ArrayList(); buildNewCubeArena(false); syncCubeLobby("poll", -1, false); if (lobbyConnected) { if (lobbyHumans == 0) { syncCubeLobby("claim", 0, false); syncCubeLobby("push", localSeat, true); } else { localSeat = -1; } } } void buildNewCubeArena(boolean pushOnline) { winnerSeat = -1; cubeShots.clear(); for (int z = 0; z < GRID_Z; z++) { for (int y = 0; y < GRID_N; y++) { for (int x = 0; x < GRID_N; x++) { if (x == 0 || y == 0 || x == GRID_N - 1 || y == GRID_N - 1) { setCubeCell(x, y, z, (z % 2 == 0) ? 1 : 3); } else { setCubeCell(x, y, z, 0); } } } for (int k = 3; k <= 12; k++) { if (k != 5 && k != 10) { setCubeCell(k, 4, z, 1); setCubeCell(k, 11, z, 3); setCubeCell(4, k, z, 2); setCubeCell(11, k, z, 1); } } setCubeCell(7, 7, z, 7); setCubeCell(8, 8, z, 7); spawnItemOnLevel(z, 8, 2); // Cube-Kerne spawnItemOnLevel(z, 9, 4); // Food spawnItemOnLevel(z, 10, 3); // Stone (+Anker) spawnItemOnLevel(z, 11, 3); // Speed } probands[0] = new Proband(0, "Proband 1", 2.5, 2.5, 0, 1.0, 0.0); probands[1] = new Proband(1, "Proband 2", 13.5, 2.5, 0, -1.0, 0.0); probands[2] = new Proband(2, "Proband 3", 2.5, 13.5, 1, 0.0, -1.0); probands[3] = new Proband(3, "Proband 4", 13.5, 13.5, 2, -1.0, 0.0); cubeStatusMsg = "Neuer Cube generiert! Sammle 4 Cube-Kerne oder nutze [F] zum Raum-Verschieben."; if (pushOnline && lobbyConnected && localSeat >= 0) { lobbyDirty = true; } } void spawnItemOnLevel(int zLvl, int itemType, int count) { int placed = 0; for (int attempt = 0; attempt < 200 && placed < count; attempt++) { int rx = int(random(2, GRID_N - 2)); int ry = int(random(2, GRID_N - 2)); if (getCubeCell(rx, ry, zLvl) == 0) { setCubeCell(rx, ry, zLvl, itemType); placed++; } } } int getCubeCell(int x, int y, int z) { if (x < 0 || x >= GRID_N || y < 0 || y >= GRID_N || z < 0 || z >= GRID_Z) return -1; return cubeGrid[x + y * GRID_N + z * GRID_N * GRID_N]; } void setCubeCell(int x, int y, int z, int val) { if (x < 0 || x >= GRID_N || y < 0 || y >= GRID_N || z < 0 || z >= GRID_Z) return; cubeGrid[x + y * GRID_N + z * GRID_N * GRID_N] = val; } boolean isWallBlocking(int cellVal) { return (cellVal >= 1 && cellVal <= 7) || cellVal == -1; } // ============================================================================================== // MODUL 5: HAUPTSCHLEIFE // ============================================================================================== void draw() { background(getUiPalette(a11yTheme, 0)); // Gebündelte Lobby-Synchronisation (alle 3 Sekunden statt bei jedem Treffer -> flüssige 60 FPS) if (lobbyConnected) { if (lobbyCooldown > 0) lobbyCooldown--; if (lobbyCooldown <= 0) { if (lobbyDirty && localSeat >= 0) { syncCubeLobby("push", localSeat, true); lobbyDirty = false; lobbyCooldown = 180; } else { syncCubeLobby("poll", -1, false); lobbyCooldown = 210; } } } int camSeat = (localSeat >= 0) ? localSeat : 0; Proband viewProb = probands[camSeat]; if (winnerSeat == -1) { if (localSeat >= 0 && !isAiSlot[localSeat]) { updateHumanProband(viewProb); } if (canRunAiLocally()) { updateAllAiProbands(); } updateCubeProjectiles(); } // 1. Obere Lobby- & Statusleiste drawTopLobbyBar(); // 2. Linkes Terminal drawLeftCubeTerminal(viewProb); // 3. Rechter 3D-Software-Raycaster (flackerfreie solide Pixelspalten!) renderSoftware3DCube(viewProb); render3DSpritesAndProbands(viewProb); drawCrosshairAndFooter(); // 4. Teleport- / Treffer-Blitz if (flashAlpha > 0.0) { noStroke(); fill(flashR, flashG, flashB, flashAlpha); rect(VIEW_X, VIEW_Y, VIEW_W, VIEW_H); flashAlpha -= 16.0; } // 5. Sieges-Overlay if (winnerSeat >= 0) { drawWinnerBanner(); } } boolean canRunAiLocally() { if (!lobbyConnected) return true; if (localSeat < 0) return false; for (int i = 0; i < localSeat; i++) { if (!isAiSlot[i]) return false; } return true; } // ============================================================================================== // MODUL 6: BEWEGUNG, DVL-RAUMVERSCHIEBUNG & KI-PROBANDEN // ============================================================================================== void updateHumanProband(Proband p) { float mSpd = 0.068 * p.speedBoost; float rSpd = 0.045; if (keyTurnL) p.rotateBy(-rSpd); if (keyTurnR) p.rotateBy(rSpd); float moveX = 0.0; float moveY = 0.0; if (keyW) { moveX += p.dirX * mSpd; moveY += p.dirY * mSpd; } if (keyS) { moveX -= p.dirX * mSpd; moveY -= p.dirY * mSpd; } if (keyA) { moveX += p.dirY * mSpd; moveY -= p.dirX * mSpd; } if (keyD) { moveX -= p.dirY * mSpd; moveY += p.dirX * mSpd; } moveProbandWithCollision(p, moveX, moveY); checkPickupForProband(p); } void moveProbandWithCollision(Proband p, float dx, float dy) { float margin = 0.24; float nx = p.x + dx; float ny = p.y + dy; float checkX = nx + ((dx > 0) ? margin : -margin); if (!isWallBlocking(getCubeCell(int(checkX), int(p.y), p.z))) { p.x = nx; } float checkY = ny + ((dy > 0) ? margin : -margin); if (!isWallBlocking(getCubeCell(int(p.x), int(checkY), p.z))) { p.y = ny; } } void checkPickupForProband(Proband p) { int gx = int(p.x); int gy = int(p.y); int cell = getCubeCell(gx, gy, p.z); if (cell == 8) { setCubeCell(gx, gy, p.z, 0); p.coresCollected++; spawnItemOnLevel(p.z, 8, 1); if (p.id == localSeat) { triggerFlash(255, 220, 60, 120.0); cubeStatusMsg = p.label + " birgt einen Cube-Kern (" + p.coresCollected + "/" + WIN_CORES + ")!"; } if (p.coresCollected >= WIN_CORES) { winnerSeat = p.id; } markLobbyDirty(); } else if (cell == 9) { setCubeCell(gx, gy, p.z, 0); p.energy = min(100, p.energy + 25); spawnItemOnLevel(p.z, 9, 1); if (p.id == localSeat) cubeStatusMsg = "Food absorbiert: Energie auf " + p.energy + "% regeneriert."; markLobbyDirty(); } else if (cell == 10) { setCubeCell(gx, gy, p.z, 0); p.anchorAmmo += 2; spawnItemOnLevel(p.z, 10, 1); if (p.id == localSeat) cubeStatusMsg = "Struktur-Stone gesammelt: +2 Teleport-Anker (" + p.anchorAmmo + " verfügbar)."; markLobbyDirty(); } else if (cell == 11) { setCubeCell(gx, gy, p.z, 0); p.speedBoost = min(1.85, p.speedBoost + 0.18); spawnItemOnLevel(p.z, 11, 1); if (p.id == localSeat) cubeStatusMsg = "Quanten-Speed aktiviert! Tempo: " + nf(p.speedBoost, 1, 2) + "x"; markLobbyDirty(); } } void shiftCubeSliceAhead(Proband p) { int stepX = 0; int stepY = 0; if (abs(p.dirX) > abs(p.dirY)) stepX = (p.dirX > 0) ? 1 : -1; else stepY = (p.dirY > 0) ? 1 : -1; int targetX = constrain(int(p.x) + stepX * 2, 1, GRID_N - 2); int targetY = constrain(int(p.y) + stepY * 2, 1, GRID_N - 2); int zLvl = p.z; if (stepX != 0) { int saved = getCubeCell(targetX, GRID_N - 2, zLvl); for (int y = GRID_N - 2; y > 1; y--) { setCubeCell(targetX, y, zLvl, getCubeCell(targetX, y - 1, zLvl)); } setCubeCell(targetX, 1, zLvl, saved); for (int i = 0; i < 4; i++) { if (probands[i].z == zLvl && int(probands[i].x) == targetX) { int ny = int(probands[i].y) + 1; if (ny > GRID_N - 2) ny = 1; probands[i].y = ny + 0.5; } } cubeStatusMsg = p.label + " verschiebt Cube-Spalte X=" + targetX + " (DVL-Matrix-Shift)!"; } else { int saved = getCubeCell(GRID_N - 2, targetY, zLvl); for (int x = GRID_N - 2; x > 1; x--) { setCubeCell(x, targetY, zLvl, getCubeCell(x - 1, targetY, zLvl)); } setCubeCell(1, targetY, zLvl, saved); for (int i = 0; i < 4; i++) { if (probands[i].z == zLvl && int(probands[i].y) == targetY) { int nx = int(probands[i].x) + 1; if (nx > GRID_N - 2) nx = 1; probands[i].x = nx + 0.5; } } cubeStatusMsg = p.label + " verschiebt Cube-Reihe Y=" + targetY + " (DVL-Matrix-Shift)!"; } triggerFlash(65, 145, 255, 85.0); markLobbyDirty(); } void switchProbandZLevel(Proband p, int deltaZ) { int nextZ = (p.z + deltaZ + GRID_Z) % GRID_Z; p.z = nextZ; int gx = int(p.x); int gy = int(p.y); if (isWallBlocking(getCubeCell(gx, gy, nextZ))) { for (int r = 1; r <= 3; r++) { for (int dy = -r; dy <= r; dy++) { for (int dx = -r; dx <= r; dx++) { if (!isWallBlocking(getCubeCell(gx + dx, gy + dy, nextZ))) { p.x = gx + dx + 0.5; p.y = gy + dy + 0.5; triggerFlash(175, 95, 255, 95.0); cubeStatusMsg = "Phasen-Sprung auf Cube-Ebene Z=" + nextZ; return; } } } } } triggerFlash(175, 95, 255, 95.0); cubeStatusMsg = "Phasen-Sprung auf Cube-Ebene Z=" + nextZ; } void updateAllAiProbands() { for (int i = 0; i < 4; i++) { if (!isAiSlot[i]) continue; Proband ai = probands[i]; ai.aiTimer--; if (ai.aiTimer <= 0) { ai.aiTimer = int(random(30, 70)); ai.aiTurnGoal = random(-0.9, 0.9); float actionRoll = random(1.0); if (actionRoll < 0.07) { switchProbandZLevel(ai, 1); } else if (actionRoll < 0.14) { shiftCubeSliceAhead(ai); } else if (actionRoll < 0.32) { fireWeaponFromProband(ai, int(random(1, 7))); } } if (abs(ai.aiTurnGoal) > 0.02) { float stepRot = ai.aiTurnGoal * 0.14; ai.rotateBy(stepRot); ai.aiTurnGoal -= stepRot; } float prevX = ai.x; float prevY = ai.y; float spd = 0.052 * ai.speedBoost; moveProbandWithCollision(ai, ai.dirX * spd, ai.dirY * spd); if (dist(prevX, prevY, ai.x, ai.y) < spd * 0.35) { ai.rotateBy(HALF_PI * ((i % 2 == 0) ? 1.0 : -1.0)); } checkPickupForProband(ai); } } // ============================================================================================== // MODUL 7: QUANTEN-WAFFEN, WAND-SPRENGUNG [5], ANKER [7] & T-GUN [8] // ============================================================================================== void fireWeaponFromProband(Proband shooter, int wKind) { if (wKind == 0) return; if (wKind == 7 || wKind == 8) { float rdx = shooter.dirX; float rdy = shooter.dirY; int mapX = int(shooter.x); int mapY = int(shooter.y); float ddx = (rdx == 0.0) ? 1e30 : abs(1.0 / rdx); float ddy = (rdy == 0.0) ? 1e30 : abs(1.0 / rdy); int stepX = (rdx < 0) ? -1 : 1; int stepY = (rdy < 0) ? -1 : 1; float sdx = (rdx < 0) ? (shooter.x - mapX) * ddx : (mapX + 1.0 - shooter.x) * ddx; float sdy = (rdy < 0) ? (shooter.y - mapY) * ddy : (mapY + 1.0 - shooter.y) * ddy; int hit = 0; int hitType = 0; int side = 0; int guard = 0; while (hit == 0 && guard < 32) { guard++; if (sdx < sdy) { sdx += ddx; mapX += stepX; side = 0; } else { sdy += ddy; mapY += stepY; side = 1; } hitType = getCubeCell(mapX, mapY, shooter.z); if (isWallBlocking(hitType)) hit = 1; } if (wKind == 7) { if (shooter.anchorAmmo <= 0) { cubeStatusMsg = "Keine Anker-Ladungen mehr! Sammle graue Stone-Blöcke."; return; } int bx = (side == 0) ? mapX - stepX : mapX; int by = (side == 1) ? mapY - stepY : mapY; if (bx > 0 && bx < GRID_N - 1 && by > 0 && by < GRID_N - 1) { if (!(bx == int(shooter.x) && by == int(shooter.y)) && getCubeCell(bx, by, shooter.z) == 0) { setCubeCell(bx, by, shooter.z, 7); shooter.anchorAmmo--; triggerFlash(255, 40, 190, 95.0); cubeStatusMsg = "Teleport-Anker bei (" + bx + "," + by + ") verankert! (Rest: " + shooter.anchorAmmo + ")"; markLobbyDirty(); } } } else if (wKind == 8) { if (hitType == 7) { int tx = (side == 0) ? mapX - stepX : mapX; int ty = (side == 1) ? mapY - stepY : mapY; if (!isWallBlocking(getCubeCell(tx, ty, shooter.z))) { shooter.x = tx + 0.5; shooter.y = ty + 0.5; triggerFlash(255, 220, 60, 190.0); cubeStatusMsg = "T-GUN TRANSLOKATION! Instantan zum Teleport-Anker gebeamt!"; markLobbyDirty(); } } else { cubeStatusMsg = "T-Gun benötigt einen pinken Teleport-Anker [7] im Fadenkreuz!"; } } return; } float spd = (wKind == 4) ? 0.34 : 0.22; cubeShots.add(new CubeProjectile(shooter.x + shooter.dirX * 0.4, shooter.y + shooter.dirY * 0.4, shooter.z, shooter.dirX * spd, shooter.dirY * spd, wKind, shooter.id)); } void updateCubeProjectiles() { for (int i = cubeShots.size() - 1; i >= 0; i--) { CubeProjectile q = (CubeProjectile) cubeShots.get(i); float nx = q.x + q.vx; float ny = q.y + q.vy; q.life--; if (q.life <= 0) { cubeShots.remove(i); continue; } boolean hitProband = false; for (int p = 0; p < 4; p++) { if (p == q.ownerId) continue; if (probands[p].z == q.z && dist(nx, ny, probands[p].x, probands[p].y) < 0.48) { moveProbandWithCollision(probands[p], q.vx * 2.4, q.vy * 2.4); probands[p].energy = max(10, probands[p].energy - 12); if (p == localSeat) { triggerFlash(235, 55, 85, 130.0); cubeStatusMsg = "Treffer von " + probands[q.ownerId].label + "! Energie: " + probands[p].energy + "%"; } hitProband = true; break; } } if (hitProband) { cubeShots.remove(i); continue; } int cx = int(nx); int cy = int(ny); int cell = getCubeCell(cx, cy, q.z); if (isWallBlocking(cell)) { if (q.kind == 6 && q.phaseLeft > 0 && cx > 0 && cx < GRID_N - 1 && cy > 0 && cy < GRID_N - 1) { q.phaseLeft--; q.x = nx + q.vx * 2.2; q.y = ny + q.vy * 2.2; continue; } if (q.kind == 5 && cell >= 1 && cell <= 7 && cx > 0 && cx < GRID_N - 1 && cy > 0 && cy < GRID_N - 1) { setCubeCell(cx, cy, q.z, 0); if (q.ownerId == localSeat) { cubeStatusMsg = "Positron-Annihilation: Cube-Wand bei (" + cx + "," + cy + ") aufgelöst!"; } markLobbyDirty(); } else if (q.kind >= 1 && q.kind <= 3) { int bx = int(q.x); int by = int(q.y); if (bx > 0 && bx < GRID_N - 1 && by > 0 && by < GRID_N - 1 && getCubeCell(bx, by, q.z) == 0) { setCubeCell(bx, by, q.z, q.kind); markLobbyDirty(); } } cubeShots.remove(i); } else { q.x = nx; q.y = ny; } } } void triggerFlash(int r, int g, int b, float strength) { flashR = r; flashG = g; flashB = b; flashAlpha = strength; } // ============================================================================================== // MODUL 8: FLACKERFREIER SOFTWARE 3D DDA-RAYCASTER & TIEFENSORTIERTE KUGEL-SPRITES // ============================================================================================== void renderSoftware3DCube(Proband cam) { int halfH = VIEW_H / 2; noStroke(); if (a11yTheme == 2) { fill(0); rect(VIEW_X, VIEW_Y, VIEW_W, VIEW_H); } else { fill(18, 6, 12); rect(VIEW_X, VIEW_Y, VIEW_W, halfH); fill(10, 16, 30); rect(VIEW_X, VIEW_Y + halfH, VIEW_W, halfH); } for (int x = 0; x < VIEW_W; x++) { float cameraX = 2.0 * x / float(VIEW_W) - 1.0; float rayDirX = cam.dirX + cam.planeX * cameraX; float rayDirY = cam.dirY + cam.planeY * cameraX; int mapX = int(cam.x); int mapY = int(cam.y); float deltaDistX = (rayDirX == 0.0) ? 1e30 : abs(1.0 / rayDirX); float deltaDistY = (rayDirY == 0.0) ? 1e30 : abs(1.0 / rayDirY); int stepX = (rayDirX < 0) ? -1 : 1; int stepY = (rayDirY < 0) ? -1 : 1; float sideDistX = (rayDirX < 0) ? (cam.x - mapX) * deltaDistX : (mapX + 1.0 - cam.x) * deltaDistX; float sideDistY = (rayDirY < 0) ? (cam.y - mapY) * deltaDistY : (mapY + 1.0 - cam.y) * deltaDistY; int hit = 0; int side = 0; int hitType = 0; int guard = 0; while (hit == 0 && guard < 48) { guard++; if (sideDistX < sideDistY) { sideDistX += deltaDistX; mapX += stepX; side = 0; } else { sideDistY += deltaDistY; mapY += stepY; side = 1; } hitType = getCubeCell(mapX, mapY, cam.z); if (isWallBlocking(hitType)) hit = 1; } float perpWallDist; if (side == 0) perpWallDist = max(0.08, (mapX - cam.x + (1 - stepX) * 0.5) / rayDirX); else perpWallDist = max(0.08, (mapY - cam.y + (1 - stepY) * 0.5) / rayDirY); zBuffer[x] = perpWallDist; int lineHeight = int(VIEW_H / perpWallDist); int drawStart = max(0, -lineHeight / 2 + halfH); int drawEnd = min(VIEW_H - 1, lineHeight / 2 + halfH); float wallX = (side == 0) ? (cam.y + perpWallDist * rayDirY) : (cam.x + perpWallDist * rayDirX); wallX -= floor(wallX); int baseCol = (hitType <= 0) ? color(120, 130, 155) : getTypeColor(a11yTheme, hitType); float shade = constrain(1.0 / (1.0 + perpWallDist * 0.14), 0.22, 1.0); if (side == 1) shade *= 0.74; if (wallX < 0.04 || wallX > 0.96) shade *= 1.25; // Lückenloses rect() statt 1px line() -> kein Subpixel-Flimmern im Browser-Canvas fill(red(baseCol) * shade, green(baseCol) * shade, blue(baseCol) * shade); int spanH = max(1, drawEnd - drawStart + 1); rect(VIEW_X + x, VIEW_Y + drawStart, 1, spanH); } } void render3DSpritesAndProbands(Proband cam) { float invDet = 1.0 / (cam.planeX * cam.dirY - cam.dirX * cam.planeY); ArrayList visibleList = new ArrayList(); // 1. Pickups (8=Core, 9=Food, 10=Stone, 11=Speed) sammeln for (int y = 1; y < GRID_N - 1; y++) { for (int x = 1; x < GRID_N - 1; x++) { int item = getCubeCell(x, y, cam.z); if (item >= 8 && item <= 11) { float wx = x + 0.5; float wy = y + 0.5; float d2 = (wx - cam.x) * (wx - cam.x) + (wy - cam.y) * (wy - cam.y); int col = getTypeColor(a11yTheme, item); // Ruhiges Schweben ohne schnelles Pixel-Zittern float bob = sin(frameCount * 0.035 + (x + y) * 0.7) * 0.045; visibleList.add(new BillboardItem(wx, wy, d2, 0.36, bob, col, false)); } } } // 2. Fliegende Quanten-Projektile sammeln for (int i = 0; i < cubeShots.size(); i++) { CubeProjectile q = (CubeProjectile) cubeShots.get(i); if (q.z == cam.z) { float d2 = (q.x - cam.x) * (q.x - cam.x) + (q.y - cam.y) * (q.y - cam.y); visibleList.add(new BillboardItem(q.x, q.y, d2, 0.24, 0.0, getTypeColor(a11yTheme, q.kind), false)); } } // 3. Andere KI- / Mitspieler-Probanden sammeln for (int p = 0; p < 4; p++) { if (p == cam.id || probands[p].z != cam.z) continue; float d2 = (probands[p].x - cam.x) * (probands[p].x - cam.x) + (probands[p].y - cam.y) * (probands[p].y - cam.y); visibleList.add(new BillboardItem(probands[p].x, probands[p].y, d2, 0.62, 0.05, getProbandColor(a11yTheme, p), true)); } // Painter's Algorithmus: Von hinten nach vorne sortieren (größtes distSq zuerst) for (int i = 0; i < visibleList.size() - 1; i++) { for (int j = i + 1; j < visibleList.size(); j++) { BillboardItem a = (BillboardItem) visibleList.get(i); BillboardItem b = (BillboardItem) visibleList.get(j); if (b.distSq > a.distSq) { visibleList.set(i, b); visibleList.set(j, a); } } } for (int i = 0; i < visibleList.size(); i++) { BillboardItem item = (BillboardItem) visibleList.get(i); drawProjectedBillboard(cam, invDet, item.wx, item.wy, item.scaleRel, item.vShift, item.col, item.isHumanoid); } } void drawProjectedBillboard(Proband cam, float invDet, float wx, float wy, float scaleRel, float vShift, int col, boolean isHumanoid) { float spriteX = wx - cam.x; float spriteY = wy - cam.y; float transformX = invDet * (cam.dirY * spriteX - cam.dirX * spriteY); float transformY = invDet * (-cam.planeY * spriteX + cam.planeX * spriteY); if (transformY <= 0.16) return; int spriteScreenX = int((VIEW_W * 0.5) * (1.0 + transformX / transformY)); int spriteSize = abs(int((VIEW_H / transformY) * scaleRel)); if (spriteSize < 4 || spriteSize > VIEW_H * 2) return; int halfW = max(2, spriteSize / 2); int centerY = VIEW_Y + VIEW_H / 2 + int((vShift / transformY) * VIEW_H * 0.4); int startX = max(0, spriteScreenX - halfW); int endX = min(VIEW_W - 1, spriteScreenX + halfW); noStroke(); int coreCol = lerpColor(col, color(255), 0.55); for (int stripe = startX; stripe <= endX; stripe++) { if (transformY < zBuffer[stripe]) { float nx = (stripe - spriteScreenX) / float(halfW); if (isHumanoid) { int topY = max(VIEW_Y, centerY - int(spriteSize * 0.65)); int botY = min(VIEW_Y + VIEW_H - 1, centerY + int(spriteSize * 0.75)); if (botY >= topY) { fill(col); rect(VIEW_X + stripe, topY, 1, botY - topY + 1); if (abs(nx) < 0.55) { fill(255); int visorY = constrain(centerY - int(spriteSize * 0.32), VIEW_Y + 2, VIEW_Y + VIEW_H - 5); rect(VIEW_X + stripe, visorY - 2, 1, 5); } } } else { // Solide gefüllte Kugel-Spalte mit hellem Kern-Glanz (ohne line()-Flackern!) float chord = sqrt(max(0.0, 1.0 - nx * nx)) * halfW; int y1 = max(VIEW_Y, int(centerY - chord)); int y2 = min(VIEW_Y + VIEW_H - 1, int(centerY + chord)); if (y2 >= y1) { fill(col); rect(VIEW_X + stripe, y1, 1, y2 - y1 + 1); if (abs(nx) < 0.48) { float innerChord = chord * 0.48; int iy1 = max(VIEW_Y, int(centerY - innerChord)); int iy2 = min(VIEW_Y + VIEW_H - 1, int(centerY + innerChord)); if (iy2 >= iy1) { fill(coreCol); rect(VIEW_X + stripe, iy1, 1, iy2 - iy1 + 1); } } } } } } } // ============================================================================================== // MODUL 9: LINKES CUBE-TERMINAL & LOBBY-LEISTE // ============================================================================================== void drawTopLobbyBar() { fill(getUiPalette(a11yTheme, 1)); noStroke(); rect(0, 0, width, 38); stroke(getUiPalette(a11yTheme, 4)); line(0, 38, width, 38); fill(255); textSize(12); textAlign(LEFT, CENTER); if (!lobbyConnected) { text("DTIM-ZEC CUBE DOOM (Einzelspieler vs. 3 KI-Probanden · Klick auf KI-Badge wechselt Steuerung)", 14, 19); } else if (localSeat == -1) { fill(255, 225, 95); text("OFFENER CUBE AKTIV (" + lobbyHumans + " Spieler): KI ersetzen ->", 14, 19); int bx = 375; for (int i = 0; i < 4; i++) { if (isAiSlot[i]) { drawUiBtn(bx, 7, 136, 24, "Proband " + (i + 1) + " übernehmen", getUiPalette(a11yTheme, 2)); bx += 144; } } } else { text("Offener Cube (" + lobbyHumans + " Mensch(en)) · Du bist Proband " + (localSeat + 1) + " · " + lobbyNotice, 14, 19); drawUiBtn(width - 315, 7, 155, 24, "An KI abgeben (-1)", color(35, 44, 66)); } String a11yLbl = (a11yTheme == 0) ? "Sehhilfe [H]" : ((a11yTheme == 1) ? "Farbenblind" : "Max-Kontrast"); drawUiBtn(width - 150, 7, 136, 24, a11yLbl, getUiPalette(a11yTheme, 3)); } void drawLeftCubeTerminal(Proband cam) { fill(getUiPalette(a11yTheme, 1)); noStroke(); rect(0, 38, VIEW_X, height - 38); stroke(getUiPalette(a11yTheme, 4)); line(VIEW_X, 38, VIEW_X, height); int mapX = 14; int mapY = 50; int cellPx = 14; fill(4, 6, 12); stroke(59, 110, 194); rect(mapX - 1, mapY - 1, GRID_N * cellPx + 2, GRID_N * cellPx + 2); noStroke(); for (int y = 0; y < GRID_N; y++) { for (int x = 0; x < GRID_N; x++) { int v = getCubeCell(x, y, cam.z); if (v > 0) { fill(getTypeColor(a11yTheme, v)); rect(mapX + x * cellPx, mapY + y * cellPx, cellPx - 1, cellPx - 1); } } } for (int p = 0; p < 4; p++) { if (probands[p].z != cam.z) continue; float px = mapX + probands[p].x * cellPx; float py = mapY + probands[p].y * cellPx; fill(getProbandColor(a11yTheme, p)); stroke(255); ellipse(px, py, 7, 7); if (p == cam.id) { line(px, py, px + cam.dirX * 13, py + cam.dirY * 13); } noStroke(); } int sideX = 248; fill(255); textSize(12); textAlign(LEFT, TOP); text("CUBE-EBENE:", sideX, 50); drawUiBtn(sideX, 70, 98, 26, "Z = " + cam.z + " / 2 [Q/E]", getUiPalette(a11yTheme, 3)); drawUiBtn(sideX, 102, 98, 28, "Raum-Shift [F]", getUiPalette(a11yTheme, 2)); drawUiBtn(sideX, 136, 98, 24, "Neu Würfeln", color(30, 38, 56)); text("PROBANDEN:", sideX, 170); for (int p = 0; p < 4; p++) { int py = 190 + p * 22; fill(getProbandColor(a11yTheme, p)); rect(sideX, py + 2, 10, 10, 2); fill(240); textSize(10); String tag = (isAiSlot[p] ? "KI" : "M") + " P" + (p + 1) + ": " + probands[p].coresCollected + "/" + WIN_CORES + " (Z" + probands[p].z + ")"; text(tag, sideX + 14, py + 1); } fill(255); textSize(12); text("QUANTEN-ARSENAL (Tasten 1-8):", 14, 288); for (int i = 1; i <= 8; i++) { int wy = 308 + (i - 1) * 29; boolean sel = (activeWeapon == i); if (a11yTheme == 2) { fill(0); stroke(sel ? color(255, 255, 0) : color(255)); } else { fill(sel ? getUiPalette(a11yTheme, 2) : color(20, 25, 38)); stroke(sel ? getUiPalette(a11yTheme, 4) : color(55, 68, 95)); } rect(14, wy, VIEW_X - 28, 25, 4); fill(getTypeColor(a11yTheme, i)); stroke(255); rect(20, wy + 5, 14, 14, 2); fill(255); textSize(11); textAlign(LEFT, CENTER); String extra = (i == 7) ? " (" + cam.anchorAmmo + "x)" : ""; text("[" + i + "] " + weaponNames[i] + extra, 42, wy + 12); } fill(14, 18, 28); stroke(55, 68, 95); rect(14, 548, VIEW_X - 28, 178, 6); fill(255); textSize(11); textAlign(LEFT, TOP); text("CUBE-RESSOURCEN & TELEMETRIE:", 24, 556); text("Energie: " + cam.energy + "% | Speed: " + nf(cam.speedBoost, 1, 2) + "x | Anker: " + cam.anchorAmmo, 24, 576); drawLegendDot(24, 602, getTypeColor(a11yTheme, 8), "Cube-Kern (4 Stück sammeln = Sieg!)"); drawLegendDot(24, 622, getTypeColor(a11yTheme, 9), "Food (+25% Energie)"); drawLegendDot(24, 642, getTypeColor(a11yTheme, 10), "Stone (+2 Teleport-Anker [7])"); drawLegendDot(24, 662, getTypeColor(a11yTheme, 11), "Speed (+0.18x Laufgeschwindigkeit)"); fill(195, 210, 235); textSize(10); text("Klick ins 3D-Bild = Feuern | Maus ziehen = Drehen", 24, 692); } void drawLegendDot(int lx, int ly, int col, String label) { fill(col); noStroke(); ellipse(lx + 5, ly + 6, 9, 9); fill(230, 238, 250); textSize(11); text(label, lx + 16, ly); } void drawCrosshairAndFooter() { stroke(a11yTheme == 2 ? color(255, 255, 0) : color(125, 211, 252)); strokeWeight(2.0); int cx = VIEW_X + VIEW_W / 2; int cy = VIEW_Y + VIEW_H / 2; line(cx - 10, cy, cx + 10, cy); line(cx, cy - 10, cx, cy + 10); noFill(); ellipse(cx, cy, 26, 26); strokeWeight(1.0); int fy = VIEW_Y + VIEW_H; fill(getUiPalette(a11yTheme, 1)); noStroke(); rect(VIEW_X, fy, VIEW_W, height - fy); stroke(getUiPalette(a11yTheme, 4)); line(VIEW_X, fy, width, fy); fill(255); textSize(12); textAlign(LEFT, CENTER); text(cubeStatusMsg, VIEW_X + 14, fy + (height - fy) * 0.5); } void drawWinnerBanner() { fill(4, 5, 12, 225); noStroke(); rect(VIEW_X, VIEW_Y, VIEW_W, VIEW_H); fill(getUiPalette(a11yTheme, 1)); stroke(getProbandColor(a11yTheme, winnerSeat)); strokeWeight(2.5); rect(VIEW_X + 130, VIEW_Y + 200, 500, 220, 10); strokeWeight(1.0); fill(255); textSize(20); textAlign(CENTER, CENTER); text(probands[winnerSeat].label.toUpperCase() + " ENTKOMMT DEM CUBE!", VIEW_X + VIEW_W * 0.5, VIEW_Y + 250); fill(225, 235, 250); textSize(13); text("Alle " + WIN_CORES + " Cube-Kerne wurden geborgen!", VIEW_X + VIEW_W * 0.5, VIEW_Y + 295); drawUiBtn(VIEW_X + 270, VIEW_Y + 345, 220, 40, "NEUEN CUBE GENERIEREN", getUiPalette(a11yTheme, 2)); } void drawUiBtn(int bx, int by, int bw, int bh, String label, int bgCol) { if (a11yTheme == 2) { fill(0); stroke(255, 255, 0); } else { fill(bgCol); stroke(125, 160, 220); } rect(bx, by, bw, bh, 4); fill(a11yTheme == 2 ? color(255, 255, 0) : color(255)); textSize(11); textAlign(CENTER, CENTER); text(label, bx + bw * 0.5, by + bh * 0.5); } // ============================================================================================== // MODUL 10: OFFENE LOBBY-SYNCHRONISATION (GEBÜNDELT & OHNE FRAME-RUCKLER) // ============================================================================================== void markLobbyDirty() { if (lobbyConnected && localSeat >= 0) { lobbyDirty = true; } } void syncCubeLobby(String action, int reqSeat, boolean sendState) { try { String url = "cube_lobby.php?action=" + action + "&cid=" + myClientId + "&seat=" + reqSeat; if (sendState) { url = url + "&st=" + encodeCubeState() + "&ev=" + cleanUrlStr(cubeStatusMsg); } String[] lines = loadStrings(url); if (lines == null || lines.length == 0) return; boolean okFound = false; int remoteRev = roomRevision; String remoteState = ""; for (int i = 0; i < lines.length; i++) { String line = trim(lines[i]); int eq = line.indexOf('='); if (eq <= 0) continue; String k = line.substring(0, eq); String v = line.substring(eq + 1); if (k.equals("STATUS") && v.equals("OK")) okFound = true; else if (k.equals("HUMANS")) lobbyHumans = int(v); else if (k.equals("MY_SEAT")) localSeat = int(v); else if (k.equals("REVISION")) remoteRev = int(v); else if (k.equals("SEAT_0")) isAiSlot[0] = v.equals("AI"); else if (k.equals("SEAT_1")) isAiSlot[1] = v.equals("AI"); else if (k.equals("SEAT_2")) isAiSlot[2] = v.equals("AI"); else if (k.equals("SEAT_3")) isAiSlot[3] = v.equals("AI"); else if (k.equals("EVENT")) lobbyNotice = v; else if (k.equals("STATE")) remoteState = v; } if (okFound) { lobbyConnected = true; if (remoteRev > roomRevision && remoteState.length() > 20) { roomRevision = remoteRev; decodeCubeState(remoteState); } else if (sendState && remoteRev > roomRevision) { roomRevision = remoteRev; } } } catch (Exception e) { // Offline-Fallback (lokal unter Linux in Processing 4.5.6) } } String cleanUrlStr(String s) { String out = ""; for (int i = 0; i < min(s.length(), 85); i++) { char ch = s.charAt(i); if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '.') { out = out + ch; } else if (ch == ' ') { out = out + "_"; } } return out; } String encodeCubeState() { String hexChars = "0123456789abcdef"; String cells = ""; for (int i = 0; i < cubeGrid.length; i++) { int v = constrain(cubeGrid[i], 0, 15); cells = cells + str(hexChars.charAt(v)); } String pStr = ""; for (int i = 0; i < 4; i++) { Proband p = probands[i]; if (i > 0) pStr = pStr + ";"; pStr = pStr + nf(p.x, 1, 2) + "," + nf(p.y, 1, 2) + "," + p.z + "," + p.coresCollected + "," + p.energy; } return winnerSeat + "|" + cells + "|" + pStr; } void decodeCubeState(String raw) { String[] parts = split(raw, '|'); if (parts == null || parts.length < 3) return; winnerSeat = int(parts[0]); String hexChars = "0123456789abcdef"; String cellStr = parts[1]; if (cellStr.length() >= cubeGrid.length) { for (int i = 0; i < cubeGrid.length; i++) { int v = hexChars.indexOf(cellStr.charAt(i)); cubeGrid[i] = (v < 0) ? 0 : v; } } String[] pList = split(parts[2], ';'); if (pList != null && pList.length >= 4) { for (int i = 0; i < 4; i++) { String[] pv = split(pList[i], ','); if (pv != null && pv.length >= 5) { probands[i].x = float(pv[0]); probands[i].y = float(pv[1]); probands[i].z = int(pv[2]); probands[i].coresCollected = int(pv[3]); probands[i].energy = int(pv[4]); } } } } // ============================================================================================== // MODUL 11: MAUS- & TASTATUR-STEUERUNG // ============================================================================================== void mousePressed() { int camSeat = (localSeat >= 0) ? localSeat : 0; Proband cam = probands[camSeat]; if (winnerSeat >= 0) { if (mouseX >= VIEW_X + 270 && mouseX <= VIEW_X + 490 && mouseY >= VIEW_Y + 345 && mouseY <= VIEW_Y + 385) { buildNewCubeArena(true); } return; } if (mouseY <= 38) { if (mouseX >= width - 150 && mouseX <= width - 14) { a11yTheme = (a11yTheme + 1) % 3; return; } if (lobbyConnected) { if (localSeat == -1) { int bx = 375; for (int i = 0; i < 4; i++) { if (isAiSlot[i]) { if (mouseX >= bx && mouseX <= bx + 136) { syncCubeLobby("claim", i, false); return; } bx += 144; } } } else if (mouseX >= width - 315 && mouseX <= width - 160) { syncCubeLobby("release", localSeat, false); return; } } return; } if (mouseX < VIEW_X) { if (mouseX >= 248 && mouseX <= 346) { if (mouseY >= 70 && mouseY <= 96 && localSeat >= 0) { switchProbandZLevel(cam, 1); return; } if (mouseY >= 102 && mouseY <= 130 && localSeat >= 0) { shiftCubeSliceAhead(cam); return; } if (mouseY >= 136 && mouseY <= 160) { buildNewCubeArena(true); return; } if (!lobbyConnected && mouseY >= 190 && mouseY <= 278) { int idx = int((mouseY - 190) / 22); if (idx >= 0 && idx < 4) isAiSlot[idx] = !isAiSlot[idx]; return; } } if (mouseX >= 14 && mouseX <= VIEW_X - 14 && mouseY >= 308 && mouseY <= 540) { int wIdx = int((mouseY - 308) / 29) + 1; if (wIdx >= 1 && wIdx <= 8) activeWeapon = wIdx; return; } return; } if (mouseX >= VIEW_X && mouseY >= VIEW_Y && mouseY < VIEW_Y + VIEW_H && mouseButton == LEFT) { if (localSeat >= 0 && !isAiSlot[localSeat]) { fireWeaponFromProband(cam, activeWeapon); } } } void mouseDragged() { int camSeat = (localSeat >= 0) ? localSeat : 0; if (mouseX >= VIEW_X && localSeat >= 0 && !isAiSlot[localSeat]) { float deltaX = mouseX - pmouseX; probands[camSeat].rotateBy(-deltaX * 0.014); } } void keyPressed() { if (key == 'h' || key == 'H') { a11yTheme = (a11yTheme + 1) % 3; return; } if (key >= '1' && key <= '8') activeWeapon = key - '0'; int camSeat = (localSeat >= 0) ? localSeat : 0; Proband cam = probands[camSeat]; if (localSeat >= 0 && !isAiSlot[localSeat]) { if (key == 'q' || key == 'Q') switchProbandZLevel(cam, -1); if (key == 'e' || key == 'E') switchProbandZLevel(cam, 1); if (key == 'f' || key == 'F') shiftCubeSliceAhead(cam); if (key == ' ') fireWeaponFromProband(cam, activeWeapon); } if (key == 'w' || key == 'W') keyW = true; if (key == 's' || key == 'S') keyS = true; if (key == 'a' || key == 'A') keyA = true; if (key == 'd' || key == 'D') keyD = true; if (key == CODED) { if (keyCode == UP) keyW = true; if (keyCode == DOWN) keyS = true; if (keyCode == LEFT) keyTurnL = true; if (keyCode == RIGHT) keyTurnR = true; } } void keyReleased() { if (key == 'w' || key == 'W') keyW = false; if (key == 's' || key == 'S') keyS = false; if (key == 'a' || key == 'A') keyA = false; if (key == 'd' || key == 'D') keyD = false; if (key == CODED) { if (keyCode == UP) keyW = false; if (keyCode == DOWN) keyS = false; if (keyCode == LEFT) keyTurnL = false; if (keyCode == RIGHT) keyTurnR = false; } }