|
@@ -6,7 +6,7 @@
|
6
|
6
|
|
7
|
7
|
|
8
|
8
|
|
9
|
|
-In almost every instance in which we want to solve a problem, we select among are one or more options that depend on whether certain conditions are met. Computer programs are built to solve problems, therefore they should have a structure that allows them to make decisions and select alternatives. In C++, selections are structured using `if`, `else`, `else if` or `switch`. Relational expressions and logical operators are common when handling selection structures. In this laboratory experience, you will practice the use of certain selection structures to complete the design of a car and an obstacle collision game application.
|
|
9
|
+In almost every instance in which we want to solve a problem, we select between different options depending on whether certain conditions are met. Computer programs are built to solve problems, therefore they should have a structure that allows them to make decisions and select alternatives. In C++, selections are structured using `if`, `else`, `else if` or `switch`. Relational expressions and logical operators are common when handling selection structures. In this laboratory experience, you will practice the use of certain selection structures to complete the design of a car and an obstacle collision game application.
|
10
|
10
|
|
11
|
11
|
## Objectives:
|
12
|
12
|
|
|
@@ -113,7 +113,7 @@ The track's attributes that can be changed are:
|
113
|
113
|
|
114
|
114
|
The `setTrackPixmap()` function is already defined and receives a variable of type `Track` that can be one of the following: **play::DAY**, **play::NIGHT**, **play::BEACH**, **play::CANDYLAND**.
|
115
|
115
|
|
116
|
|
-The `setObstaclesPixmap()` function is already defined and receives a variable of type `string` that can be one of the following: **"hole"**, **"cone"**, **"it"**, **"zombie"**, **"spongebob"**, **"patric"**, **"monster"**.
|
|
116
|
+The `setObstaclesPixmap()` function is already defined and receives a variable of type `string` that can be one of the following: **"hole"**, **"cone"**, **"it"**, **"zombie"**, **"spongebob"**, **"patrick"**, **"monster"**.
|
117
|
117
|
|
118
|
118
|
#### Instructions
|
119
|
119
|
|
|
@@ -125,7 +125,7 @@ To complete the `setTrack()` function:
|
125
|
125
|
|
126
|
126
|
* `play::DAY` - the obstacles are of type "hole" or "cone"
|
127
|
127
|
* `play::NIGHT` - the obstacles are of type "it" or "zombie"
|
128
|
|
- * `play::BEACH` - the obstacles are of type "spongebob" or "patric"
|
|
128
|
+ * `play::BEACH` - the obstacles are of type "spongebob" or "patrick"
|
129
|
129
|
* `play::CANDYLAND` - the obstacles are of type "monster"
|
130
|
130
|
|
131
|
131
|
With the options that have two possible obstacles use `rand() % 2` to randomly select between an obstacle or the other.
|
|
@@ -134,7 +134,7 @@ To complete the `setTrack()` function:
|
134
|
134
|
|
135
|
135
|
In this exercise you will complete the `obstacleCollision` method that can be found in the `work.cpp` file. 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.
|
136
|
136
|
|
137
|
|
-To detect the collision, the function should ask for the coordinates of the obstacle and the car's $$Y$$ coordinate. Remember that the car does not move on the $$X$$ axis, since that coordinate is fixed and stored in a constant variable called `CARX`. The collision occurs if the obstacle has the same $$X$$ coordinate, and is a certain distance above and below the car's $$Y$$ coordinate as shown in Figure 1. The range of the distance of the car's center upwards and downwards is stored in the variable called `OBSTACLERANGE`.
|
|
137
|
+To detect the collision, the function should ask for the coordinates of the obstacle and the car's $$Y$$ coordinate. Remember that the car does not move on the $$X$$ axis, since that coordinate is fixed and stored in a constant variable called `CARX`. The collision occurs if the obstacle has the same $$X$$ coordinate, and is a certain distance above and below the car's $$Y$$ 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 `OBSTACLERANGE`.
|
138
|
138
|
|
139
|
139
|
If a collision is detected, the function returns `true`, and if not the function should return `false`.
|
140
|
140
|
|