User prompt
Haz que la paredes no tengan textura
User prompt
Haz que la pared tenga el color de la imagen
User prompt
También pon un reconocimiento de cada ves que se toca la pared para poner colision con esta
User prompt
Debes usar una textura cuadrada has que la textura de la pared se pueda moldear para el juego
User prompt
Crea 2 texturas 1 invisible que sea para la segunda textura que es donde está la visible se usará la invisible para moldear la pared y con la textura mostrada se pegará a la que lo se ve
User prompt
Por las coordenadas crea paredes y haz o fuerza que la textura se moldé a la base de la coordenada
User prompt
Haz que la pared sea 1 sola por cada lugar de pared
User prompt
Haz un sistema propio de paredes para que imiten a las de baldi's basic education
User prompt
No se como hacer las paredes te dejo a consideración tuya hacer un sistema de paredes funcional
User prompt
En el techo haz cuadrados amarillos que estén en el medio o en un lugar que no esté serca de una esquina
User prompt
Haz que se pueda interactuar con la configuraciónes y haz el botón de este más grande
User prompt
Haz un sistema de configuración en la parte superior en la derecha para configurar la sensibilidad esta tendrá del 0 al 100 en esta pon diferente sensibilidad para el gusto del jugador ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Haz que el movimiento de la cámara más fluido ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Con el sistema de coordenadas trasa donde hay paredes y donde adra y pon una pared las paredes no se podrán acumular en un lugar se van a poner una pared al terminar el cuadrado asi hasta completar una línea
User prompt
Has que la paredes sigan una línea recta
User prompt
Haz un sistema de vista para que las paredes no se intercalan ósea si tengo una pared enfrente no puedo ver las cosas que están detrás de esta
User prompt
Haz que la pared sea un cuadrado
User prompt
Haz que las paredes sigan una coordenada para que no se vean tan puntiagudas
User prompt
Haz que el movimiento del personaje disminuya
User prompt
Haz que el juego separe por el sistema de paeudeo-3D las paredes la parte del medio el piso la parte inferior y el techo la parte alta de este como en doom
User prompt
Haz una textura que se llame piso y repréntala con color verde y ponla en la coordenada 0
User prompt
Haz que el personaje no pueda bajar de la coordenada y 0
User prompt
Haz visibles las coordenadas x y z para el jugar
User prompt
has un sistema de coordenadas y que las paredes piso y techo respeten estas coordenadas
User prompt
Haz un espacio para estas áreas el piso siempre va a estar debajo del personaje y de las paredes las paredes están en el medio del piso y el techo es un separador de área y el techo simpre va a estar arriba del personaje y arriba de las paredes
/****
* Classes
****/
var Player = Container.expand(function () {
var self = Container.call(this);
self.x = 1024;
self.y = 1366;
self.angle = 0;
self.speed = 3;
self.rotSpeed = 0.1;
// Player visual for debugging (will be hidden in first person)
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
playerGraphics.visible = false; // Hide for first person view
self.moveForward = function () {
var newX = self.x + Math.cos(self.angle) * self.speed;
var newY = self.y + Math.sin(self.angle) * self.speed;
// Constrain Y coordinate to not go below 0
if (newY < 0) {
newY = 0;
}
// Check collision with world grid
if (!worldGrid.hasWallAt(newX, newY)) {
self.x = newX;
self.y = newY;
}
};
self.moveBackward = function () {
var newX = self.x - Math.cos(self.angle) * self.speed;
var newY = self.y - Math.sin(self.angle) * self.speed;
// Constrain Y coordinate to not go below 0
if (newY < 0) {
newY = 0;
}
// Check collision with world grid
if (!worldGrid.hasWallAt(newX, newY)) {
self.x = newX;
self.y = newY;
}
};
self.turnLeft = function () {
self.angle -= self.rotSpeed;
};
self.turnRight = function () {
self.angle += self.rotSpeed;
};
return self;
});
var Renderer3D = Container.expand(function () {
var self = Container.call(this);
self.wallColumns = [];
self.floorColumns = [];
self.ceilingColumns = [];
self.zBuffer = []; // Track depth for each column
// Create pseudo-3D rendering columns
for (var i = 0; i < 512; i++) {
var wallCol = self.addChild(LK.getAsset('wall', {
anchorX: 0.5,
anchorY: 1.0
}));
wallCol.x = i * 4;
wallCol.y = 1366;
self.wallColumns.push(wallCol);
var floorCol = self.addChild(LK.getAsset('piso', {
anchorX: 0.5,
anchorY: 0.5
}));
floorCol.x = i * 4;
floorCol.y = 1366;
self.floorColumns.push(floorCol);
var ceilCol = self.addChild(LK.getAsset('ceilingStrip', {
anchorX: 0.5,
anchorY: 0.5
}));
ceilCol.x = i * 4;
ceilCol.y = 700;
self.ceilingColumns.push(ceilCol);
}
self.render = function (player) {
var fov = Math.PI / 3; // 60 degrees field of view
var halfFov = fov / 2;
var screenHeight = 2732;
var screenCenter = screenHeight / 2; // Center line at Y = 1366
// Store column data for depth sorting
var columnData = [];
for (var i = 0; i < 512; i++) {
var rayAngle = player.angle - halfFov + i / 512 * fov;
var rayData = self.castRayWithCoords(player.x, player.y, rayAngle);
var distance = rayData.distance;
var hitX = rayData.hitX;
var hitY = rayData.hitY;
// Store column data with distance for sorting
columnData.push({
index: i,
distance: distance,
hitX: hitX,
hitY: hitY,
rayAngle: rayAngle
});
}
// Sort columns by distance (farthest first for proper depth)
columnData.sort(function (a, b) {
return b.distance - a.distance;
});
// Initialize z-buffer for this frame
for (var k = 0; k < 512; k++) {
self.zBuffer[k] = 1000; // Start with maximum distance
}
// First pass: Update z-buffer with closest distances
for (var j = 0; j < columnData.length; j++) {
var data = columnData[j];
var i = data.index;
var distance = data.distance;
// Only update z-buffer if this is closer
if (distance < self.zBuffer[i]) {
self.zBuffer[i] = distance;
}
}
// Second pass: Render only if at closest distance
for (var j = 0; j < columnData.length; j++) {
var data = columnData[j];
var i = data.index;
var distance = data.distance;
var hitX = data.hitX;
var hitY = data.hitY;
// Only render if this column is at the closest distance
if (Math.abs(distance - self.zBuffer[i]) < 1) {
// Calculate wall height to maintain square aspect ratio
var baseWallSize = 400; // Base size for square walls
var wallHeight = Math.max(100, baseWallSize * (1000 / (distance + 100)));
var wallWidth = wallHeight; // Make it square
var halfWallHeight = wallHeight / 2;
// WALLS: Position in middle section (centered on screen)
var wallTop = screenCenter - halfWallHeight;
var wallBottom = screenCenter + halfWallHeight;
self.wallColumns[i].height = wallHeight;
self.wallColumns[i].width = wallWidth;
self.wallColumns[i].y = wallBottom; // Anchor at bottom of wall
self.wallColumns[i].visible = true;
// Align wall columns to exact grid lines for straight wall appearance
var gridX = Math.floor(hitX / worldGrid.cellSize);
var gridY = Math.floor(hitY / worldGrid.cellSize);
// Snap to exact grid boundaries to create straight walls
var alignedX = gridX * worldGrid.cellSize;
var alignedY = gridY * worldGrid.cellSize;
// Position wall column at aligned grid position
self.wallColumns[i].x = i * 4; // Keep screen column position
// FLOOR: Bottom section (from wall bottom to screen bottom)
var floorTop = wallBottom;
var floorHeight = screenHeight - floorTop;
self.floorColumns[i].y = floorTop + floorHeight / 2; // Center floor in bottom section
self.floorColumns[i].height = Math.max(2, floorHeight);
self.floorColumns[i].visible = true;
// CEILING: Top section (from screen top to wall top)
var ceilingHeight = wallTop;
self.ceilingColumns[i].y = ceilingHeight / 2; // Center ceiling in top section
self.ceilingColumns[i].height = Math.max(2, ceilingHeight);
self.ceilingColumns[i].visible = true;
} else {
// Hide columns that are behind walls
self.wallColumns[i].visible = false;
self.floorColumns[i].visible = false;
self.ceilingColumns[i].visible = false;
}
}
};
self.castRay = function (startX, startY, angle) {
var rayData = self.castRayWithCoords(startX, startY, angle);
return rayData.distance;
};
self.castRayWithCoords = function (startX, startY, angle) {
var rayX = startX;
var rayY = startY;
var deltaX = Math.cos(angle) * 2;
var deltaY = Math.sin(angle) * 2;
var distance = 0;
// Raycast using world coordinate system
while (distance < 1000) {
rayX += deltaX;
rayY += deltaY;
distance += 2;
// Check for walls using world grid
if (worldGrid.hasWallAt(rayX, rayY)) {
break;
}
}
// Align hit coordinates to grid boundaries for straight walls
var gridX = Math.floor(rayX / worldGrid.cellSize);
var gridY = Math.floor(rayY / worldGrid.cellSize);
var alignedHitX = gridX * worldGrid.cellSize;
var alignedHitY = gridY * worldGrid.cellSize;
return {
distance: distance,
hitX: alignedHitX,
hitY: alignedHitY
};
};
return self;
});
/****
* Initialize Game
****/
// Create player
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// World coordinate system - grid-based layout
var worldGrid = {
cellSize: 200,
width: 20,
// 20x20 grid
height: 20,
walls: [],
// Will store wall positions
// Initialize world grid with walls
initializeGrid: function initializeGrid() {
for (var x = 0; x < this.width; x++) {
this.walls[x] = [];
for (var y = 0; y < this.height; y++) {
// Create backrooms-style layout
var isWall = false;
// Outer boundaries are always walls
if (x === 0 || x === this.width - 1 || y === 0 || y === this.height - 1) {
isWall = true;
}
// Create maze-like structure typical of backrooms
else if (x % 3 === 0 && y % 3 === 0 || x % 4 === 0 && y % 2 === 0 || y % 4 === 0 && x % 2 === 0) {
isWall = true;
}
this.walls[x][y] = isWall;
}
}
},
// Check if a world position has a wall
hasWallAt: function hasWallAt(worldX, worldY) {
var gridX = Math.floor(worldX / this.cellSize);
var gridY = Math.floor(worldY / this.cellSize);
if (gridX < 0 || gridX >= this.width || gridY < 0 || gridY >= this.height) {
return true; // Outside bounds = wall
}
return this.walls[gridX][gridY];
},
// Convert screen coordinates to world coordinates
screenToWorld: function screenToWorld(screenX, screenY) {
return {
x: screenX,
y: screenY
};
},
// Convert world coordinates to screen coordinates
worldToScreen: function worldToScreen(worldX, worldY) {
return {
x: worldX,
y: worldY
};
}
};
// Initialize the world grid
worldGrid.initializeGrid();
// Create player
var player = new Player();
// Position player at a valid starting location in the world grid
player.x = worldGrid.cellSize * 1.5; // Start in cell (1,1)
player.y = worldGrid.cellSize * 1.5;
game.addChild(player);
// Create 3D renderer
var renderer3D = new Renderer3D();
game.addChild(renderer3D);
// Create coordinate display text
var coordXText = new Text2('X: 0', {
size: 60,
fill: 0xFFFFFF
});
coordXText.anchor.set(0, 0);
coordXText.x = 120; // Avoid top-left 100x100 area
coordXText.y = 120;
LK.gui.addChild(coordXText);
var coordZText = new Text2('Z: 0', {
size: 60,
fill: 0xFFFFFF
});
coordZText.anchor.set(0, 0);
coordZText.x = 120; // Avoid top-left 100x100 area
coordZText.y = 200;
LK.gui.addChild(coordZText);
// Movement flags
var moveForward = false;
var moveBackward = false;
var turnLeft = false;
var turnRight = false;
// Touch controls for movement
var touchStartX = 0;
var touchStartY = 0;
var touchActive = false;
game.down = function (x, y, obj) {
touchStartX = x;
touchStartY = y;
touchActive = true;
// Forward movement on touch
moveForward = true;
};
game.up = function (x, y, obj) {
touchActive = false;
moveForward = false;
moveBackward = false;
turnLeft = false;
turnRight = false;
};
game.move = function (x, y, obj) {
if (!touchActive) return;
var deltaX = x - touchStartX;
var deltaY = y - touchStartY;
// Horizontal movement for turning
if (Math.abs(deltaX) > 50) {
if (deltaX > 0) {
turnRight = true;
turnLeft = false;
} else {
turnLeft = true;
turnRight = false;
}
} else {
turnLeft = false;
turnRight = false;
}
// Vertical movement for forward/backward
if (Math.abs(deltaY) > 50) {
if (deltaY < 0) {
moveForward = true;
moveBackward = false;
} else {
moveBackward = true;
moveForward = false;
}
}
};
game.update = function () {
// Handle movement
if (moveForward) {
player.moveForward();
}
if (moveBackward) {
player.moveBackward();
}
if (turnLeft) {
player.turnLeft();
}
if (turnRight) {
player.turnRight();
}
// Render the pseudo-3D view
renderer3D.render(player);
// Update coordinate display
var gridX = Math.floor(player.x / worldGrid.cellSize);
var gridZ = Math.floor(player.y / worldGrid.cellSize);
coordXText.setText('X: ' + gridX);
coordZText.setText('Z: ' + gridZ);
}; ===================================================================
--- original.js
+++ change.js
@@ -138,13 +138,16 @@
self.wallColumns[i].height = wallHeight;
self.wallColumns[i].width = wallWidth;
self.wallColumns[i].y = wallBottom; // Anchor at bottom of wall
self.wallColumns[i].visible = true;
- // Align wall columns to grid coordinates to prevent jagged appearance
+ // Align wall columns to exact grid lines for straight wall appearance
var gridX = Math.floor(hitX / worldGrid.cellSize);
var gridY = Math.floor(hitY / worldGrid.cellSize);
- var alignedX = gridX * worldGrid.cellSize + worldGrid.cellSize / 2;
- var alignedY = gridY * worldGrid.cellSize + worldGrid.cellSize / 2;
+ // Snap to exact grid boundaries to create straight walls
+ var alignedX = gridX * worldGrid.cellSize;
+ var alignedY = gridY * worldGrid.cellSize;
+ // Position wall column at aligned grid position
+ self.wallColumns[i].x = i * 4; // Keep screen column position
// FLOOR: Bottom section (from wall bottom to screen bottom)
var floorTop = wallBottom;
var floorHeight = screenHeight - floorTop;
self.floorColumns[i].y = floorTop + floorHeight / 2; // Center floor in bottom section
@@ -182,12 +185,17 @@
if (worldGrid.hasWallAt(rayX, rayY)) {
break;
}
}
+ // Align hit coordinates to grid boundaries for straight walls
+ var gridX = Math.floor(rayX / worldGrid.cellSize);
+ var gridY = Math.floor(rayY / worldGrid.cellSize);
+ var alignedHitX = gridX * worldGrid.cellSize;
+ var alignedHitY = gridY * worldGrid.cellSize;
return {
distance: distance,
- hitX: rayX,
- hitY: rayY
+ hitX: alignedHitX,
+ hitY: alignedHitY
};
};
return self;
});