Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: obstacleManager is not defined' in or related to this line: 'obstacleManager.setPathOccupied(self.pathIndex, false); // Mark the path as unoccupied' Line Number: 481
User prompt
now create a ObstacleManager class that will be responsible of handling Obstacles path and active state globally
User prompt
add a propery active to Obstacle class
User prompt
obstacles spawn configuration is always the same, randomize it in order to have sometimes 1 obstacle, sometimes 2 spawned at same time (not same path)
User prompt
obstacles configuration is always the same, randomize it
User prompt
using index property of obstacles and reset() function, invent a way to avoid having 2 obstacles spwaned on the same path at the same time
User prompt
use baseNbObstacles to loop on obstacles spawn
User prompt
add a global baseNbObstacles = 5
User prompt
add a global baseNbCoins and use it instead of 5
User prompt
store the index in a property of Obstacle class
User prompt
also pass and index to Obstacle constructor
Code edit (3 edits merged)
Please save this source code
User prompt
pass an index to Coin constructor
User prompt
coin value is in $; in level 1 coinValue is 0.10$; adapt increaseScore to display score in ยข when <1$ then round then in $ and ยข when <10$ then rounded in $
Code edit (1 edits merged)
Please save this source code
User prompt
also move coinsCollected +=1 inside increase score
User prompt
now use increaseScore function instead of mannual increase
User prompt
add new global function increaseScore(); it add coinValue of currentLevel to the score
Code edit (1 edits merged)
Please save this source code
Code edit (23 edits merged)
Please save this source code
User prompt
add a global array levelConfigs that contains an object for each level. each object is the config of a level and have the following properties : name, coinValue, baseSpeed
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
in decoration reset log // Add left & right startX & endX here
===================================================================
--- original.js
+++ change.js
@@ -858,8 +858,12 @@
/****
* Game Code
****/
+function increaseScore() {
+ score += levelConfigs[currentLevel - 1].coinValue;
+ scoreTxt.setText(currentLevel == 1 ? score + "ยข" : "$" + score);
+}
var levelConfigs = [{}, {
name: "Level 1",
coinValue: 0.10,
baseSpeed: 10
Directly overhead, plumb view of a beggar heading top (we see his back).. Zenith view, directly overhead, plumb view. NOT PERSPECTIVE! Fantasy theme. Pixel art
a traffic cone. video game sprite
face view of a big start button in the shape of a dollar bill. video game style
a tree. video game style
a black garbage bag. video game style
Dollar bill. Perspective. video game sprite
perspective of a simple snake rolled up on itself.. video game sprite
Ball of dry desert bushes. video game sprite
tractor. high definition video game sprite
street ad billboard with 1 or 2 posts with "Get rich!" on it. high definition video game sprite
a dog sleeping on a street. video game sprite
desert bush. video game sprite
profile view of an empty motorcycle helmet. black with a white vertical central band and another thiner orange band on the center. NOT PERSPECTIVE!. Pixel art high definition
simple red and white magnet. video game style
gold sign with a "X" and a "2". video game style
bgMusic
Music
coin_1
Sound effect
hit_1
Sound effect
hit_2
Sound effect
hit_3
Sound effect
levelWin_1
Sound effect
car_1
Sound effect
police_1
Sound effect
ambulance_1
Sound effect
accident_1
Sound effect
killed_1
Sound effect
jump_1
Sound effect
rip_1
Sound effect
bonus_take
Sound effect
bonus_approaching
Sound effect