Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ 1) 2) bool game::obstacleColl(Obstacle &obs, Car &car) Ouse of undeclared identifier 'game' Il Complete the function using the selection structure iffelse // to detect

c++
image text in transcribed
1)
image text in transcribed
2)
image text in transcribed
image text in transcribed
bool game::obstacleColl(Obstacle &obs, Car &car) Ouse of undeclared identifier 'game' Il Complete the function using the selection structure iffelse // to detect a collision between the obstacle and the car. 1/ Recall from the instructions that the car does not move in the 1/ X axis and that the fix X asix is stored in CARX. // OBSTACLERANGE contains the range from the obstacle center to 1/ each side. I } void game:: flagColFlag &flag, Car (car) { Ouse of undeclared identifier 'game' H Complete the function using the selection structure if/else 1/ to detect a collision between the flag and the car. 1 Recall from the instructions that the car does not move in the H7 X axis and that the fix X asix is stored in CARX. /FLAGRANGE contains the range from the flag center to 7/ each side. // If there is a collision set the score to 30 more points 1/ and hide the flag. The function receives an object of the Obstacle class and another object of the Car class, and should detect if there is a collision or not between the car and the obstacle. The function returns true if there is a collision between the car and an obstacle, and false if there is no collision. To detect the collision, the function should ask for the coordinates of the obstacle and the car's coordinate. Remember that the car does not move on the axis, since that coordinate is fixed and stored in a constant variable called CARX The collision occurs if the obstacle has the same coordinate, and is a certain distance above and below the car's coordinate as shown in Figure 1. The range of the distance of the obstacle's center upwards and downwards is stored in the variable called OBSTACLE RANGE If a collision is detected, the function returns true and if not the function should return false function receives an object of the Obstacle class and another object of the Car class, and should detect if there is a collision or not between the car and the flag. This function is very similar to the function in Exercise 3, except that the function does not return a value. The actions that occur when a collision is detected are done inside the function. In this case if a collision is detected, the game's score should increase by 30 points using the setScore function, and the flags should be hidden using the flog hide() function to create the illusion that the flag was picked up during the collision obtstacle.h y obstacle.cpp : contains the definition of the class Obstacle, the methods of the class and their declarations. o play.h y play.cpp contains the definition of the class Play, the methods of the class and their declarations. Familiarize yourself with the methods in these files. Emphasize the following methods: Car::getycar() : Returns the {% math %}Y{% endmath %} coordinate of the car's position on the track o Flag::getXFlag() : Returns the % math %}X{% endmath %) coordinate of the flag's position on the track Flag::getYFlag : Returns the % math %}Y{% endmath %) coordinate of the flag's position on the track. Flag::hide(): Hides the flag. o Obstacle::getxobstacle(): Returns the {% math %}X{% endmath %) coordinate of the obstacle's position on the track. o Obstacle::getYobstacle(): Returns the {% math %}Y{% endmath %} coordinate of the obstacle's position on the track. o Play::setScore(n): Receives an integer number and adds it to the game's total score. There isn't a getxCar() method because the car does not move on the {% math %}X{% endmath %) axis

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions