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 = 8; 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; // 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; // 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 = []; // 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('floorStrip', { anchorX: 0.5, anchorY: 0.5 })); floorCol.x = i * 4; floorCol.y = 2000; 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; for (var i = 0; i < 512; i++) { var rayAngle = player.angle - halfFov + i / 512 * fov; var distance = self.castRay(player.x, player.y, rayAngle); // Calculate wall height based on distance var wallHeight = Math.max(50, 20000 / (distance + 1)); var wallY = 1366 - wallHeight / 2; // Update wall column self.wallColumns[i].height = wallHeight; self.wallColumns[i].y = wallY; // Calculate floor perspective var floorY = 1366 + wallHeight / 2 + distance / 10; self.floorColumns[i].y = Math.min(2632, floorY); self.floorColumns[i].height = Math.max(2, distance / 50); // Calculate ceiling perspective var ceilY = 1366 - wallHeight / 2 - distance / 10; self.ceilingColumns[i].y = Math.max(0, ceilY); self.ceilingColumns[i].height = Math.max(2, distance / 50); } }; self.castRay = 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; } } return distance; }; 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); // 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); };
===================================================================
--- original.js
+++ change.js
@@ -16,18 +16,19 @@
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;
- // Simple boundary check
- if (newX > 100 && newX < 1948 && newY > 100 && newY < 2632) {
+ // 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;
- if (newX > 100 && newX < 1948 && newY > 100 && newY < 2632) {
+ // Check collision with world grid
+ if (!worldGrid.hasWallAt(newX, newY)) {
self.x = newX;
self.y = newY;
}
};
@@ -43,40 +44,32 @@
var self = Container.call(this);
self.wallColumns = [];
self.floorColumns = [];
self.ceilingColumns = [];
- self.init = function (floorArea, wallArea, ceilingArea) {
- self.floorArea = floorArea;
- self.wallArea = wallArea;
- self.ceilingArea = ceilingArea;
- // Create pseudo-3D rendering columns in their respective areas
- for (var i = 0; i < 512; i++) {
- // Wall columns in wall area
- var wallCol = self.wallArea.addChild(LK.getAsset('wall', {
- anchorX: 0.5,
- anchorY: 1.0
- }));
- wallCol.x = i * 4;
- wallCol.y = 1366;
- self.wallColumns.push(wallCol);
- // Floor columns in floor area - positioned below walls
- var floorCol = self.floorArea.addChild(LK.getAsset('floorStrip', {
- anchorX: 0.5,
- anchorY: 0.5
- }));
- floorCol.x = i * 4;
- floorCol.y = 2000;
- self.floorColumns.push(floorCol);
- // Ceiling columns in ceiling area - positioned above walls
- var ceilCol = self.ceilingArea.addChild(LK.getAsset('ceilingStrip', {
- anchorX: 0.5,
- anchorY: 0.5
- }));
- ceilCol.x = i * 4;
- ceilCol.y = 700;
- self.ceilingColumns.push(ceilCol);
- }
- };
+ // 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('floorStrip', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ floorCol.x = i * 4;
+ floorCol.y = 2000;
+ 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;
for (var i = 0; i < 512; i++) {
@@ -84,16 +77,16 @@
var distance = self.castRay(player.x, player.y, rayAngle);
// Calculate wall height based on distance
var wallHeight = Math.max(50, 20000 / (distance + 1));
var wallY = 1366 - wallHeight / 2;
- // Update wall column in wall area (middle layer)
+ // Update wall column
self.wallColumns[i].height = wallHeight;
self.wallColumns[i].y = wallY;
- // Update floor column in floor area (below walls and player)
+ // Calculate floor perspective
var floorY = 1366 + wallHeight / 2 + distance / 10;
self.floorColumns[i].y = Math.min(2632, floorY);
self.floorColumns[i].height = Math.max(2, distance / 50);
- // Update ceiling column in ceiling area (above walls and player)
+ // Calculate ceiling perspective
var ceilY = 1366 - wallHeight / 2 - distance / 10;
self.ceilingColumns[i].y = Math.max(0, ceilY);
self.ceilingColumns[i].height = Math.max(2, distance / 50);
}
@@ -103,23 +96,17 @@
var rayY = startY;
var deltaX = Math.cos(angle) * 2;
var deltaY = Math.sin(angle) * 2;
var distance = 0;
- // Simple raycasting - check for boundaries
+ // Raycast using world coordinate system
while (distance < 1000) {
rayX += deltaX;
rayY += deltaY;
distance += 2;
- // Hit wall boundaries
- if (rayX <= 100 || rayX >= 1948 || rayY <= 100 || rayY >= 2632) {
+ // Check for walls using world grid
+ if (worldGrid.hasWallAt(rayX, rayY)) {
break;
}
- // Add some procedural walls for the backrooms feel
- var gridX = Math.floor(rayX / 200);
- var gridY = Math.floor(rayY / 200);
- if ((gridX + gridY) % 3 === 0 && distance > 50) {
- break;
- }
}
return distance;
};
return self;
@@ -135,26 +122,70 @@
/****
* Game Code
****/
-// Create separate areas for different pseudo-3D layers
-var floorArea = new Container();
-var wallArea = new Container();
-var ceilingArea = new Container();
-// Position areas correctly - floor below, walls middle, ceiling above
-floorArea.y = 1366; // Floor area positioned below player level
-wallArea.y = 0; // Wall area at player level
-ceilingArea.y = -366; // Ceiling area positioned above player level
-// Add areas to game in correct order (back to front)
-game.addChild(ceilingArea); // Ceiling at back
-game.addChild(wallArea); // Walls in middle
-game.addChild(floorArea); // Floor at front (closest to player)
+// 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();
-wallArea.addChild(player); // Player exists in wall area
+// 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();
-renderer3D.init(floorArea, wallArea, ceilingArea);
+game.addChild(renderer3D);
// Movement flags
var moveForward = false;
var moveBackward = false;
var turnLeft = false;