|
@@ -6,7 +6,7 @@
|
6
|
6
|
|
7
|
7
|
[Verano 2016 - Ive - Coralys]
|
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 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.
|
10
|
10
|
|
11
|
11
|
## Objectives:
|
12
|
12
|
|
|
@@ -20,7 +20,7 @@ Before arriving at the laboratory you should have:
|
20
|
20
|
|
21
|
21
|
1. Reviewed the following concepts:
|
22
|
22
|
|
23
|
|
- a. Logical operators
|
|
23
|
+ a. logical operators
|
24
|
24
|
|
25
|
25
|
b. if, else, else if, switch
|
26
|
26
|
|
|
@@ -62,11 +62,12 @@ In this laboratory experience, you will practice the use of mathematical express
|
62
|
62
|
|
63
|
63
|
Your task is to complete the design of the game application.
|
64
|
64
|
|
65
|
|
-### Exercise 1 - Familiarize yourself with the pre-defined functions
|
|
65
|
+
|
|
66
|
+### Exercise 1 - Familiarize Yourself with the Pre-defined Functions
|
66
|
67
|
|
67
|
68
|
The first step in this laboratory experience is to familiarize yourself with the pre-defined functions (methods) in the code. You will invoke some of these functions in the code to detect the collisions.
|
68
|
69
|
|
69
|
|
-#### Instructions:
|
|
70
|
+#### Instructions
|
70
|
71
|
|
71
|
72
|
1. Load the project `CarScrollingGame` into `QtCreator`. There are two ways to do this:
|
72
|
73
|
|
|
@@ -94,7 +95,7 @@ The first step in this laboratory experience is to familiarize yourself with the
|
94
|
95
|
|
95
|
96
|
There isn't a `getXCar()` method because the car does not move on the $$X$$ axis.
|
96
|
97
|
|
97
|
|
-### Exercise 2 - Complete the function to change the game's track.
|
|
98
|
+### Exercise 2 - Complete the Function to Change the Game's Track.
|
98
|
99
|
|
99
|
100
|
In this exercise you will use the C++ condition structure called **switch** to change the attributes of the track. You will complete the `setTrack` method that can be found in the `work.cpp` file. This method changes the environment of the track depending on the value of `track_type` that is given as a parameter.
|
100
|
101
|
|
|
@@ -114,7 +115,7 @@ The `setTrackPixmap()` function is already defined and receives a variable of ty
|
114
|
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
|
117
|
|
117
|
|
-#### Instructions:
|
|
118
|
+#### Instructions
|
118
|
119
|
|
119
|
120
|
To complete the `setTrack()` function:
|
120
|
121
|
|
|
@@ -129,7 +130,7 @@ To complete the `setTrack()` function:
|
129
|
130
|
|
130
|
131
|
With the options that have two possible obstacles use `rand() % 2` to randomly select between an obstacle or the other.
|
131
|
132
|
|
132
|
|
-### Exercise 3: Complete the function for collision with obstacles
|
|
133
|
+### Exercise 3 - Complete the Function for Collision with Obstacles
|
133
|
134
|
|
134
|
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.
|
135
|
136
|
|
|
@@ -146,11 +147,11 @@ If a collision is detected, the function returns `true`, and if not the function
|
146
|
147
|
---
|
147
|
148
|
|
148
|
149
|
|
149
|
|
-### Exercise 4: Complete the function for collision with flags
|
|
150
|
+### Exercise 4 - Complete the Function for Collision with Flags
|
150
|
151
|
|
151
|
152
|
In this exercise you will complete the `flagCollision` 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 flag. This function is very similiar 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.
|
152
|
153
|
|
153
|
|
-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 `flag.hide()` function to create the illusion that the flag was picked up during the collision.
|
|
154
|
+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 `flag.hide()` function to create the illusion that the flag was picked up during the collision.
|
154
|
155
|
|
155
|
156
|
---
|
156
|
157
|
|
|
@@ -158,7 +159,7 @@ In this case if a collision is detected, the game's score should increase by 30
|
158
|
159
|
|
159
|
160
|
### Deliverables
|
160
|
161
|
|
161
|
|
-Use "Deliverable" in Moodle to upload the `work.cpp` file that contains the function calls and changes you made to the program. Remember to use good programming techniques by including the name of the programmers involved and documenting your program.
|
|
162
|
+Use "Deliverable" in Moodle to upload the `work.cpp` file that contains the function calls and changes you made to the program. Remember to use good programming techniques, include the name of the programmers involved and document your program.
|
162
|
163
|
|
163
|
164
|
---
|
164
|
165
|
|
|
@@ -166,4 +167,3 @@ Use "Deliverable" in Moodle to upload the `work.cpp` file that contains the func
|
166
|
167
|
|
167
|
168
|
### References
|
168
|
169
|
[1] Dave Feinberg, http://nifty.stanford.edu/2011/feinberg-generic-scrolling-game/
|
169
|
|
-
|