/* ============================================================================================== ATOM SMILE + DTIM ZEC DOOM (atom_smile_doom.pde) Physik-Simulator & Topologic First-Person Observer Framework (Pure Software Raycaster) SPECIAL FEATURE: Teleport-Anchor & Instant-Raycast Translocator (Parkour Mode) MIT License Copyright (c) 2024-2026 Jan Bühring & Adaptive Intelligence Synthesis Network (Google AI) ============================================================================================== */ import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.zip.*; // ============================================================================================== // 1. GLOBALE VARIABLEN (ATOM SMILE EDITOR) // ============================================================================================== float feld = 10.0f; int num = 30; int num1 = 30; int level = 0; // Z-Achse int ordner = 0; // Run-ID int iv = 1; int lastSavedFrame = 1; class Particle { int id; int type; int x, y, z; int[] props = new int[16]; } ArrayList particles = new ArrayList(); int[] typeCounters = new int[9]; // --- MEMORY CACHE --- HashMap> memoryFrames = new HashMap>(); HashMap memoryNum = new HashMap(); int[][][][] gridData = new int[105][105][105][16]; String[] themeNames = {"Klassik", "C-Blind", "Kontrast"}; color[][] colorThemes = { { color(255, 255, 255), color(255, 50, 50), color(50, 255, 50), color(50, 100, 255), color(255, 255, 50), color(255, 50, 255), color(50, 255, 255), color(255, 0, 200), color(255, 200, 0) }, { color(255, 255, 255), color(230, 159, 0), color(86, 180, 233), color(0, 158, 115), color(240, 228, 66), color(0, 114, 178), color(213, 94, 0), color(255, 0, 200), color(255, 200, 0) }, { color(255, 255, 255), color(200, 0, 0), color(0, 200, 0), color(0, 0, 200), color(255, 200, 0), color(200, 0, 200), color(0, 200, 200), color(255, 0, 200), color(255, 200, 0) } }; int currentTheme = 0; // 7: Teleport-Anker (Stein bauen), 8: Teleport-Gun (Zum Stein springen) String[] particleNames = {"nix", "proton", "neutron", "elektron", "photon", "positron", "neutrino", "Anker", "T-Gun"}; int currentParticle = 1; int[] inspectedProps = new int[16]; boolean hasInspected = false; int dom = 1; boolean showHelperGrid = true; boolean isPlaying = false; boolean urknallMode = false; boolean autoZipMode = true; boolean expertMode = false; boolean edgeWrapMode = true; int playTimer = 0; String flashMsg = ""; int flashMsgTimer = 0; int saveFlashTimer = 0; int sign(int v) { if (v > 0) return 1; if (v < 0) return -1; return 0; } // ============================================================================================== // 2. GLOBALE VARIABLEN (DTIM ZEC DOOM RAYCASTER) // ============================================================================================== boolean doomMode = false; float posX = 1.5, posY = 1.5; float dirX = -1.0, dirY = 0.0; float planeX = 0.0, planeY = 0.66; float moveSpeed = 0.08; float rotSpeed = 0.04; float[] zBuffer = new float[800]; float doomFlash = 0; color doomFlashColor = color(255); boolean keyW = false; boolean keyA = false; boolean keyS = false; boolean keyD = false; class DoomProjectile { float x, y; float vx, vy; color c; int type; int life = 100; DoomProjectile(float startX, float startY, float vX, float vY, int pType) { x = startX; y = startY; vx = vX; vy = vY; type = pType; c = colorThemes[currentTheme][type]; } } ArrayList doomProjectiles = new ArrayList(); float[] doomParticleSpeeds = { 0.0, 0.15, 0.15, 0.30, 0.40, 0.10, 0.20, 0.00, 0.00 }; void setup() { size(1200, 850); noSmooth(); background(255); ensureDir("sim0/"); updateGridFromParticles(); drawBlankGrid(); } void ensureDir(String path) { try { File f = new File(sketchPath(path)); if (!f.exists()) f.mkdirs(); } catch (Exception e) {} } void draw() { if (doomMode) drawDoomMode(); else drawEditorMode(); } // ============================================================================================== // MODUS 1: ATOM SMILE EDITOR // ============================================================================================== void wipeEntireGrid() { for (int l = 0; l < 105; l++) { for (int y = 0; y < 105; y++) { for (int x = 0; x < 105; x++) { for (int p = 0; p < 16; p++) gridData[x][y][l][p] = 0; } } } } void clearMemoryGrid() { int maxN = min(104, num + 2); for (int l = 0; l <= maxN; l++) { for (int y = 0; y <= maxN; y++) { for (int x = 0; x <= maxN; x++) { for (int p = 0; p < 16; p++) gridData[x][y][l][p] = 0; } } } } void updateGridFromParticles() { clearMemoryGrid(); for (Particle p : particles) { if (p.x >= 0 && p.x <= num && p.y >= 0 && p.y <= num && p.z >= 0 && p.z <= num) { for(int i=0; i<16; i++) gridData[p.x][p.y][p.z][i] = p.props[i]; } } } boolean frameExistsLocally(int targetFrame) { if (memoryFrames.containsKey(targetFrame)) return true; try { String baseDir = "sim" + ordner + "/"; if (autoZipMode) { File zipF = new File(sketchPath(baseDir + "frame_" + nf(targetFrame, 4) + ".zip")); if (zipF.exists()) return true; } } catch(Exception e) {} return false; } void showMessage(String text) { flashMsg = text; flashMsgTimer = 240; } void setDefaultProps(Particle p) { switch(p.type) { case 1: p.props[4]=938; p.props[5]=1; p.props[6]=1; break; case 2: p.props[4]=939; p.props[5]=0; p.props[6]=1; break; case 3: p.props[4]=1; p.props[5]=-1; p.props[6]=1; break; case 4: p.props[4]=0; p.props[5]=0; p.props[6]=2; break; case 5: p.props[4]=1; p.props[5]=1; p.props[6]=1; break; case 6: p.props[4]=0; p.props[5]=0; p.props[6]=1; break; case 7: p.props[4]=0; p.props[5]=0; p.props[6]=0; break; case 8: p.props[4]=0; p.props[5]=0; p.props[6]=0; break; } } void drawTopBar() { fill(255); noStroke(); rect(0, 0, 1200, 30); if (saveFlashTimer > 0) { fill(100, 255, 100); saveFlashTimer--; } else if (!frameExistsLocally(iv)) fill(255, 255, 100); else fill(245); stroke(150); rect(5, 3, 50, 24, 4); fill(autoZipMode ? color(100, 255, 100) : color(240)); stroke(150); rect(60, 3, 75, 24, 4); fill(240); stroke(150); rect(140, 3, 85, 24, 4); fill(240); stroke(150); rect(230, 3, 55, 24, 4); fill(isPlaying ? color(100, 255, 100) : color(240)); stroke(150); rect(290, 3, 75, 24, 4); fill(urknallMode ? color(100, 255, 100) : color(240)); stroke(150); rect(370, 3, 65, 24, 4); fill(expertMode ? color(150, 150, 255) : color(240)); stroke(150); rect(440, 3, 85, 24, 4); fill(edgeWrapMode ? color(100, 255, 200) : color(240)); stroke(150); rect(530, 3, 80, 24, 4); fill(240); stroke(150); rect(615, 3, 70, 24, 4); fill(240); stroke(150); rect(690, 3, 70, 24, 4); fill(240); stroke(150); rect(765, 3, 70, 24, 4); fill(showHelperGrid ? color(200, 230, 255) : color(240)); stroke(150); rect(840, 3, 90, 24, 4); fill(color(0, 255, 200)); stroke(150); rect(940, 3, 100, 24, 4); fill(240); stroke(150); rect(1060, 3, 130, 24, 4); // EXAKTE PIXEL-POSITIONIERUNG (Ohne fehleranfälliges CENTER, CENTER) fill(0); textSize(13); textAlign(LEFT, CENTER); text("Datei", 13, 15); text("AutoZip", 72, 15); text("Frame: " + iv, 148, 15); text("Clear", 242, 15); text(isPlaying ? "Sim: ON" : "Sim: OFF", 298, 15); text("Urknall", 378, 15); text(expertMode ? "Mode: EXPT" : "Mode: NORM", 445, 15); text(edgeWrapMode ? "Wrap: ON" : "Wrap: OFF", 538, 15); text("Size: " + num, 622, 15); text("Run: " + ordner, 698, 15); text("Level: " + level, 772, 15); text(showHelperGrid ? "Gitter: AN" : "Gitter: AUS", 848, 15); fill(color(0, 100, 50)); text("DOOM 3D", 962, 15); fill(0); text("Design: " + themeNames[currentTheme], 1070, 15); } void drawEditorMode() { if (urknallMode || isPlaying) { playTimer++; if (playTimer > 5) { playTimer = 0; int calcStart = millis(); updateAtomSimulation(false); int calcDuration = millis() - calcStart; if (calcDuration >= 5000) { isPlaying = false; urknallMode = false; showMessage("NOTAUS! Berechnung dauerte > 5 Sekunden.\nFrame " + iv + " eingefroren."); } else { if (urknallMode) { saveFrameData(); iv++; } } } } drawTopBar(); drawPropertyControls(); if (dom == 1) { dom = 0; drawBlankGrid(); } draw3DBlockArea(); if (!urknallMode && !isPlaying) { if (mouseX >= 0 && mouseX < 600 && mouseY >= 30 && mouseY < 630) { int cellX = floor(mouseX / feld); int cellY = floor((mouseY - 30) / feld); if (mousePressed && mouseButton == LEFT) { hasInspected = false; if (cellX <= num && cellY <= num) { for (int i = particles.size() - 1; i >= 0; i--) { Particle p = particles.get(i); if (p.x == cellX && p.y == cellY && p.z == level) particles.remove(i); } if (currentParticle != 0) { Particle p = new Particle(); p.type = currentParticle; p.id = typeCounters[currentParticle]++; p.x = cellX; p.y = cellY; p.z = level; color pCol = colorThemes[0][currentParticle]; p.props[0] = (int)red(pCol); p.props[1] = (int)green(pCol); p.props[2] = (int)blue(pCol); p.props[3] = p.type; for (int i=4; i<16; i++) p.props[i] = 0; setDefaultProps(p); particles.add(p); } updateGridFromParticles(); } fill(colorThemes[currentTheme][currentParticle]); stroke(200); rect(cellX * feld, 30 + cellY * feld, feld, feld); } if (mousePressed && mouseButton == RIGHT) { if (cellX <= num && cellY <= num) { int pType = gridData[cellX][cellY][level][3]; if (pType != 0) { currentParticle = pType; for(int i=0; i<16; i++) inspectedProps[i] = gridData[cellX][cellY][level][i]; hasInspected = true; } else { hasInspected = false; } } } } } if (flashMsgTimer > 0) { fill(0, 200); stroke(255); strokeWeight(2); rect(350, 350, 500, 100, 10); fill(255); textSize(18); textAlign(CENTER, CENTER); text(flashMsg, 600, 400); strokeWeight(1); flashMsgTimer--; } } void updateAtomSimulation(boolean silent) { if (urknallMode) { if (num < 100) { num++; num1 = num; feld = 600.0f / (num + 1); ArrayList newP = new ArrayList(); for(Particle p : particles) { if(random(1) > 0.3f) { int nx = p.x + (int)random(3) - 1; int ny = p.y + (int)random(3) - 1; int nz = p.z + (int)random(3) - 1; if (edgeWrapMode) { nx = (nx + num + 1) % (num + 1); ny = (ny + num + 1) % (num + 1); nz = (nz + num + 1) % (num + 1); } else { nx = constrain(nx, 0, num); ny = constrain(ny, 0, num); nz = constrain(nz, 0, num); } if (gridData[nx][ny][nz][3] == 0) { Particle np = new Particle(); np.type = (int)random(1, 7); np.id = typeCounters[np.type]++; np.x = nx; np.y = ny; np.z = nz; color nCol = colorThemes[0][np.type]; np.props[0] = (int)red(nCol); np.props[1] = (int)green(nCol); np.props[2] = (int)blue(nCol); np.props[3] = np.type; for(int i=4; i<16; i++) np.props[i] = p.props[i]; setDefaultProps(np); np.props[15] = 255; newP.add(np); gridData[nx][ny][nz][3] = np.type; } } } particles.addAll(newP); } else { urknallMode = false; showMessage("Maximales Array-Limit erreicht.\nUrknall gestoppt."); } } ArrayList spawns = new ArrayList(); for (Particle p : particles) { if (p.props[15] > 0) p.props[15] = max(0, p.props[15] - 15); int moveX = 0, moveY = 0, moveZ = 0; if (p.type == 7 || p.type == 8) continue; if (p.type == 2 && random(1) < 0.005f) { p.type = 1; p.props[3] = 1; p.props[15] = 255; setDefaultProps(p); gridData[p.x][p.y][p.z][3] = 1; spawnParticleNear(3, p.x, p.y, p.z, spawns); spawnParticleNear(6, p.x, p.y, p.z, spawns); continue; } for (int dx = -2; dx <= 2; dx++) { for (int dy = -2; dy <= 2; dy++) { for (int dz = -2; dz <= 2; dz++) { if (dx == 0 && dy == 0 && dz == 0) continue; int checkX = p.x + dx; int checkY = p.y + dy; int checkZ = p.z + dz; if (edgeWrapMode) { checkX = (checkX + num + 1) % (num + 1); checkY = (checkY + num + 1) % (num + 1); checkZ = (checkZ + num + 1) % (num + 1); } else { if (checkX < 0 || checkX > num || checkY < 0 || checkY > num || checkZ < 0 || checkZ > num) continue; } int neighborType = gridData[checkX][checkY][checkZ][3]; if (neighborType == 0) continue; int distSq = dx*dx + dy*dy + dz*dz; if ((p.type == 1 || p.type == 2) && (neighborType == 1 || neighborType == 2)) { if (distSq <= 3) { moveX += sign(dx); moveY += sign(dy); moveZ += sign(dz); if (random(1) < 0.05f) p.props[15] = 255; } else if (p.type == 1 && neighborType == 1 && distSq > 3) { moveX -= sign(dx); moveY -= sign(dy); moveZ -= sign(dz); } } if (p.type == 3) { if (neighborType == 1) { if (distSq <= 2) { moveX -= sign(dx); moveY -= sign(dy); moveZ -= sign(dz); } else { moveX += sign(dx); moveY += sign(dy); moveZ += sign(dz); } } else if (neighborType == 3) { moveX -= sign(dx); moveY -= sign(dy); moveZ -= sign(dz); } } } } } int finalDx = 0, finalDy = 0, finalDz = 0; if (moveX != 0) finalDx = sign(moveX); else if (random(1) < 0.2f) finalDx = (int)random(3) - 1; if (moveY != 0) finalDy = sign(moveY); else if (random(1) < 0.2f) finalDy = (int)random(3) - 1; if (moveZ != 0) finalDz = sign(moveZ); else if (random(1) < 0.2f) finalDz = (int)random(3) - 1; int nx = p.x + finalDx; int ny = p.y + finalDy; int nz = p.z + finalDz; if (edgeWrapMode) { nx = (nx + num + 1) % (num + 1); ny = (ny + num + 1) % (num + 1); nz = (nz + num + 1) % (num + 1); } else { nx = constrain(nx, 0, num); ny = constrain(ny, 0, num); nz = constrain(nz, 0, num); } if (gridData[nx][ny][nz][3] == 0) { gridData[p.x][p.y][p.z][3] = 0; p.x = nx; p.y = ny; p.z = nz; gridData[nx][ny][nz][3] = p.type; } } particles.addAll(spawns); if (!silent) { updateGridFromParticles(); loadLevelToScreen(); } } void spawnParticleNear(int type, int x, int y, int z, ArrayList spawns) { for (int dx=-1; dx<=1; dx++) { for (int dy=-1; dy<=1; dy++) { for (int dz=-1; dz<=1; dz++) { int nx = x + dx; int ny = y + dy; int nz = z + dz; if (edgeWrapMode) { nx = (nx + num + 1) % (num + 1); ny = (ny + num + 1) % (num + 1); nz = (nz + num + 1) % (num + 1); } else { nx = constrain(nx, 0, num); ny = constrain(ny, 0, num); nz = constrain(nz, 0, num); } if (gridData[nx][ny][nz][3] == 0) { Particle np = new Particle(); np.type = type; np.id = typeCounters[type]++; np.x = nx; np.y = ny; np.z = nz; color nCol = colorThemes[0][type]; np.props[0] = (int)red(nCol); np.props[1] = (int)green(nCol); np.props[2] = (int)blue(nCol); np.props[3] = type; setDefaultProps(np); np.props[15] = 255; gridData[nx][ny][nz][3] = type; spawns.add(np); return; } } } } } color getParticleColor2D(int x, int y, int z) { int pType = gridData[x][y][z][3]; color baseC = colorThemes[currentTheme][pType]; int blinkTimer = gridData[x][y][z][15]; if (blinkTimer > 0) { float amt = (sin(blinkTimer * 0.2f) * 0.5f + 0.5f) * (blinkTimer / 255.0f); return lerpColor(baseC, color(255), amt); } return baseC; } void loadLevelToScreen() { fill(255); noStroke(); rect(0, 30, 600, 600); feld = 600.0f / (num + 1); stroke(220); strokeWeight(1); for (int i = 0; i <= num + 1; i++) { line(i * feld, 30, i * feld, 30 + 600); line(0, 30 + i * feld, 600, 30 + i * feld); } stroke(150, 100); strokeWeight(2); for (Particle p : particles) { if (p.z == level) { for(int dx=0; dx<=1; dx++) { for(int dy=0; dy<=1; dy++) { if(dx==0 && dy==0) continue; int nx = p.x + dx; int ny = p.y + dy; if(edgeWrapMode) { nx = (nx+num+1)%(num+1); ny = (ny+num+1)%(num+1); } if(nx>=0 && nx<=num && ny>=0 && ny<=num) { if(gridData[nx][ny][level][3] != 0 && abs(p.x - nx) <= 1 && abs(p.y - ny) <= 1) { line(p.x * feld + feld/2, 30 + p.y * feld + feld/2, nx * feld + feld/2, 30 + ny * feld + feld/2); } } } } } } strokeWeight(1); for (int y = 0; y <= num; y++) { for (int x = 0; x <= num; x++) { int pType = gridData[x][y][level][3]; if (pType != 0) { fill(getParticleColor2D(x, y, level)); stroke(150); rect(x * feld, 30 + y * feld, feld, feld); } } } } void drawBlankGrid() { fill(255); noStroke(); rect(0, 30, 600, 600); feld = 600.0f / (num + 1); stroke(220); strokeWeight(1); for (int i = 0; i <= num + 1; i++) { line(i * feld, 30, i * feld, 30 + 600); line(0, 30 + i * feld, 600, 30 + i * feld); } } void drawIsoCube(float sx, float sy, float S, color c) { fill(c); stroke(40, 60); beginShape(); vertex(sx, sy); vertex(sx + S, sy + S * 0.5f); vertex(sx, sy + S); vertex(sx - S, sy + S * 0.5f); endShape(CLOSE); fill(red(c) * 0.75f, green(c) * 0.75f, blue(c) * 0.75f); stroke(40, 60); beginShape(); vertex(sx - S, sy + S * 0.5f); vertex(sx, sy + S); vertex(sx, sy + S + S); vertex(sx - S, sy + S * 0.5f + S); endShape(CLOSE); fill(red(c) * 0.55f, green(c) * 0.55f, blue(c) * 0.55f); stroke(40, 60); beginShape(); vertex(sx, sy + S); vertex(sx + S, sy + S * 0.5f); vertex(sx + S, sy + S * 0.5f + S); vertex(sx, sy + S + S); endShape(CLOSE); } void draw3DBlockArea() { fill(245); stroke(180); rect(630, 30, 560, 600); fill(0); textSize(14); textAlign(LEFT, CENTER); text("3D Atom-Ansicht (Clean Voxel Mode)", 645, 48); float S = 265.0f / (num + 1); float originX = 910; float originY = 345; if (showHelperGrid) { stroke(180, 120); noFill(); for (int y = 0; y <= num; y++) { float x1 = originX + (0 - y) * S; float y1 = originY + (0 + y) * (S * 0.5f); float x2 = originX + (num - y) * S; float y2 = originY + (num + y) * (S * 0.5f); line(x1, y1, x2, y2); } for (int x = 0; x <= num; x++) { float x1 = originX + (x - 0) * S; float y1 = originY + (x + 0) * (S * 0.5f); float x2 = originX + (x - num) * S; float y2 = originY + (x + num) * (S * 0.5f); line(x1, y1, x2, y2); } } for (int l = 0; l <= num; l++) { for (int y = 0; y <= num; y++) { for (int x = 0; x <= num; x++) { int pType = gridData[x][y][l][3]; if (pType != 0) { color c = colorThemes[currentTheme][pType]; if (showHelperGrid && l != level) c = color(red(c), green(c), blue(c), 100); float sx = originX + (x - y) * S; float sy = originY + (x + y) * (S * 0.5f) - (l * S * 1.0f); drawIsoCube(sx, sy, S, c); } } } } } void drawPropertyControls() { noStroke(); fill(240); stroke(180); rect(5, 675, 400, 150, 6); if (!hasInspected) { fill(100); textSize(14); textAlign(LEFT, TOP); text("INSPEKTOR\n\nKlicke mit der RECHTEN Maustaste auf\nein Partikel im 2D-Gitter,\num seine Werte zu analysieren.", 20, 700); } else { fill(0); textSize(14); textAlign(LEFT, TOP); text("INSPEKTOR (LMT Klick ins Gitter zum Beenden)", 15, 685); text("Typ: " + particleNames[inspectedProps[3]].toUpperCase(), 15, 710); text("Energie: " + (inspectedProps[4] * 1.0f) + " MeV", 15, 730); text("Ladung: " + (inspectedProps[5] * 1.0f) + " e", 15, 750); text("Spin: " + (inspectedProps[6] * 0.5f) + " ħ", 15, 770); text("Zusatz: " + (inspectedProps[7] * 0.01f), 15, 790); if (expertMode) { text("Vel X: " + (inspectedProps[8] * 10.0f) + " m/s", 200, 710); text("Vel Y: " + (inspectedProps[9] * 10.0f) + " m/s", 200, 730); text("Vel Z: " + (inspectedProps[10] * 10.0f) + " m/s", 200, 750); text("Starke K.: " + (inspectedProps[11] * 2.5f) + " N", 200, 770); text("Schwache: " + (inspectedProps[12] * 0.1f) + " %", 200, 790); } } fill(colorThemes[currentTheme][currentParticle]); stroke(0); rect(0, 830, 405, 15); fill(currentParticle == 0 ? 0 : 255); textAlign(LEFT, CENTER); text("AKTIVES PARTIKEL: " + particleNames[currentParticle].toUpperCase(), 15, 837); fill(240); stroke(180); rect(410, 680, 520, 140, 6); fill(0); textSize(14); textAlign(LEFT, CENTER); text("Partikel-Palette (Klick zum Auswählen):", 425, 700); for (int i = 0; i < 9; i++) { float hx = 425 + (i * 55); float hy = 715; fill(colorThemes[currentTheme][i]); stroke(0); rect(hx, hy, 45, 45, 4); // EXAKTE TEXT-POSITION (Sicheres Rendering für PJS) fill(0); textSize(11); textAlign(CENTER, TOP); text(particleNames[i], hx + 22.5f, hy + 50); if (currentParticle == i) { noFill(); stroke(0, 255, 0); strokeWeight(3); rect(hx - 2, hy - 2, 49, 49, 6); strokeWeight(1); } } textAlign(LEFT, CENTER); // Reset } // ================================================================= // OFFLINE EXPORT ENGINE (ZIP & TXT) // ================================================================= void saveFrameData() { String baseDir = "sim" + ordner + "/"; String frameStr = nf(iv, 4); int saveLen = expertMode ? 16 : 8; ArrayList cloneList = new ArrayList(); for(Particle p : particles) { Particle cp = new Particle(); cp.id = p.id; cp.type = p.type; cp.x = p.x; cp.y = p.y; cp.z = p.z; for(int i=0; i<16; i++) cp.props[i] = p.props[i]; cloneList.add(cp); } memoryFrames.put(iv, cloneList); memoryNum.put(iv, num); try { ensureDir(baseDir); if (autoZipMode) { String zipFileName = sketchPath(baseDir + "frame_" + frameStr + ".zip"); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFileName)); if (particles.isEmpty()) { for (int l = 0; l <= num; l++) { zos.putNextEntry(new ZipEntry("nix0/" + l + "nix" + frameStr + ".txt")); PrintWriter out = new PrintWriter(new OutputStreamWriter(zos, "UTF-8")); for (int x = 0; x <= num; x++) { for (int y = 0; y <= num; y++) { String emptyLine = "255 255 255 0"; for(int i=4; i entries = zf.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (!entry.isDirectory() && entry.getName().endsWith(".txt")) { String eName = entry.getName(); int slashIdx = eName.indexOf("/"); if (slashIdx != -1) { String folderName = eName.substring(0, slashIdx); int pType = -1; String pNameStr = ""; for (int i=0; i<9; i++) { if (folderName.startsWith(particleNames[i])) { pType = i; pNameStr = particleNames[i]; break; } } if (pType != -1 && pType != 0) { int pId = 0; try { pId = Integer.parseInt(folderName.substring(pNameStr.length())); } catch(Exception e){} String fileName = eName.substring(slashIdx + 1); int zLevel = Integer.parseInt(fileName.substring(0, fileName.indexOf(pNameStr))); BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(entry), "UTF-8")); String line; int lx = 0, ly = 0; boolean foundInThisFile = false; while ((line = br.readLine()) != null && !line.equals("eof")) { if (line.equals("eol")) { lx++; ly = 0; } else { String[] parts = splitTokens(line, " "); if (parts.length >= 4) { int parsedType = int(parts[3]); if (parsedType != 0) { Particle p = new Particle(); p.type = parsedType; p.id = pId; p.x = lx; p.y = ly; p.z = zLevel; for(int j=0; j num || y < 0 || y > num) return -1; return gridData[x][y][level][3]; } void drawDoomMode() { background(0); handleDoomKinematics(); updateDoomProjectiles(); renderRaycast3D(); renderDoomProjectiles3D(); renderDoomHUD2D(); // DTIM MAGIE: Flash-Renderer für Instantane Array-Verschiebungen (Teleportation) if (doomFlash > 0) { fill(red(doomFlashColor), green(doomFlashColor), blue(doomFlashColor), doomFlash); rect(400, 0, 800, height); doomFlash -= 15; } } void handleDoomKinematics() { if (keyW) { if (getDoomMapCell((int)(posX + dirX * moveSpeed), (int)posY) == 0) posX += dirX * moveSpeed; if (getDoomMapCell((int)posX, (int)(posY + dirY * moveSpeed)) == 0) posY += dirY * moveSpeed; } if (keyS) { if (getDoomMapCell((int)(posX - dirX * moveSpeed), (int)posY) == 0) posX -= dirX * moveSpeed; if (getDoomMapCell((int)posX, (int)(posY - dirY * moveSpeed)) == 0) posY -= dirY * moveSpeed; } if (keyA) { float sX = dirY; float sY = -dirX; if (getDoomMapCell((int)(posX + sX * moveSpeed), (int)posY) == 0) posX += sX * moveSpeed; if (getDoomMapCell((int)posX, (int)(posY + sY * moveSpeed)) == 0) posY += sY * moveSpeed; } if (keyD) { float sX = -dirY; float sY = dirX; if (getDoomMapCell((int)(posX + sX * moveSpeed), (int)posY) == 0) posX += sX * moveSpeed; if (getDoomMapCell((int)posX, (int)(posY + sY * moveSpeed)) == 0) posY += sY * moveSpeed; } } void renderRaycast3D() { int viewW = 800; int viewH = height; int startX = 400; noStroke(); fill(10, 15, 25); rect(startX, 0, viewW, viewH / 2); fill(20, 30, 40); rect(startX, viewH / 2, viewW, viewH / 2); for (int x = 0; x < viewW; x++) { float cameraX = 2 * x / float(viewW) - 1; float rayDirX = dirX + planeX * cameraX; float rayDirY = dirY + planeY * cameraX; int mapX = (int)posX; int mapY = (int)posY; float deltaDistX = (rayDirX == 0) ? 9999999.0f : abs(1.0f / rayDirX); float deltaDistY = (rayDirY == 0) ? 9999999.0f : abs(1.0f / rayDirY); float perpWallDist; int stepX, stepY; float sideDistX, sideDistY; if (rayDirX < 0) { stepX = -1; sideDistX = (posX - mapX) * deltaDistX; } else { stepX = 1; sideDistX = (mapX + 1.0f - posX) * deltaDistX; } if (rayDirY < 0) { stepY = -1; sideDistY = (posY - mapY) * deltaDistY; } else { stepY = 1; sideDistY = (mapY + 1.0f - posY) * deltaDistY; } int hit = 0; int side = 0; int hitType = 0; while (hit == 0) { if (sideDistX < sideDistY) { sideDistX += deltaDistX; mapX += stepX; side = 0; } else { sideDistY += deltaDistY; mapY += stepY; side = 1; } hitType = getDoomMapCell(mapX, mapY); if (hitType != 0) hit = 1; } if (side == 0) perpWallDist = (mapX - posX + (1 - stepX) / 2.0f) / rayDirX; else perpWallDist = (mapY - posY + (1 - stepY) / 2.0f) / rayDirY; zBuffer[x] = perpWallDist; int lineHeight = (int)(viewH / perpWallDist); int drawStart = max(0, -lineHeight / 2 + viewH / 2); int drawEnd = min(viewH - 1, lineHeight / 2 + viewH / 2); color wallColor = (hitType == -1) ? color(100) : colorThemes[currentTheme][hitType]; if (side == 1) wallColor = color(red(wallColor)*0.7f, green(wallColor)*0.7f, blue(wallColor)*0.7f); stroke(wallColor); line(startX + x, drawStart, startX + x, drawEnd); if (x % 20 == 0 || drawStart % 20 == 0) { stroke(255, 50); line(startX + x, drawStart, startX + x, drawEnd); } } } void fireDoomParticle() { if (currentParticle == 0) return; if (currentParticle == 7 || currentParticle == 8) { float rayDirX = dirX; float rayDirY = dirY; int mapX = (int)posX; int mapY = (int)posY; float deltaDistX = (rayDirX == 0) ? 9999999.0f : abs(1.0f / rayDirX); float deltaDistY = (rayDirY == 0) ? 9999999.0f : abs(1.0f / rayDirY); int stepX, stepY; float sideDistX, sideDistY; if (rayDirX < 0) { stepX = -1; sideDistX = (posX - mapX) * deltaDistX; } else { stepX = 1; sideDistX = (mapX + 1.0f - posX) * deltaDistX; } if (rayDirY < 0) { stepY = -1; sideDistY = (posY - mapY) * deltaDistY; } else { stepY = 1; sideDistY = (mapY + 1.0f - posY) * deltaDistY; } int hit = 0; int hitType = 0; int side = 0; while (hit == 0) { if (sideDistX < sideDistY) { sideDistX += deltaDistX; mapX += stepX; side = 0; } else { sideDistY += deltaDistY; mapY += stepY; side = 1; } hitType = getDoomMapCell(mapX, mapY); if (hitType != 0) hit = 1; } if (currentParticle == 7) { int buildX = mapX; int buildY = mapY; if (side == 0) buildX -= stepX; else buildY -= stepY; if (buildX >= 0 && buildX <= num && buildY >= 0 && buildY <= num) { if (!(buildX == (int)posX && buildY == (int)posY)) { if (gridData[buildX][buildY][level][3] == 0) { Particle p = new Particle(); p.type = 7; p.id = typeCounters[7]++; p.x = buildX; p.y = buildY; p.z = level; color pCol = colorThemes[0][7]; p.props[0] = (int)red(pCol); p.props[1] = (int)green(pCol); p.props[2] = (int)blue(pCol); p.props[3] = 7; for (int j = 4; j < 16; j++) p.props[j] = 0; setDefaultProps(p); p.props[15] = 255; particles.add(p); for (int j = 0; j < 16; j++) { gridData[buildX][buildY][level][j] = p.props[j]; } } } } doomFlash = 100; doomFlashColor = colorThemes[currentTheme][7]; } else if (currentParticle == 8) { if (hitType == 7) { int targetX = mapX; int targetY = mapY; if (side == 0) targetX -= stepX; else targetY -= stepY; if (getDoomMapCell(targetX, targetY) == 0) { posX = targetX + 0.5f; posY = targetY + 0.5f; doomFlash = 200; doomFlashColor = colorThemes[currentTheme][8]; } } } return; } float spd = doomParticleSpeeds[currentParticle]; doomProjectiles.add(new DoomProjectile(posX, posY, dirX * spd, dirY * spd, currentParticle)); } void updateDoomProjectiles() { for (int i = doomProjectiles.size() - 1; i >= 0; i--) { DoomProjectile q = doomProjectiles.get(i); float nextX = q.x + q.vx; float nextY = q.y + q.vy; if (edgeWrapMode) { if (nextX < 0) nextX += (num + 1); else if (nextX >= num + 1) nextX -= (num + 1); if (nextY < 0) nextY += (num + 1); else if (nextY >= num + 1) nextY -= (num + 1); } int nextCx = (int)nextX; int nextCy = (int)nextY; int hitType = getDoomMapCell(nextCx, nextCy); if (q.life <= 0 || hitType != 0) { if (hitType != 0) { int currCx = (int)q.x; int currCy = (int)q.y; if (currCx >= 0 && currCx <= num && currCy >= 0 && currCy <= num) { if (!(currCx == (int)posX && currCy == (int)posY)) { if (gridData[currCx][currCy][level][3] == 0) { Particle p = new Particle(); p.type = q.type; p.id = typeCounters[q.type]++; p.x = currCx; p.y = currCy; p.z = level; color pCol = colorThemes[0][q.type]; p.props[0] = (int)red(pCol); p.props[1] = (int)green(pCol); p.props[2] = (int)blue(pCol); p.props[3] = p.type; for (int j = 4; j < 16; j++) p.props[j] = 0; setDefaultProps(p); p.props[15] = 255; particles.add(p); for (int j = 0; j < 16; j++) { gridData[currCx][currCy][level][j] = p.props[j]; } } } } } doomProjectiles.remove(i); } else { q.x = nextX; q.y = nextY; q.life--; } } } void renderDoomProjectiles3D() { int viewW = 800; int viewH = height; int startX = 400; for (DoomProjectile q : doomProjectiles) { float spriteX = q.x - posX; float spriteY = q.y - posY; float invDet = 1.0f / (planeX * dirY - dirX * planeY); float transformX = invDet * (dirY * spriteX - dirX * spriteY); float transformY = invDet * (-planeY * spriteX + planeX * spriteY); if (transformY <= 0) continue; int spriteScreenX = (int)((viewW / 2) * (1 + transformX / transformY)); int spriteSize = abs((int)(viewH / transformY)) / 2; int drawStartY = max(0, -spriteSize / 2 + viewH / 2); int drawEndY = min(viewH - 1, spriteSize / 2 + viewH / 2); int drawStartX = max(0, -spriteSize / 2 + spriteScreenX); int drawEndX = min(viewW - 1, spriteSize / 2 + spriteScreenX); for (int stripe = drawStartX; stripe < drawEndX; stripe++) { if (transformY < zBuffer[stripe]) { float nx = map(stripe, drawStartX, drawEndX, -1, 1); for (int y = drawStartY; y < drawEndY; y++) { float ny = map(y, drawStartY, drawEndY, -1, 1); if (nx*nx + ny*ny < 1.0f) { stroke(q.c); point(startX + stripe, y); } } } } } } void renderDoomHUD2D() { fill(5, 10, 15); noStroke(); rect(0, 0, 400, height); stroke(0, 150, 255); strokeWeight(2); line(400, 0, 400, height); fill(0, 255, 255); textSize(18); textAlign(LEFT, TOP); text("DTIM-ZEC QUANTUM TERMINAL", 20, 20); fill(100, 150, 200); textSize(12); text("Subsystem Self-Observation Framework", 20, 45); fill(255, 255, 0); text("Z-EBENE: " + level + " (Wechseln mit Q / E)", 20, 60); stroke(0, 100, 150); line(20, 75, 380, 75); // Minimap float mapX = 20, mapY = 90, mapW = 360, mapH = 360; fill(0, 5, 10); stroke(0, 100, 150); rect(mapX, mapY, mapW, mapH); float tileSize = min(mapW / (num+1), mapH / (num+1)); pushMatrix(); translate(mapX, mapY); noStroke(); for (int x = 0; x <= num; x++) { for (int y = 0; y <= num; y++) { int pType = getDoomMapCell(x, y); if (pType > 0) { fill(colorThemes[currentTheme][pType]); rect(x * tileSize, y * tileSize, tileSize - 1, tileSize - 1); } } } for (DoomProjectile q : doomProjectiles) { fill(q.c); ellipse(q.x * tileSize, q.y * tileSize, tileSize/2, tileSize/2); } fill(255, 255, 0); ellipse(posX * tileSize, posY * tileSize, tileSize/1.5f, tileSize/1.5f); stroke(255, 0, 0); line(posX * tileSize, posY * tileSize, (posX + dirX) * tileSize, (posY + dirY) * tileSize); popMatrix(); // Waffenarsenal fill(0, 255, 255); textSize(14); text("QUANTEN-EMITTER ARSENAL (Tasten 1-8)", 20, 470); for (int i = 1; i < 9; i++) { float yPos = 490 + (i * 28); if (i == currentParticle) { fill(50, 100, 150); noStroke(); rect(20, yPos - 4, 360, 24, 4); } fill(colorThemes[currentTheme][i]); stroke(255); rect(25, yPos, 16, 16); fill(i == currentParticle ? color(255) : color(150, 150, 200)); textSize(13); text("[" + i + "] " + particleNames[i], 55, yPos + 1); } // Großzügige Klick-Fläche für EXIT Button! fill(200, 50, 50); stroke(255); rect(20, 780, 360, 40, 5); fill(255); textSize(16); textAlign(LEFT, CENTER); text("ZURÜCK ZUM EDITOR (Oder ESC drücken)", 50, 800); textAlign(LEFT, TOP); // Reset stroke(0, 255, 0); strokeWeight(2); int cx = 400 + 800/2; int cy = height/2; line(cx - 10, cy, cx + 10, cy); line(cx, cy - 10, cx, cy + 10); noFill(); ellipse(cx, cy, 30, 30); strokeWeight(1); } // ============================================================================================== // GEMEINSAME EINGABE-EVENTS // ============================================================================================== void keyPressed() { if (key == 27 || keyCode == 27) { if (doomMode) exitDoomMode(); key = 0; return; } if (key == 'w' || key == 'W') keyW = true; if (key == 'a' || key == 'A') keyA = true; if (key == 's' || key == 'S') keyS = true; if (key == 'd' || key == 'D') keyD = true; if (doomMode) { if (key >= '1' && key <= '8') currentParticle = key - '0'; if (key == 'e' || key == 'E') level = min(num, level + 1); if (key == 'q' || key == 'Q') level = max(0, level - 1); } } void keyReleased() { if (key == 'w' || key == 'W') keyW = false; if (key == 'a' || key == 'A') keyA = false; if (key == 's' || key == 'S') keyS = false; if (key == 'd' || key == 'D') keyD = false; } void mousePressed() { if (doomMode) { // GROSSZÜGIGE HITBOX FÜR EXIT BUTTON if (mouseX >= 10 && mouseX <= 390 && mouseY >= 770 && mouseY <= 830) { exitDoomMode(); return; } if (mouseX > 400 && mouseButton == LEFT) fireDoomParticle(); } else { if (mouseY >= 0 && mouseY <= 30) { // GROSSZÜGIGE HITBOX FÜR DOOM 3D if (mouseX >= 930 && mouseX <= 1050) { isPlaying = false; urknallMode = false; enterDoomMode(); return; } if (mouseX >= 60 && mouseX <= 135) { autoZipMode = !autoZipMode; return; } if (mouseX >= 140 && mouseX <= 225 && !isPlaying && !urknallMode) { if (mouseButton == LEFT) iv = max(1, iv - 1); if (mouseButton == RIGHT) iv++; if (frameExistsLocally(iv)) loadFrameData(iv); else { particles.clear(); wipeEntireGrid(); drawBlankGrid(); } return; } if (mouseX >= 230 && mouseX <= 285 && !isPlaying && !urknallMode) { particles.clear(); memoryFrames.clear(); memoryNum.clear(); wipeEntireGrid(); updateGridFromParticles(); drawBlankGrid(); return; } if (mouseX >= 290 && mouseX <= 365) { isPlaying = !isPlaying; return; } if (mouseX >= 370 && mouseX <= 435) { urknallMode = !urknallMode; if (urknallMode) { if (particles.isEmpty()) { num = 2; num1 = num; iv = 1; feld = 600.0f / (num + 1); for(int i=0; i<9; i++) typeCounters[i]=0; Particle p = new Particle(); p.type = 7; p.id = typeCounters[7]++; p.x = 1; p.y = 1; p.z = 1; setDefaultProps(p); particles.add(p); wipeEntireGrid(); updateGridFromParticles(); loadLevelToScreen(); } isPlaying = true; hasInspected = false; } return; } if (mouseX >= 440 && mouseX <= 525) { expertMode = !expertMode; return; } if (mouseX >= 530 && mouseX <= 610) { edgeWrapMode = !edgeWrapMode; return; } if (mouseX >= 615 && mouseX <= 685 && !isPlaying && !urknallMode) { if (mouseButton == LEFT) num = min(100, num + 1); if (mouseButton == RIGHT) { wipeEntireGrid(); num = max(2, num - 1); } num1 = num; feld = 600.0f / (num + 1); for (int i = particles.size() - 1; i >= 0; i--) { Particle p = particles.get(i); if (p.x > num || p.y > num || p.z > num) particles.remove(i); } updateGridFromParticles(); loadLevelToScreen(); return; } if (mouseX >= 690 && mouseX <= 760 && !isPlaying && !urknallMode) { if (mouseButton == LEFT) ordner++; if (mouseButton == RIGHT) ordner = max(0, ordner - 1); particles.clear(); memoryFrames.clear(); memoryNum.clear(); iv = 1; wipeEntireGrid(); drawBlankGrid(); return; } if (mouseX >= 765 && mouseX <= 835 && !isPlaying && !urknallMode) { if (mouseButton == LEFT) level = min(num, level + 1); if (mouseButton == RIGHT) level = max(0, level - 1); loadLevelToScreen(); return; } if (mouseX >= 840 && mouseX <= 930) { showHelperGrid = !showHelperGrid; return; } if (mouseX >= 1060 && mouseX <= 1190) { currentTheme = (currentTheme + 1) % 3; loadLevelToScreen(); return; } if (mouseX >= 5 && mouseX <= 55 && !isPlaying && !urknallMode) { if (mouseButton == RIGHT) { saveFrameData(); saveFlashTimer = 20; iv++; } else if (mouseButton == LEFT) { iv = lastSavedFrame; loadFrameData(iv); } } } // Palette im Editor Modus: 425 + 495 = 920 Breite (9 Buttons a 55px) if (mouseY >= 715 && mouseY <= 780 && mouseX >= 425 && mouseX <= 425 + (9 * 55)) { int clickedIdx = floor((mouseX - 425) / 55.0f); if (clickedIdx >= 0 && clickedIdx < 9) { currentParticle = clickedIdx; hasInspected = false; return; } } } } void mouseDragged() { if (doomMode && mouseX > 400) { float deltaX = mouseX - pmouseX; float rot = -deltaX * rotSpeed * 0.5f; float oldDirX = dirX; dirX = dirX * cos(rot) - dirY * sin(rot); dirY = oldDirX * sin(rot) + dirY * cos(rot); float oldPlaneX = planeX; planeX = planeX * cos(rot) - planeY * sin(rot); planeY = oldPlaneX * sin(rot) + planeY * cos(rot); } }