DOOM
North Mini Code 1.0 GGUF · typescript

Reviews & generation details
Reviews
No human review yet. Unreviewed does not mean unsuccessful.
Generation context
Imported historical artifact. Its exact original instructions and lineage are not known.
Generation prompt · exact text unavailable
See the current prompt for reference. It may differ from the instructions used to generate this artifact.
Inspect original source 23,890 bytes · SHA-256 f11a3ef67ed1
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Doom</title>
<style>
</style>
</head>
<body>
<div id="app"></div>
<canvas id="gameCanvas" width="800" height="600"></canvas>
<div id="hud">
<div id="health">Health: <span id="healthVal">100</span></div>
<div id="ammo">Ammo: <span id="ammoVal">30</span></div>
<div id="weapon">Weapon: <span id="weaponName">Pistol</span></div>
<div id="message"></div>
</div>
<script>
(function () {
'use strict';
var __mods = {};
var __cache = {};
var __map = {"src/main.ts":{"./engine":"src/engine.ts"},"src/player.ts":{"./game_state":"src/game_state.ts","./input":"src/input.ts"},"src/enemy.ts":{"./game_state":"src/game_state.ts","./player":"src/player.ts"},"src/engine.ts":{"./game_state":"src/game_state.ts","./player":"src/player.ts","./enemy":"src/enemy.ts"}};
function __require(id) {
if (__cache[id]) return __cache[id].exports;
var module = __cache[id] = { exports: {} };
var factory = __mods[id];
if (!factory) throw new Error("Module not found: " + id);
factory(module.exports, function (spec) {
var target = (__map[id] && __map[id][spec]) || spec;
return __require(target);
}, module);
return module.exports;
}
// ── module: src/main.ts ──
__mods["src/main.ts"] = function (exports, require, module) {
"use strict";
// Entry point. Runs after the DOM is parsed and after any classic
// <script> imports, so document queries and CDN globals are available.
// Import your other modules from here.
Object.defineProperty(exports, "__esModule", { value: true });
exports.start = start;
const engine_1 = require("./engine");
function start() {
const canvas = document.getElementById('gameCanvas');
if (!canvas) {
console.error('Canvas not found');
return;
}
const engine = new engine_1.GameEngine(canvas);
// Setup restart
window.addEventListener('keydown', (e) => {
if (e.key === 'r' && engine.getState().gameOver) {
// Restart game
location.reload();
}
});
// Game loop
const gameLoop = (currentTime) => {
const delta = currentTime - gameLoop.lastTime;
gameLoop.lastTime = currentTime;
engine.update(delta);
engine.render();
requestAnimationFrame(gameLoop);
};
gameLoop.lastTime = performance.now();
requestAnimationFrame(gameLoop);
}
start();
};
// ── module: src/game_state.ts ──
__mods["src/game_state.ts"] = function (exports, require, module) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
};
// ── module: src/input.ts ──
__mods["src/input.ts"] = function (exports, require, module) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyboardControls = void 0;
exports.createKeyboardControls = createKeyboardControls;
class KeyboardControls {
constructor() {
this.keys = new Map();
this.setupEventListeners();
}
setupEventListeners() {
window.addEventListener("keydown", (e) => {
this.keys.set(e.key.toLowerCase(), true);
});
window.addEventListener("keyup", (e) => {
this.keys.set(e.key.toLowerCase(), false);
});
}
processInput(state) {
state.up = this.keys.get("w") || false;
state.down = this.keys.get("s") || false;
state.left = this.keys.get("a") || false;
state.right = this.keys.get("d") || false;
state.shoot = this.keys.get(" ") || false;
state.sprint = this.keys.get("shift") || false;
}
update(state, delta) {
// Update continuous states based on keys held
// For keyboard, we just keep the current state
}
}
exports.KeyboardControls = KeyboardControls;
function createKeyboardControls() {
return new KeyboardControls();
}
};
// ── module: src/player.ts ──
__mods["src/player.ts"] = function (exports, require, module) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Player = void 0;
class Player {
constructor(startPos, controls) {
this.speed = 200;
this.sprintSpeed = 400;
this.lastShootTime = 0;
this.shootCooldown = 300;
this.controls = controls;
this.input = {
up: false,
down: false,
left: false,
right: false,
shoot: false,
sprint: false
};
this.state = {
position: startPos,
health: 100,
maxHealth: 100,
weapon: "pistol",
ammo: 30,
maxAmmo: 999,
alive: true,
respawnTimer: 0
};
}
update(delta, enemies, projectiles) {
if (!this.state.alive) {
this.state.respawnTimer += delta;
if (this.state.respawnTimer >= 3000) {
this.respawn();
}
return;
}
// Update input from keyboard
this.controls.processInput(this.input);
this.controls.update(this.input, delta);
const speed = this.input.sprint ? this.sprintSpeed : this.speed;
let newX = this.state.position.x;
let newY = this.state.position.y;
if (this.input.up)
newY -= speed * (delta / 1000);
if (this.input.down)
newY += speed * (delta / 1000);
if (this.input.left)
newX -= speed * (delta / 1000);
if (this.input.right)
newX += speed * (delta / 1000);
// Keep player within bounds
newX = Math.max(0, Math.min(800 - 20, newX));
newY = Math.max(0, Math.min(600 - 20, newY));
this.state.position = { x: newX, y: newY };
// Handle shooting
const now = Date.now();
if (this.input.shoot && now - this.lastShootTime >= this.shootCooldown) {
this.shoot();
this.lastShootTime = now;
}
// Update weapon ammo
if (this.state.ammo <= 0) {
this.reload();
}
}
shoot() {
if (this.state.ammo <= 0)
return;
this.state.ammo--;
const angle = 0; // For now, straight forward
const projectile = {
position: {
x: this.state.position.x + 10,
y: this.state.position.y
},
velocity: { x: 5, y: 0 },
damage: this.getWeaponDamage(),
owner: "player"
};
// Return projectile for game state update
window.lastShot = projectile;
}
getWeaponDamage() {
switch (this.state.weapon) {
case "pistol": return 10;
case "shotgun": return 25;
case "rocket": return 50;
default: return 10;
}
}
reload() {
this.state.ammo = this.getWeaponAmmoCapacity();
}
getWeaponAmmoCapacity() {
switch (this.state.weapon) {
case "pistol": return 30;
case "shotgun": return 8;
case "rocket": return 2;
default: return 30;
}
}
respawn() {
this.state.health = this.state.maxHealth;
this.state.position = { x: 400, y: 300 };
this.state.alive = true;
this.state.respawnTimer = 0;
}
getState() {
return { ...this.state };
}
takeDamage(amount) {
if (!this.state.alive)
return;
this.state.health -= amount;
if (this.state.health <= 0) {
this.die();
}
}
die() {
this.state.health = 0;
this.state.alive = false;
this.state.respawnTimer = 0;
// Game over condition
window.gameOver = true;
}
switchWeapon() {
const weapons = ["pistol", "shotgun", "rocket"];
const currentIndex = weapons.indexOf(this.state.weapon);
const nextIndex = (currentIndex + 1) % weapons.length;
this.state.weapon = weapons[nextIndex];
this.reload();
}
addHealth(amount) {
this.state.health = Math.min(this.state.maxHealth, this.state.health + amount);
}
addAmmo(amount) {
this.state.ammo = Math.min(this.state.maxAmmo, this.state.ammo + amount);
}
}
exports.Player = Player;
};
// ── module: src/enemy.ts ──
__mods["src/enemy.ts"] = function (exports, require, module) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PickupSpawner = exports.EnemySpawner = exports.Enemy = void 0;
class Enemy {
constructor(startPos, player) {
this.speed = 150;
this.shootCooldown = 2000;
this.lastShootTime = 0;
this.player = player;
this.state = {
position: startPos,
health: 50,
maxHealth: 50,
velocity: { x: 0, y: 0 },
shootTimer: 0
};
}
update(delta, playerState) {
// Simple AI: move towards player
const playerPos = playerState.position;
const enemyPos = this.state.position;
const dx = playerPos.x - enemyPos.x;
const dy = playerPos.y - enemyPos.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist > 0) {
this.state.velocity.x = (dx / dist) * this.speed;
this.state.velocity.y = (dy / dist) * this.speed;
}
this.state.position.x += this.state.velocity.x * (delta / 1000);
this.state.position.y += this.state.velocity.y * (delta / 1000);
// Keep enemy within bounds
this.state.position.x = Math.max(0, Math.min(800 - 20, this.state.position.x));
this.state.position.y = Math.max(0, Math.min(600 - 20, this.state.position.y));
// Handle shooting
const now = Date.now();
if (now - this.lastShootTime >= this.shootCooldown) {
this.shoot();
this.lastShootTime = now;
}
}
shoot() {
const projectile = {
position: {
x: this.state.position.x,
y: this.state.position.y
},
velocity: { x: 0, y: 5 },
damage: 15,
owner: "enemy"
};
// Return projectile for game state update
window.enemyShot = projectile;
}
getState() {
return { ...this.state };
}
takeDamage(amount) {
this.state.health -= amount;
if (this.state.health <= 0) {
this.die();
}
}
die() {
// Remove enemy - handled by game state
window.enemyDied = true;
}
isAlive() {
return this.state.health > 0;
}
getPosition() {
return { ...this.state.position };
}
}
exports.Enemy = Enemy;
class EnemySpawner {
constructor(player) {
this.spawnTimer = 0;
this.spawnInterval = 3000;
this.player = player;
}
update(delta, enemies) {
this.spawnTimer += delta;
if (this.spawnTimer >= this.spawnInterval) {
this.spawnEnemy(enemies);
this.spawnTimer = 0;
}
}
spawnEnemy(enemies) {
const side = Math.floor(Math.random() * 4);
let x = 0, y = 0;
switch (side) {
case 0: // Top
x = Math.random() * 800;
y = 0;
break;
case 1: // Right
x = 800;
y = Math.random() * 600;
break;
case 2: // Bottom
x = Math.random() * 800;
y = 600;
break;
case 3: // Left
x = 0;
y = Math.random() * 600;
break;
}
enemies.push(new Enemy({ x, y }, this.player));
}
getSpawnInterval() {
return this.spawnInterval;
}
setSpawnInterval(interval) {
this.spawnInterval = interval;
}
}
exports.EnemySpawner = EnemySpawner;
class PickupSpawner {
constructor(player) {
this.spawnTimer = 0;
this.spawnInterval = 5000;
this.player = player;
}
update(delta, pickups) {
this.spawnTimer += delta;
if (this.spawnTimer >= this.spawnInterval) {
this.spawnPickup(pickups);
this.spawnTimer = 0;
}
}
spawnPickup(pickups) {
const side = Math.floor(Math.random() * 4);
let x = 0, y = 0;
switch (side) {
case 0: // Top
x = Math.random() * 800;
y = 0;
break;
case 1: // Right
x = 800;
y = Math.random() * 600;
break;
case 2: // Bottom
x = Math.random() * 800;
y = 600;
break;
case 3: // Left
x = 0;
y = Math.random() * 600;
break;
}
const type = Math.random() < 0.5 ? "health" : "ammo";
const pickup = {
position: { x, y },
type,
active: true
};
pickups.push(pickup);
}
getSpawnInterval() {
return this.spawnInterval;
}
setSpawnInterval(interval) {
this.spawnInterval = interval;
}
}
exports.PickupSpawner = PickupSpawner;
};
// ── module: src/engine.ts ──
__mods["src/engine.ts"] = function (exports, require, module) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GameEngine = void 0;
const player_1 = require("./player");
const enemy_1 = require("./enemy");
class GameEngine {
constructor(canvas) {
this.enemies = [];
this.keys = new Set();
this.canvas = canvas;
this.ctx = canvas.getContext('2d');
// Initialize player with proper controls
this.player = new player_1.Player({ x: 400, y: 300 }, {
processInput(state) {
// Keyboard will be handled by engine
},
update(state, delta) {
// Update based on key states
}
});
this.enemySpawner = new enemy_1.EnemySpawner(this.player);
this.pickupSpawner = new enemy_1.PickupSpawner(this.player);
// Initialize game state
this.state = {
player: this.player.getState(),
enemies: [],
projectiles: [],
pickups: [],
score: 0,
gameOver: false,
wave: 1,
spawnTimer: 0
};
this.lastTime = performance.now();
this.setupInputHandlers();
}
setupInputHandlers() {
window.addEventListener('keydown', (e) => {
this.keys.add(e.key.toLowerCase());
// Switch weapon on number keys
if (e.key >= '1' && e.key <= '3') {
const weaponMap = {
'1': 'pistol',
'2': 'shotgun',
'3': 'rocket'
};
this.player.switchWeapon();
}
});
window.addEventListener('keyup', (e) => {
this.keys.delete(e.key.toLowerCase());
});
// Handle mouse shooting
this.canvas.addEventListener('click', () => {
// Trigger shoot if player has ammo
if (this.state.player.ammo > 0 && this.state.player.alive) {
// Simple shooting logic - will be handled by player update
}
});
}
update(delta) {
if (this.state.gameOver) {
return;
}
// Create input state based on current keys
const inputState = {
up: this.keys.has('w'),
down: this.keys.has('s'),
left: this.keys.has('a'),
right: this.keys.has('d'),
shoot: this.keys.has(' '),
sprint: this.keys.has('shift')
};
// Update player with current key states
this.player.update(delta, this.state.enemies, this.state.projectiles);
// Update enemies
this.enemySpawner.update(delta, this.enemies);
// Update pickups
this.pickupSpawner.update(delta, this.state.pickups);
// Handle projectiles
this.updateProjectiles(delta);
// Handle collisions
this.handleCollisions();
// Update game state
this.state.player = this.player.getState();
this.state.enemies = this.enemies.map(e => e.getState());
// Check win condition
if (this.state.score >= 100 && this.state.enemies.length === 0) {
this.state.gameOver = true;
}
// Handle enemy spawning based on wave
if (this.state.enemies.length === 0 && this.state.wave < 10 && this.state.spawnTimer > 5000) {
this.state.wave++;
this.enemySpawner.setSpawnInterval(Math.max(1000, 3000 - (this.state.wave - 1) * 200));
this.state.spawnTimer = 0;
}
this.state.spawnTimer += delta;
}
updateProjectiles(delta) {
// Handle player projectiles from window.lastShot
if (window.lastShot) {
const projectile = window.lastShot;
this.state.projectiles.push(projectile);
delete window.lastShot;
}
// Handle enemy projectiles from window.enemyShot
if (window.enemyShot) {
const projectile = window.enemyShot;
this.state.projectiles.push(projectile);
delete window.enemyShot;
}
// Update projectile positions
for (let i = this.state.projectiles.length - 1; i >= 0; i--) {
const p = this.state.projectiles[i];
p.position.x += p.velocity.x * (delta / 1000);
p.position.y += p.velocity.y * (delta / 1000);
// Remove projectiles that go off screen
if (p.position.x < 0 || p.position.x > 800 ||
p.position.y < 0 || p.position.y > 600) {
this.state.projectiles.splice(i, 1);
}
}
}
handleCollisions() {
// Player vs Enemy collisions (simple distance check)
for (let i = 0; i < this.state.enemies.length; i++) {
const enemy = this.state.enemies[i];
const dx = enemy.position.x - this.state.player.position.x;
const dy = enemy.position.y - this.state.player.position.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 30) {
// Damage player
this.player.takeDamage(10);
// Knockback enemy
enemy.position.x += (dx / dist) * 20;
enemy.position.y += (dy / dist) * 20;
}
}
// Projectile vs Enemy collisions
for (let pIndex = this.state.projectiles.length - 1; pIndex >= 0; pIndex--) {
const projectile = this.state.projectiles[pIndex];
for (let eIndex = 0; eIndex < this.state.enemies.length; eIndex++) {
const enemy = this.state.enemies[eIndex];
const dx = enemy.position.x - projectile.position.x;
const dy = enemy.position.y - projectile.position.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 15) {
// Enemy takes damage
enemy.health -= projectile.damage;
// Remove projectile
this.state.projectiles.splice(pIndex, 1);
// Check if enemy died
if (enemy.health <= 0) {
this.state.score += 10;
this.state.enemies.splice(eIndex, 1);
break;
}
}
}
}
// Player vs Pickup collisions
for (let pIndex = this.state.pickups.length - 1; pIndex >= 0; pIndex--) {
const pickup = this.state.pickups[pIndex];
if (!pickup.active) {
this.state.pickups.splice(pIndex, 1);
continue;
}
const dx = pickup.position.x - this.state.player.position.x;
const dy = pickup.position.y - this.state.player.position.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 20) {
// Apply pickup effect
if (pickup.type === 'health') {
this.player.addHealth(25);
}
else {
this.player.addAmmo(15);
}
// Remove pickup
this.state.pickups.splice(pIndex, 1);
}
}
}
render() {
// Clear canvas
this.ctx.fillStyle = '#000000';
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
// Draw player
if (this.state.player.alive) {
this.ctx.fillStyle = '#00ff00';
this.ctx.fillRect(this.state.player.position.x, this.state.player.position.y, 20, 20);
}
// Draw enemies
for (const enemy of this.state.enemies) {
this.ctx.fillStyle = '#ff0000';
this.ctx.fillRect(enemy.position.x, enemy.position.y, 20, 20);
}
// Draw projectiles
for (const projectile of this.state.projectiles) {
this.ctx.fillStyle = projectile.owner === 'player' ? '#ffff00' : '#ff8800';
this.ctx.fillRect(projectile.position.x, projectile.position.y, 5, 5);
}
// Draw pickups
for (const pickup of this.state.pickups) {
this.ctx.fillStyle = pickup.type === 'health' ? '#ff0000' : '#0000ff';
this.ctx.fillRect(pickup.position.x, pickup.position.y, 10, 10);
}
// Draw HUD
this.renderHUD();
// Draw game over screen
if (this.state.gameOver) {
this.ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
this.ctx.fillStyle = '#ffffff';
this.ctx.font = '48px Arial';
this.ctx.textAlign = 'center';
this.ctx.fillText('GAME OVER', this.canvas.width / 2, this.canvas.height / 2);
this.ctx.font = '24px Arial';
this.ctx.fillText('Press R to restart', this.canvas.width / 2, this.canvas.height / 2 + 60);
}
}
renderHUD() {
// Update HUD elements
const healthEl = document.getElementById('healthVal');
const ammoEl = document.getElementById('ammoVal');
const weaponEl = document.getElementById('weaponName');
const messageEl = document.getElementById('message');
if (healthEl)
healthEl.textContent = this.state.player.health.toString();
if (ammoEl)
ammoEl.textContent = this.state.player.ammo.toString();
if (weaponEl)
weaponEl.textContent = this.state.player.weapon;
// Update message
if (messageEl) {
if (this.state.wave < 10) {
messageEl.textContent = `Wave ${this.state.wave}/10 | Score: ${this.state.score}`;
}
else {
messageEl.textContent = `FINAL BOSS! | Score: ${this.state.score}`;
}
}
}
getState() {
return { ...this.state };
}
getPlayer() {
return this.player;
}
getCanvas() {
return this.canvas;
}
}
exports.GameEngine = GameEngine;
};
// ── entry ──
__require("src/main.ts");
})();
</script>
</body>
</html>
<!-- agent-meta {"model":"unsloth/North-Mini-Code-1.0-GGUF","provider":"brigid","persona":"typescript","sessionId":"48646a0e-4a09-43f6-8792-1c95f46b40df","tokensIn":1446641,"tokensOut":28577,"tokensTotal":1475218,"cost":0,"turns":66,"toolCalls":65,"failedToolCalls":23,"timestamp":"2026-08-07T23:19:15.402Z"} -->