User prompt
Build the poles faster
User prompt
the distance between posts should be 2 pixels
User prompt
the distance between cubes should be 2 pixels
User prompt
the distance between cubes and pillars should be 2 pixels
User prompt
the distance between cubes should be 2 pixels
User prompt
the flow of poles must be continuous
User prompt
columns should come out of the screen border already formed
User prompt
columns should come out of the screen border already formed and without gaps
User prompt
columns should come out of the screen border already formed and without gaps of more than 2 pixels
User prompt
columns should come out of the screen border already formed
User prompt
Fix Bug: 'TypeError: poles[0].getGlobalPosition is not a function' in or related to this line: 'while (poles.length > 0 && poles[0].getGlobalPosition().x + poles[0].width / 2 < 0) {' Line Number: 90
User prompt
Fix Bug: 'TypeError: poles[0].getGlobalPosition is not a function' in or related to this line: 'while (poles.length > 0 && poles[0].getGlobalPosition().x + poles[0].width / 2 < 0) {' Line Number: 90
User prompt
to make the flow of poles continuous
User prompt
the columns should come out of the screen boundary already formed
User prompt
make the distance between the poles 2 pixels
User prompt
the poles must stand close together
User prompt
the poles must be close to each other
User prompt
there must be no gaps between the posts
User prompt
fill the entire space with cubes
Initial prompt
Platformer
===================================================================
--- original.js
+++ change.js
@@ -1,106 +1,109 @@
-/****
+/****
* Classes
****/
// Class for the poles consisting of cubes
var Pole = Container.expand(function () {
- var self = Container.call(this);
- self.cubes = [];
- self.addCube = function () {
- var cube = self.attachAsset('cube', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- cube.y = -(self.cubes.length * 100);
- self.cubes.push(cube);
- };
- self.getHeight = function () {
- return self.cubes.length * 100;
- };
+ var self = Container.call(this);
+ self.cubes = [];
+ self.addCube = function () {
+ var cube = self.attachAsset('cube', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ cube.y = -(self.cubes.length * 100);
+ self.cubes.push(cube);
+ };
+ self.getHeight = function () {
+ return self.cubes.length * 100;
+ };
});
// Class for the player's hero
var Hero = Container.expand(function () {
- var self = Container.call(this);
- var heroGraphics = self.attachAsset('hero', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.isOnGround = false;
- self.velocityY = 0;
- self.jump = function () {
- if (self.isOnGround) {
- self.velocityY = -15;
- self.isOnGround = false;
- }
- };
- self.update = function () {
- self.y += self.velocityY;
- self.velocityY += 0.5; // Gravity effect
- };
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isOnGround = false;
+ self.velocityY = 0;
+ self.jump = function () {
+ if (self.isOnGround) {
+ self.velocityY = -15;
+ self.isOnGround = false;
+ }
+ };
+ self.update = function () {
+ self.y += self.velocityY;
+ self.velocityY += 0.5; // Gravity effect
+ };
});
-/****
+/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 // Init game with black background
+ backgroundColor: 0x000000 // Init game with black background
});
-/****
+/****
* Game Code
****/
-// Initialize important asset arrays
// Initialize assets used in the game.
+// Initialize important asset arrays
var poles = [];
var hero;
// Create the hero
hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150; // Start above the bottom of the screen
// Create initial poles
function createInitialPoles() {
- for (var i = 0; i < 5; i++) {
- var pole = game.addChild(new Pole());
- pole.x = 300 + i * 500; // Space out poles horizontally
- pole.y = 2732; // Align base of pole with bottom of the screen
- for (var j = 0; j < 3; j++) {
- // Add 3 cubes to each pole
- pole.addCube();
- }
- poles.push(pole);
- }
+ var poleSpacing = 100; // Space between poles
+ var poleCount = Math.ceil(2048 / poleSpacing); // Number of poles to fill the width
+ for (var i = 0; i < poleCount; i++) {
+ var pole = game.addChild(new Pole());
+ pole.x = i * poleSpacing + 50; // Space out poles horizontally
+ pole.y = 2732; // Align base of pole with bottom of the screen
+ var cubeCount = Math.ceil(2732 / 100); // Number of cubes to fill the height
+ for (var j = 0; j < cubeCount; j++) {
+ // Add cubes to each pole to fill the height
+ pole.addCube();
+ }
+ poles.push(pole);
+ }
}
createInitialPoles();
// Event listener for jump action
game.on('down', function (obj) {
- hero.jump();
+ hero.jump();
});
// Game tick update
LK.on('tick', function () {
- hero.update();
- // Collision detection with poles
- for (var i = 0; i < poles.length; i++) {
- var pole = poles[i];
- if (hero.intersects(pole) && hero.velocityY > 0 && hero.y + hero.height / 2 < pole.y) {
- hero.y = pole.y - pole.getHeight() - hero.height / 2;
- hero.isOnGround = true;
- hero.velocityY = 0;
- }
- }
- // Remove off-screen poles and create new ones
- if (poles.length > 0 && poles[0].x + poles[0].width / 2 < 0) {
- poles[0].destroy();
- poles.shift();
- var newPole = game.addChild(new Pole());
- newPole.x = poles[poles.length - 1].x + 500; // Position new pole to the right of the last one
- newPole.y = 2732;
- var cubesCount = Math.floor(Math.random() * 3) + 1; // Random number of cubes between 1 and 3
- for (var j = 0; j < cubesCount; j++) {
- newPole.addCube();
- }
- poles.push(newPole);
- }
- // Move poles to the left to simulate hero running
- for (var i = 0; i < poles.length; i++) {
- poles[i].x -= 5;
- }
+ hero.update();
+ // Collision detection with poles
+ for (var i = 0; i < poles.length; i++) {
+ var pole = poles[i];
+ if (hero.intersects(pole) && hero.velocityY > 0 && hero.y + hero.height / 2 < pole.y) {
+ hero.y = pole.y - pole.getHeight() - hero.height / 2;
+ hero.isOnGround = true;
+ hero.velocityY = 0;
+ }
+ }
+ // Remove off-screen poles and create new ones
+ if (poles.length > 0 && poles[0].x + poles[0].width / 2 < 0) {
+ poles[0].destroy();
+ poles.shift();
+ var newPole = game.addChild(new Pole());
+ newPole.x = poles[poles.length - 1].x + 500; // Position new pole to the right of the last one
+ newPole.y = 2732;
+ var cubesCount = Math.floor(Math.random() * 3) + 1; // Random number of cubes between 1 and 3
+ for (var j = 0; j < cubesCount; j++) {
+ newPole.addCube();
+ }
+ poles.push(newPole);
+ }
+ // Move poles to the left to simulate hero running
+ for (var i = 0; i < poles.length; i++) {
+ poles[i].x -= 5;
+ }
});
\ No newline at end of file
girl sitting on Wrecking Ball, cartoon style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
construction cranes on the sides of the frame, depth of field blur, cartoon style, black and white. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
"ALARM" text bubble, comic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
the surface is gray, concrete with a black square in the center. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Wrecking Ball with eyes, cartoon style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
the surface is red, concrete with a black square in the center.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
"ALARM" text bubble yellow, comic book style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
the surface is yellow, concrete with a black square in the center. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.