User prompt
Fix Bug: 'TypeError: dot.intersectsPixel is not a function' in or related to this line: 'if (dot.intersectsPixel(obstacles[i])) {' Line Number: 113
User prompt
dot interection with big obstacle should be based on pixels and not on asset surface
User prompt
Fix Bug: 'TypeError: dot.intersectsPixelPerfect is not a function' in or related to this line: 'if (dot.intersectsPixelPerfect(obstacles[i])) {' Line Number: 114
User prompt
dot interection with big obstacle should be based on pixels and not on asset surface
User prompt
bigobstacle should rotate on its axis on game start
User prompt
bigobstacles should use the size set in the asset
Code edit (2 edits merged)
Please save this source code
User prompt
double size of bigobstacle
User prompt
bigobstacles should rotate on its axis on game start
User prompt
Fix Bug: 'TypeError: obstacles[i].move is not a function' in or related to this line: 'obstacles[i].move();' Line Number: 111
User prompt
Fix Bug: 'TypeError: obstacles[i].move is not a function' in or related to this line: 'obstacles[i].move();' Line Number: 111
User prompt
bigobstacle shouldnot move sideways
User prompt
Fix Bug: 'TypeError: obstacles[i].move is not a function' in or related to this line: 'obstacles[i].move();' Line Number: 110
User prompt
Fix Bug: 'TypeError: obstacles[i].move is not a function' in or related to this line: 'obstacles[i].move();' Line Number: 110
User prompt
bigobstacles should rotateon its axis
User prompt
bigobstacle should spawn in the center of x axis and not move sideways
User prompt
create a new bigobstacle. should behave the sameway as obstacles towards the dot
Code edit (1 edits merged)
Please save this source code
User prompt
obstacles should start spawnning from the middle of the screen and upwards
User prompt
remove flash on game over
User prompt
dot particles should have an explosion pattern
User prompt
obstacles should spawn in the center of the screen and move in the shape of a square
User prompt
after dot collides with obstacle wait for 1.5 seconds before game ovevr
User prompt
add particles effect when dot collides with obstacle
User prompt
star should have the same y moments downwards like the obstacles
/**** * Classes ****/ var Dot = Container.expand(function () { var self = Container.call(this); var dotGraphics = self.attachAsset('dot', { anchorX: 0.5, anchorY: 0.5 }); self.velocityY = 0; self.gravity = 0.5; self.bounce = -15; self.update = function () { var previousY = self.y; self.velocityY += self.gravity; self.y += self.velocityY; if (self.y > 2732 - self.height / 2) { self.velocityY = self.bounce; } self.movedDistance = self.y - previousY; }; self.bounceUp = function () { self.velocityY = self.bounce; }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.direction = Math.random() < 0.5 ? -1 : 1; self.speed = (Math.random() * 3 + 5) * self.direction; self.move = function () { self.x += self.speed; if (self.direction === 1 && self.x > 2048 + self.width / 2 || self.direction === -1 && self.x < -self.width / 2) { self.direction *= -1; self.speed *= -1; self.y = Math.random() * (2732 - self.height) + self.height / 2; } }; self.moveDown = function (distance) { self.y += distance; if (self.y > 2732 - self.height / 2) { self.y = -self.height / 2; } }; }); var BigObstacle = Container.expand(function () { var self = Container.call(this); var bigObstacleGraphics = self.attachAsset('bigobstacle', { anchorX: 0.5, anchorY: 0.5 }); self.direction = Math.random() < 0.5 ? -1 : 1; self.speed = (Math.random() * 3 + 5) * self.direction; self.rotationSpeed = 0.01; self.move = function () { // No horizontal movement for BigObstacle self.rotation += self.rotationSpeed; }; self.moveDown = function (distance) { self.y += distance; if (self.y > 2732 - self.height / 2) { self.y = -self.height / 2; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var dot = game.addChild(new Dot()); dot.x = 2048 / 2; dot.y = 2732 / 2; var obstacles = []; for (var i = 0; i < 4; i++) { var obstacle = game.addChild(new Obstacle()); obstacle.x = obstacle.direction === 1 ? -obstacle.width / 2 : 2048 + obstacle.width / 2; obstacle.y = Math.random() * (1366 - obstacle.height) + obstacle.height / 2; obstacles.push(obstacle); } var bigObstacle = game.addChild(new BigObstacle()); bigObstacle.x = 2048 / 2; bigObstacle.y = Math.random() * (1366 - bigObstacle.height) + bigObstacle.height / 2; obstacles.push(bigObstacle); var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); scoreTxt.x = 2048 / 2; scoreTxt.y = 50; LK.gui.top.addChild(scoreTxt); game.on('down', function (obj) { dot.bounceUp(); }); LK.on('tick', function () { dot.update(); for (var i = 0; i < obstacles.length; i++) { obstacles[i].move(); if (dot.y < 1200 && dot.movedDistance < 0) { // If the dot moved up and its y position is less than 1400 obstacles[i].moveDown(-dot.movedDistance); } if (dot.intersects(obstacles[i])) { LK.showGameOver(); } } // Update score based on the dot's survival time var currentScore = Math.floor(LK.ticks / 60); LK.setScore(currentScore); scoreTxt.setText(LK.getScore().toString()); });
===================================================================
--- original.js
+++ change.js
@@ -109,9 +109,9 @@
if (dot.y < 1200 && dot.movedDistance < 0) {
// If the dot moved up and its y position is less than 1400
obstacles[i].moveDown(-dot.movedDistance);
}
- if (dot.intersectsPixel(obstacles[i])) {
+ if (dot.intersects(obstacles[i])) {
LK.showGameOver();
}
}
// Update score based on the dot's survival time