Page 150 - KEC Khaitan C5 Flipbook
P. 150

car2.velocityY = 10;

                      start.visible = false;

                    }
                    o   The enemy cars begin moving when the player presses the spacebar.

                  Step 8: Adding Collision Detection

                     Show Restart Button on Collision:

                    if(player_car.isTouching(car1) || player_car.isTouching(car2)){

                      restart.visible = true;

                    }
                    o   Consider adding an explosion or crash animation upon collision.

                  Step 9: Restarting the Game

                     Restart When Restart Button is Clicked:

                    if(mousePressedOver(restart)){

                      car1.velocityY = 10;

                      car2.velocityY = 10;

                      restart.visible = false;
                    }

                    o   The game resumes when the restart button is clicked.

                    o   Reset the player’s car position for a full restart experience.

                  Optional Features:
                     Scoring System: Track time survived for points.

                     Dynamic Difficulty: Increase enemy car speed every 20 seconds.

                     Power-Ups: Add items that slow down enemy cars or boost player speed.

                     Background Changes: Cycle through different road backgrounds during gameplay.
                  Happy Coding!




















                  148   Premium Edition-V
   145   146   147   148   149   150   151   152   153   154   155