User prompt
Bg=blue
User prompt
Over the game if any obstacle missed
Code edit (1 edits merged)
Please save this source code
User prompt
When the dot touch obstacles the obstacles should disappear
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'mainShip.update();' Line Number: 83
User prompt
Please fix the bug: 'ReferenceError: mainShip is not defined' in or related to this line: 'mainShip.update();' Line Number: 81
User prompt
At dots as main ship
User prompt
Remove
User prompt
Add dot
User prompt
Disappear the obstacles as user touch it
User prompt
Please fix the bug: 'Uncaught TypeError: obstacles[i].containsPoint is not a function' in or related to this line: 'if (obstacles[i].containsPoint({' Line Number: 73
User prompt
If the user touch obstacles then it disappears
User prompt
Remove the hero
User prompt
Move the hero
User prompt
Please fix the bug: 'Uncaught TypeError: requestAnimationFrame is not a function' in or related to this line: 'requestAnimationFrame(_moveHero);' Line Number: 114
User prompt
My ve the hero
User prompt
The hero can move as user wants
User prompt
The dot can move as user wants
Initial prompt
Jungle Dash
===================================================================
--- original.js
+++ change.js
@@ -96,20 +96,18 @@
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var deltaX = x - centerX;
var deltaY = y - centerY;
- if (Math.abs(deltaX) > Math.abs(deltaY)) {
- if (deltaX > 0) {
- hero.move('right');
+ var directionX = deltaX > 0 ? 'right' : 'left';
+ var directionY = deltaY > 0 ? 'down' : 'up';
+ var _moveHero = function moveHero() {
+ if (Math.abs(deltaX) > Math.abs(deltaY)) {
+ hero.move(directionX);
} else {
- hero.move('left');
+ hero.move(directionY);
}
- } else {
- if (deltaY > 0) {
- hero.move('down');
- } else {
- hero.move('up');
- }
- }
+ requestAnimationFrame(_moveHero);
+ };
+ _moveHero();
};
// Initialize game elements
initGame();
\ No newline at end of file