mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-29 19:18:34 +01:00
Start implementing torches and light and add some new tiles
This commit is contained in:
@@ -141,7 +141,9 @@ var GameState = {
|
||||
for (let y_scan = 0; y_scan < screenHeight; y_scan++) {
|
||||
if (this._map[y_scan]) {
|
||||
for (let x_scan = 0; x_scan < screenWidth; x_scan++) {
|
||||
if (this._map[y_scan][x_scan] === 0) { // Find first floor tile
|
||||
const tile = this._map[y_scan][x_scan];
|
||||
// Check for both legacy (0) and new ("'1", "'2") floor tiles
|
||||
if (tile === 0 || tile === "'1" || tile === "'2") {
|
||||
this._player.x = x_scan;
|
||||
this._player.y = y_scan;
|
||||
console.warn(`Player moved to fallback position: (${this._player.x}, ${this._player.y})`);
|
||||
@@ -167,8 +169,9 @@ var GameState = {
|
||||
if (!this._map[y] || this._map[y][x] === undefined) {
|
||||
return false; // Unknown tiles block light
|
||||
}
|
||||
// Tile type 0 = floor (transparent), 1 = wall (blocks light)
|
||||
return this._map[y][x] === 0;
|
||||
const tile = this._map[y][x];
|
||||
// Check for both legacy (0) and new ("'1", "'2") floor tiles
|
||||
return tile === 0 || tile === "'1" || tile === "'2";
|
||||
}.bind(this));
|
||||
|
||||
// If map was NOT built from initialVisibleTiles, compute FOV now
|
||||
@@ -355,7 +358,9 @@ var GameState = {
|
||||
this._visibleTiles = {};
|
||||
|
||||
const fov = new ROT.FOV.PreciseShadowcasting(function(x, y) {
|
||||
return this._map[y] && this._map[y][x] === 0; // 0 = passable, 1 = wall
|
||||
const tile = this._map[y] && this._map[y][x];
|
||||
// Check for both legacy (0) and new ("'1", "'2") floor tiles
|
||||
return tile === 0 || tile === "'1" || tile === "'2";
|
||||
}.bind(this));
|
||||
|
||||
fov.compute(this._player.x, this._player.y, 6, function(x, y, r, visibility) {
|
||||
|
||||
+59
-4
@@ -20,16 +20,39 @@ var options = {
|
||||
tileWidth: 32, // Width of a single tile in pixels
|
||||
tileHeight: 32, // Height of a single tile in pixels
|
||||
tileSet: tileSet,
|
||||
|
||||
// GAME CONFIGURATION - Change these to select different assets
|
||||
gameConfig: {
|
||||
playerType: "@", // Options: "@", "@2"
|
||||
treasureType: "$W", // Options: "$W" (Wownero), "$M" (Monero), "$B" (Bitcoin), "$" (Regular)
|
||||
monsterType: "~", // Options: "~", "~2"
|
||||
|
||||
// Floor tile configuration
|
||||
primaryFloor: "'1", // Main floor tile (99% of floors)
|
||||
secondaryFloor: "'2", // Alt floor tile (1% of floors)
|
||||
floorVariation: 0.01, // Percentage of secondary floor tiles (0.01 = 1%)
|
||||
|
||||
// Torch configuration
|
||||
torchEnabled: true, // Enable/disable torch placement
|
||||
torchDensity: 0.15, // Percentage of wall tiles that get torches (0.15 = 15%)
|
||||
torchTile: "torch" // Torch tile identifier
|
||||
},
|
||||
tileMap: {
|
||||
// Keep your existing tile mappings
|
||||
"'": [0, 0], // Floor
|
||||
"'1": [0, 0], // Floor
|
||||
">": [32, 0], // Exit
|
||||
"@": [64, 0], // Player
|
||||
"~": [96, 0], // Monster
|
||||
"$W": [960, 0], // Wownero Treasure
|
||||
"$M": [992, 0], // Monero Treasure
|
||||
"'2": [1024, 0], // Alt floor
|
||||
"<": [0, 32], // Entrance
|
||||
"=": [32, 32], // Monster Entrance
|
||||
"#": [64, 32], // Wall
|
||||
"$": [96, 32], // Treasure
|
||||
"$B": [96, 32], // Bitcoin Treasure
|
||||
"@2": [960, 32], // Player Alt
|
||||
"~2": [992, 32], // Monster Alt
|
||||
"torch": [1024, 32], // Torch
|
||||
// ... include all other necessary character mappings ...
|
||||
"a": [128, 0],
|
||||
"b": [160, 0],
|
||||
@@ -109,11 +132,13 @@ var options = {
|
||||
"^": [736, 64],
|
||||
")": [768, 64],
|
||||
"[": [800, 64],
|
||||
"]": [832, 64],
|
||||
"$": [832, 64], // remap to regular dollar sign
|
||||
"{": [864, 64],
|
||||
"%": [896, 64],
|
||||
"^": [928, 64],
|
||||
" ": [992, 64]
|
||||
"\'": [960, 64], // New quotes mapping
|
||||
"\"": [992, 64],
|
||||
" ": [1024, 64]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -121,3 +146,33 @@ var options = {
|
||||
window.tileSet = tileSet;
|
||||
window.tileMap = options.tileMap;
|
||||
window.options = options;
|
||||
|
||||
// Helper functions to get configured tile types
|
||||
window.GameTiles = {
|
||||
getPlayerTile: function() {
|
||||
return options.gameConfig.playerType;
|
||||
},
|
||||
|
||||
getTreasureTile: function() {
|
||||
return options.gameConfig.treasureType;
|
||||
},
|
||||
|
||||
getMonsterTile: function() {
|
||||
return options.gameConfig.monsterType;
|
||||
},
|
||||
|
||||
getFloorTile: function(useVariation = false) {
|
||||
if (useVariation && Math.random() < options.gameConfig.floorVariation) {
|
||||
return options.gameConfig.secondaryFloor;
|
||||
}
|
||||
return options.gameConfig.primaryFloor;
|
||||
},
|
||||
|
||||
getTorchTile: function() {
|
||||
return options.gameConfig.torchTile;
|
||||
},
|
||||
|
||||
shouldPlaceTorch: function() {
|
||||
return options.gameConfig.torchEnabled && Math.random() < options.gameConfig.torchDensity;
|
||||
}
|
||||
};
|
||||
|
||||
+41
-12
@@ -24,10 +24,17 @@ var RenderEngine = {
|
||||
const entrance = gameState.entrance;
|
||||
const exit = gameState.exit;
|
||||
const treasure = gameState.treasure;
|
||||
const torches = gameState.torches || []; // New torch positions
|
||||
const visibleTiles = gameState.visibleTiles || {};
|
||||
const exploredTiles = gameState.exploredTiles || {};
|
||||
const message = gameState.message;
|
||||
|
||||
// Get configured tile types from options
|
||||
const playerTile = window.GameTiles ? window.GameTiles.getPlayerTile() : '@';
|
||||
const treasureTile = window.GameTiles ? window.GameTiles.getTreasureTile() : '$W';
|
||||
const monsterTile = window.GameTiles ? window.GameTiles.getMonsterTile() : '~';
|
||||
const torchTile = window.GameTiles ? window.GameTiles.getTorchTile() : 'torch';
|
||||
|
||||
const playerWX = player.x;
|
||||
const playerWY = player.y;
|
||||
const centerX = Math.floor(this._screenWidth / 2);
|
||||
@@ -54,26 +61,40 @@ var RenderEngine = {
|
||||
tileType = visibleTiles[wy][wx];
|
||||
baseFg = this.defaultFg;
|
||||
|
||||
if (tileType === 1) {
|
||||
// Handle new string-based tile system
|
||||
if (tileType === '#') {
|
||||
baseChar = '#'; // Wall
|
||||
} else if (tileType === "'1" || tileType === "'2") {
|
||||
baseChar = tileType; // Use the specific floor tile type
|
||||
} else if (tileType === 'torch') {
|
||||
baseChar = '#'; // Torch tiles are walls with torches on top
|
||||
} else if (tileType === 1) {
|
||||
baseChar = '#'; // Legacy wall support
|
||||
} else if (tileType === 0) {
|
||||
baseChar = "'"; // Floor
|
||||
baseChar = "'1"; // Legacy floor support - use primary floor
|
||||
} else {
|
||||
baseChar = "'"; // Default to floor for safety
|
||||
tileType = 0;
|
||||
// Use the tile type directly if it's a string
|
||||
baseChar = tileType || "'1"; // Default to primary floor for safety
|
||||
}
|
||||
|
||||
} else if (exploredTiles[wy] && exploredTiles[wy][wx] !== undefined) {
|
||||
tileType = exploredTiles[wy][wx];
|
||||
baseFg = this.defaultFg;
|
||||
|
||||
if (tileType === 1) {
|
||||
// Handle new string-based tile system for explored tiles
|
||||
if (tileType === '#') {
|
||||
baseChar = '#'; // Wall
|
||||
} else if (tileType === "'1" || tileType === "'2") {
|
||||
baseChar = tileType; // Use the specific floor tile type
|
||||
} else if (tileType === 'torch') {
|
||||
baseChar = '#'; // Torch tiles are walls with torches on top
|
||||
} else if (tileType === 1) {
|
||||
baseChar = '#'; // Legacy wall support
|
||||
} else if (tileType === 0) {
|
||||
baseChar = "'"; // Floor
|
||||
baseChar = "'1"; // Legacy floor support - use primary floor
|
||||
} else {
|
||||
baseChar = "'"; // Default to floor for safety
|
||||
tileType = 0;
|
||||
// Use the tile type directly if it's a string
|
||||
baseChar = tileType || "'1"; // Default to primary floor for safety
|
||||
}
|
||||
} else {
|
||||
// No visible or explored tile - render empty space
|
||||
@@ -125,21 +146,28 @@ var RenderEngine = {
|
||||
|
||||
// Render treasure
|
||||
if (treasure && treasure[0] === wx && treasure[1] === wy && this.isVisible(wx, wy, visibleTiles)) {
|
||||
charStack.push('$');
|
||||
charStack.push(treasureTile);
|
||||
fgStack.push("transparent"); // Use transparent for now
|
||||
bgStack.push("transparent");
|
||||
}
|
||||
|
||||
// Render torches (check if this tile has a torch)
|
||||
if (this.isVisible(wx, wy, visibleTiles) && visibleTiles[wy][wx] === 'torch') {
|
||||
charStack.push(torchTile);
|
||||
fgStack.push("transparent"); // Use transparent for now
|
||||
bgStack.push("transparent");
|
||||
}
|
||||
|
||||
// Render monster
|
||||
if (monster && monster.x === wx && monster.y === wy && this.isVisible(wx, wy, visibleTiles)) {
|
||||
charStack.push('~');
|
||||
charStack.push(monsterTile);
|
||||
fgStack.push("transparent"); // Use transparent for now
|
||||
bgStack.push("transparent");
|
||||
}
|
||||
|
||||
// Render player (always on top)
|
||||
if (wx === playerWX && wy === playerWY) {
|
||||
charStack.push('@');
|
||||
charStack.push(playerTile);
|
||||
fgStack.push("transparent"); // Use transparent for now
|
||||
bgStack.push("transparent");
|
||||
}
|
||||
@@ -152,7 +180,8 @@ var RenderEngine = {
|
||||
// Validate characters are in tileMap
|
||||
for (let i = 0; i < charStack.length; i++) {
|
||||
if (!charStack[i] || (window.options?.tileMap && !window.options.tileMap.hasOwnProperty(charStack[i]))) {
|
||||
charStack[i] = "'";
|
||||
// Default to primary floor if tile not found
|
||||
charStack[i] = "'1";
|
||||
}
|
||||
if (!fgStack[i]) fgStack[i] = "transparent";
|
||||
if (!bgStack[i]) bgStack[i] = "transparent";
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ const UI = {
|
||||
// After animations are complete, set static text
|
||||
setTimeout(function() {
|
||||
$('#banner, #bannercursor').fadeOut(500, function() {
|
||||
$('#staticbanner').text("THE WOWNGEON");
|
||||
$('#staticbanner').text("WOWGUE - A Wownero Roguelike").fadeIn(500);
|
||||
});
|
||||
}, 14000);
|
||||
},
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 56 KiB |
Binary file not shown.
Reference in New Issue
Block a user