Browse Source

Splitted READMEs

root 7 years ago
parent
commit
ac0bafe687
3 changed files with 320 additions and 320 deletions
  1. 154
    0
      README-en.md
  2. 164
    0
      README-es.md
  3. 2
    320
      README.md

+ 154
- 0
README-en.md View File

@@ -0,0 +1,154 @@
1
+
2
+# Selection Structures - Car Scrolling Game
3
+
4
+![main1.png](images/main1.png)
5
+![main2.png](images/main2.png)
6
+![main3.png](images/main3.png)
7
+
8
+When we want to solve a problem, most of the time there is one or more options that depend on certain conditions being met. Computer programs are written to solve problems, and should therefore have a structure that allows it to make decisions. In C++ the decision (or conditional) instructions are structured using if, else, else if or switch. These structures usually involve the use of relational expressions and logical operations. In today's laboratory experience you will practice the use of certain decision structures to complete the design of a car and obstacle collision game application. 
9
+
10
+##Objectives:
11
+
12
+1. Use relational expressions and select appropriate logical operators to make decisions.
13
+2. Apply decision structures.
14
+
15
+
16
+## Pre-Lab:
17
+
18
+Before arriving at the laboratory you should have:
19
+
20
+1. Reviewed the following concepts:
21
+
22
+   a. logical operators
23
+
24
+   b. if, else, else if, switch
25
+
26
+2. Studied the concepts and instructions for the laboratory session.
27
+
28
+
29
+---
30
+
31
+---
32
+
33
+
34
+##Car Scrolling Game
35
+
36
+Collision games consist of maneuvering an object in order to dodge incoming objects to avoid possible collision. The collision can lower the player's score, or stop the game. Sometimes, colliding with certain objects may increase the player's score. In the game from today's laboratory experience, the object the player controls is a car, the objects that cause the game to stop are pines, holes, among others, and the objects that add points to the score are flags.
37
+
38
+The controls for this game are simple: the up arrow moves the car up and the down arrow moves the car down. During gameplay, the game simulates the movement of the car towards the right using a simple method: moving the background with its obstacles and flags towards the left while the car stays in the same place. The player can move the car up or down to dodge obstacles and to capture the flags. If the car collides with an obstacle, the game ends. The player can continue by pressing the `Retry` button. 
39
+
40
+
41
+---
42
+
43
+---
44
+
45
+
46
+## Laboratory Session:
47
+
48
+In this laboratory experience you will practice the use of mathematical expressions and condition structures to implement the car's collision detection against obstacles and flags.
49
+
50
+Your task is to complete the design of the game application.
51
+
52
+### Exercise 1: Familiarize yourself with the pre-defined functions
53
+
54
+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 you will complete to detect the collisions. 
55
+
56
+**Instructions**
57
+
58
+1. Download the `Conditionals-CarScrollingGame` folder from `Bitbucket` using the terminal, moving to the directory `Documents/eip`, and writing the command `git clone http://bitbucket.org/eip-uprrp/conditionals-carscrollinggame`.
59
+
60
+2. Load the Qt project `CarScrollingGame` by double clicking the `CarScrollingGame.pro` file found within the `Documents/eip/Conditionals-CarScrollingGame` directory on your computer.
61
+
62
+3. Configure the project. The project consists of various files. **You will only write code on the file** `work.cpp`**. You should not change anything on the other files.**
63
+
64
+4. You are going to need a few methods defined in the following files to create your code.
65
+
66
+   * `car.h` y `car.cpp`: contains the definition of the class `Car`, the methods of the class and their declarations.
67
+   *  `flag.h` y `flag.cpp`: contains the definition of the class `Flag`, the methods of the class and their declarations.
68
+   *  `obtstacle.h` y `obstacle.cpp`: contains the definition of the class `Obstacle`, the methods of the class and their declarations.
69
+   * `play.h` y `play.cpp`: contains the definition of the class `Play`, the methods of the class and their declarations.
70
+
71
+Familiarize yourself with the methods in these files. Emphasize the following methods:
72
+
73
+   * `Car::getYCar()`: Returns the $$Y$$ coordinate of the car's position on the track.
74
+   * `Flag::getXFlag()`: Returns the $$X$$ coordinate of the flag's position on the track.
75
+   * `Flag::getYFlag()`: Returns the $$Y$$ coordinate of the flag's position on the track.
76
+   * `Flag::hide()`: Hides the flag.
77
+   * `Obstacle::getXObstacle()`: Returns the $$X$$ coordinate of the obstacle's position on the track.
78
+   * `Obstacle::getYObstacle()`: Returns the $$Y$$ coordinate of the obstacle's position on the track.
79
+   * `Play::setScore(n)`: Receives an integer number and adds it to the game's total score.
80
+    
81
+There isn't a `getXCar()` method because the car does not move on the $$X$$ axis.
82
+
83
+### Exercise 2: Complete the function to change the game's track.
84
+
85
+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 parameter.
86
+
87
+The method `setTrack` receives a value of type `Track` that can be:
88
+
89
+   * `play::DAY` - for a day track
90
+   * `play::NIGHT` - for a night track
91
+   * `play::BEACH` - for a beach track
92
+   * `play::CANDYLAND` - for a candy track
93
+
94
+The track's attributes that can be changed are:
95
+
96
+   * the image on the track using the function `setTrackPixmap()`
97
+   * the image of the obstacles using the function `setObstaclesPixmap()`
98
+
99
+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**).
100
+
101
+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"**).
102
+
103
+**Instructions**
104
+
105
+To complete the `setTrack()` function: 
106
+
107
+1. Change the image on the track according to the `Track` value received.
108
+
109
+2. Change the image of the obstacles using the `switch` selection structure such that the obstacles change according to the value received by `setTrack()`. If the type of the track that is received is:
110
+
111
+    * `play::DAY` - the obstacles are of type "hole" or "cone"  
112
+    * `play::NIGHT` - the obstacles are of type "it" or "zombie"
113
+    * `play::BEACH` - the obstacles are of type "spongebob" or "patric"
114
+    * `play::CANDYLAND` - the obstacles are of type "monster"
115
+
116
+    With the options that have two possible obstacles use `rand() % 2` to randomly select between an obstacle or the other.
117
+
118
+### Exercise 3: Complete the function for collision with obstacles
119
+
120
+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.
121
+
122
+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`.
123
+
124
+If a collision is detected, the function returns `true`, and if not the function should return `false`.
125
+
126
+---
127
+
128
+![ColisionC.png](images/ColisionC.png)
129
+
130
+**Figure 1.** The image shows the coordinates $$(CARX,Y)$$ that the obstacle should have for a collision to occur.
131
+
132
+---
133
+
134
+
135
+### Exercise 4: Complete the function for collision with flags
136
+
137
+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.
138
+
139
+In this case if a collision is detected, the game's score should increase by 30 points using the `setScore` function and hide the flag using the `flag.hide()` function to create the illusion that the flag was picked up during the collision.
140
+
141
+---
142
+
143
+---
144
+
145
+### Deliverables
146
+
147
+Use "Deliverables" in Moodle to hand in 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.
148
+
149
+---
150
+
151
+---
152
+
153
+### References
154
+[1] Dave Feinberg, http://nifty.stanford.edu/2011/feinberg-generic-scrolling-game/

+ 164
- 0
README-es.md View File

@@ -0,0 +1,164 @@
1
+
2
+#Estructuras de decisión - Juego de desplazamiento de carro
3
+
4
+![main1.png](images/main1.png)
5
+![main2.png](images/main2.png)
6
+![main3.png](images/main3.png)
7
+
8
+En casi todas las instancias en que queremos resolver un problema hay una o más opciones que dependen de si se cumplen o no ciertas condiciones. Los programas de computadoras se construyen para resolver problemas y, por lo tanto, deben tener una estructura que permita tomar decisiones. En C++ las instrucciones de decisión (o condicionales) se estructuran utilizando if, else, else if o switch. Muchas veces el uso de estas estructuras también envuelve el uso de expresiones de relación y operadores lógicos. En la experiencia de laboratorio de hoy practicarás el uso de algunas estructuras de decisión completando el diseño de una aplicación de juego de colisiones de carros con obstáculos en una pista.
9
+
10
+
11
+
12
+##Objetivos:
13
+
14
+1.  Utilizar expresiones relacionales y seleccionar operadores lógicos adecuados para la toma de decisiones.
15
+2. Aplicar estructuras de decisión.
16
+
17
+
18
+## Pre-Lab:
19
+
20
+Antes de llegar al laboratorio debes:
21
+
22
+1. Haber repasado los siguientes conceptos:
23
+    a. operadores lógicos
24
+    b. if, else, else if, switch
25
+
26
+2. Haber estudiado los conceptos e instrucciones para la sesión de laboratorio.
27
+
28
+---
29
+
30
+---
31
+
32
+
33
+## Juego de desplazamiento de carro
34
+
35
+Los juegos de colisiones consisten de manejar un objeto esquivando o provocando la posible colisión contra otros objetos. La colisión puede descontar puntos o detener el juego. También hay colisiones con algunos objetos que acumulan puntos.  En el juego de esta experiencia de laboratorio el objeto que se maneja es un carrito, los objetos que causan que el juego se detenga son pinos, agujeros, entre otros, y los objetos que suman puntos son las banderas.
36
+
37
+Los controles del juego son bien sencillos: la tecla con la flecha hacia arriba desplaza el carro hacia arriba y la tecla con la flecha hacia abajo desplaza el carro hacia abajo.  Al jugar, el juego da la sensación de que el carro está en movimiento hacia la derecha usando un método muy simple: desplazando el fondo con sus obsteaculos y banderas hacia la izquierda mientras el carro permanece en el mismo lugar. El jugador puede desplazar el carro hacia arriba o hacia abajo  para esquivar los obstáculos y para capturar las banderas.  De haber una colisión con un obstáculo el juego se detiene.  El jugador puede continuar marcando el botón de `Retry`.
38
+
39
+---
40
+
41
+---
42
+
43
+
44
+## Sesión de laboratorio:
45
+
46
+En esta experiencia de laboratorio practicarás el uso de expresiones matemáticas y estructuras condicionales para implementar la detección de colisiones del carrito contra los obstáculos y contra las banderas.  
47
+
48
+Tu tarea es completar el diseño de la aplicación del juego. 
49
+
50
+
51
+### Ejercicio 1: Familiarizate con las funciones pre-definidas. 
52
+
53
+El primer paso en esta experiencia de laboratorio es familiarizarte con las funciones (métodos) pre-definidas en el código.  Invocarás algunas de estas funciones en el código que completarás para detectar las colisiones.  
54
+
55
+**Instrucciones**
56
+
57
+1. Descarga la carpeta `Conditionals-CarScrollingGame` de `Bitbucket` usando un terminal, moviéndote al directorio `Documents/eip`, y escribiendo el comando `git clone http://bitbucket.org/eip-uprrp/conditionals-carscrollinggame`.
58
+
59
+2. Carga a Qt creator el proyecto `CarScrollingGame`  haciendo doble "click" en el archivo `CarScrollingGame.pro` que se encuentra en la carpeta  `Documents/eip/Conditionals-CarScrollingGame` de tu computadora. 
60
+
61
+3. Configura el proyecto. El proyecto consiste de varios archivos. **Solo escribirás código en el archivo** `work.cpp`**. No debes cambiar nada en los demás archivos.** 
62
+
63
+4. Vas a necesitar algunos de los métodos definidos en los siguientes  archivos para crear tu código. 
64
+
65
+    * `car.h` y `car.cpp`: contienen la definición de la clase `Car`, los métodos de esta clase y sus declaraciones.
66
+    *  `flag.h` y `flag.cpp`: contienen la definición de la clase `Flag`, los métodos de esta clase y sus declaraciones.
67
+    *  `obtstacle.h` y `obstacle.cpp`: contienen la definición de la clase `Obstacle`, los métodos de esta clase y sus declaraciones.
68
+    * `play.h` y `play.cpp`: contienen la definición de la clase `Play`, los métodos de esta clase y sus declaraciones.
69
+    
70
+
71
+    Familiarízate con los métodos en estos archivos. Pon énfazis en los siguientes métodos:
72
+
73
+    * `Car::getYCar()`: Devuelve la coordenada en $Y$ de la posición del carro en la pista.
74
+    * `Flag::getXFlag()`: Devuelve la coordenada en $X$ de la posición de la bandera en la pista.
75
+    * `Flag::getYFlag()`: Devuelve la coordenada en $Y$ de la posición de la bandera en la pista.
76
+    * `Flag::hide()`: Esconde la bandera.  Desaparece de la pista.
77
+    * `Obstacle::getXObstacle()`: Devuelve la coordenada en $X$ de la  posición del obstáculo en la pista.
78
+    * `Obstacle::getYObstacle()`: Devuelve la coordenada en $Y$ de la posición del obstáculo en la pista.
79
+    * `Play::setScore(n)`: Recibe un número entero y lo suma a la puntuación del juego.
80
+    
81
+
82
+    Nota que no hay método `getXCar()` porque el  carro no se desplaza en el eje de $X$.  
83
+
84
+### Ejercicio 2: Completar la función para cambiar la pista del juego.
85
+
86
+En este ejercicio utilizarás la estructura de condición de C++ **switch** para cambiar los atributos de la pista. Completarás el método `setTrack` que se encuentra en el archivo `work.cpp`. Este método cambia el ambiente de la pista del juego dependiendo del valor que recibe el parámetro `track_type`.  
87
+
88
+El método `setTrack`  recibe un valor de tipo `Track` que puede ser:
89
+    
90
+    * play::DAY - para la pista de día
91
+    * play::NIGHT - para la pista de la noche
92
+    * play::BEACH - para la pista de la playa
93
+    * play::CANDYLAND - para la pista de dulces
94
+
95
+Los atributos de la pista que se pueden cambiar son: 
96
+
97
+    * la imagen de la pista usando la función `setTrackPixmap()`
98
+    * la imagen de los obstáculos usando la función `setObstaclesPixmap()`
99
+
100
+La función `setTrackPixmap(Track)` ya está definida y recibe una variable de tipo `Track` que puede ser un valor entre (**play::DAY**, **play::NIGHT**, **play::BEACH**, **play::CANDYLAND**).
101
+
102
+La función `setObstaclePixmap(string)`  ya está definida y recibe una variable de tipo `string` que puede ser un valor entre (**"hole"**, **"cone"**, **"it"**, **"zombie"**, **"spongebob"**, **"patric"**, **"monster"**).
103
+
104
+**Instrucciones**
105
+
106
+Para completar la función `setTrack()`:
107
+
108
+1. Cambia la imagen de la pista de acuerdo al valor `Track` recibido.
109
+
110
+2. Cambia la imagen de los obstáculos utilizando la estructura de selección `switch` de modo que los obstáculos cambien de acuerdo al valor recibido por `setTrack()`. Si el tipo de pista que se recibe es:
111
+
112
+    * `play::DAY` - los obstáculos sean de tipo "hole" o "cone", si el  
113
+    * `play::NIGHT` - los obstáculos sean de tipo "it" o "zombie"
114
+    * `play::BEACH` - los obstáculos sean de tipo "spongebob" o "patric"
115
+    * `play::CANDYLAND` - los obstáculos sean de tipo "monster"
116
+
117
+    En las opciones que tengan dos posibles obstáculos utilza  `rand() % 2`  para escoger aleatoriamente entre un obstáculo u otro. 
118
+
119
+
120
+### Ejercicio 3: Completar la función para colisiones con obstáculos. 
121
+
122
+En este ejercicio completarás el método `obstacleCollision` que se encuentra en el archivo `work.cpp`. La función recibe un objeto de clase `Obstacle` y otro objeto de clase `Car` y debe detectar si hay colisión o no entre el carro y el obstáculo. La función devuelve cierto si hay colisión entre el carro y un obstáculo y falso si no hay colisión.
123
+
124
+Para detectar la colisión la función debe solicitar las coordenadas del obstáculo y la coordenada en $Y$ del carro.  Recuerda que el carro no se desplaza en la coordenada $X$, esa coordenada es fija y está guardada en la variable constante `CARX`.  La colisión ocurre si el obstáculo tiene la misma coordenada en $X$ y está a cierta distancia hacia arriba y abajo de la coordenada en $Y$ como muestra la Figura 1. El rango de distancia del centro del carro hacia arriba y abajo se encuentra guardada en la variable constante `OBSTACLERANGE`.
125
+
126
+Si se detecta una colisión la función debe devolver `true` y si no debe devolver `false`.
127
+
128
+---
129
+
130
+![ColisionC.png](images/ColisionC.png)
131
+
132
+**Figura 1.** La imagen muestra las coordenadas $(CARX,Y)$ que debe tener el obstáculo para que ocurra una colisión.
133
+
134
+---
135
+
136
+### Ejercicio 4: Completar la función para colisiones con banderas.
137
+
138
+En este ejercicio completarás el método `flagCollision` que se encuentra en el archivo `work.cpp`. La función recibe un objeto de clase `Obstacle` y otro objeto de clase `Flag` y debe detectar si hay colisión o no entre el carro y la bandera. Esta función es bien similar a la función del Ejericio 3, excepto que esta función no devuelve valor.  Las acciones que ocurren cuando se detecta la colisión se van a tomar dentro de la función.
139
+
140
+En este caso si se detecta una colisión, se debe aumentar la puntuación del juego 30 puntos utilizando la función `setScore` y esconder la bandera  utilizando la función `flag.hide()` para crear la ilusión de que se recogió la bandera en la colisión.
141
+
142
+
143
+---
144
+
145
+---
146
+
147
+## Entregas
148
+
149
+Utiliza "Entrega" en Moodle para entregar el archivo `work.cpp` que contiene el código con las soluciones para escoger la pista y detectar las colisiones. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
150
+
151
+
152
+
153
+---
154
+
155
+---
156
+
157
+## Referencias
158
+
159
+[1] Dave Feinberg, http://nifty.stanford.edu/2011/feinberg-generic-scrolling-game/
160
+
161
+    
162
+
163
+---
164
+

+ 2
- 320
README.md View File

@@ -1,320 +1,2 @@
1
-[English](#markdown-header-selection-structures-car-scrolling-game) | [Español](#markdown-header-estructuras-de-seleccion-juego-de-desplazamiento-de-carro)
2
-
3
-#Estructuras de decisión - Juego de desplazamiento de carro
4
-
5
-![main1.png](images/main1.png)
6
-![main2.png](images/main2.png)
7
-![main3.png](images/main3.png)
8
-
9
-En casi todas las instancias en que queremos resolver un problema hay una o más opciones que dependen de si se cumplen o no ciertas condiciones. Los programas de computadoras se construyen para resolver problemas y, por lo tanto, deben tener una estructura que permita tomar decisiones. En C++ las instrucciones de decisión (o condicionales) se estructuran utilizando if, else, else if o switch. Muchas veces el uso de estas estructuras también envuelve el uso de expresiones de relación y operadores lógicos. En la experiencia de laboratorio de hoy practicarás el uso de algunas estructuras de decisión completando el diseño de una aplicación de juego de colisiones de carros con obstáculos en una pista.
10
-
11
-
12
-
13
-##Objetivos:
14
-
15
-1.  Utilizar expresiones relacionales y seleccionar operadores lógicos adecuados para la toma de decisiones.
16
-2. Aplicar estructuras de decisión.
17
-
18
-
19
-## Pre-Lab:
20
-
21
-Antes de llegar al laboratorio debes:
22
-
23
-1. Haber repasado los siguientes conceptos:
24
-    a. operadores lógicos
25
-    b. if, else, else if, switch
26
-
27
-2. Haber estudiado los conceptos e instrucciones para la sesión de laboratorio.
28
-
29
----
30
-
31
----
32
-
33
-
34
-## Juego de desplazamiento de carro
35
-
36
-Los juegos de colisiones consisten de manejar un objeto esquivando o provocando la posible colisión contra otros objetos. La colisión puede descontar puntos o detener el juego. También hay colisiones con algunos objetos que acumulan puntos.  En el juego de esta experiencia de laboratorio el objeto que se maneja es un carrito, los objetos que causan que el juego se detenga son pinos, agujeros, entre otros, y los objetos que suman puntos son las banderas.
37
-
38
-Los controles del juego son bien sencillos: la tecla con la flecha hacia arriba desplaza el carro hacia arriba y la tecla con la flecha hacia abajo desplaza el carro hacia abajo.  Al jugar, el juego da la sensación de que el carro está en movimiento hacia la derecha usando un método muy simple: desplazando el fondo con sus obsteaculos y banderas hacia la izquierda mientras el carro permanece en el mismo lugar. El jugador puede desplazar el carro hacia arriba o hacia abajo  para esquivar los obstáculos y para capturar las banderas.  De haber una colisión con un obstáculo el juego se detiene.  El jugador puede continuar marcando el botón de `Retry`.
39
-
40
----
41
-
42
----
43
-
44
-
45
-## Sesión de laboratorio:
46
-
47
-En esta experiencia de laboratorio practicarás el uso de expresiones matemáticas y estructuras condicionales para implementar la detección de colisiones del carrito contra los obstáculos y contra las banderas.  
48
-
49
-Tu tarea es completar el diseño de la aplicación del juego. 
50
-
51
-
52
-### Ejercicio 1: Familiarizate con las funciones pre-definidas. 
53
-
54
-El primer paso en esta experiencia de laboratorio es familiarizarte con las funciones (métodos) pre-definidas en el código.  Invocarás algunas de estas funciones en el código que completarás para detectar las colisiones.  
55
-
56
-**Instrucciones**
57
-
58
-1. Descarga la carpeta `Conditionals-CarScrollingGame` de `Bitbucket` usando un terminal, moviéndote al directorio `Documents/eip`, y escribiendo el comando `git clone http://bitbucket.org/eip-uprrp/conditionals-carscrollinggame`.
59
-
60
-2. Carga a Qt creator el proyecto `CarScrollingGame`  haciendo doble "click" en el archivo `CarScrollingGame.pro` que se encuentra en la carpeta  `Documents/eip/Conditionals-CarScrollingGame` de tu computadora. 
61
-
62
-3. Configura el proyecto. El proyecto consiste de varios archivos. **Solo escribirás código en el archivo** `work.cpp`**. No debes cambiar nada en los demás archivos.** 
63
-
64
-4. Vas a necesitar algunos de los métodos definidos en los siguientes  archivos para crear tu código. 
65
-
66
-    * `car.h` y `car.cpp`: contienen la definición de la clase `Car`, los métodos de esta clase y sus declaraciones.
67
-    *  `flag.h` y `flag.cpp`: contienen la definición de la clase `Flag`, los métodos de esta clase y sus declaraciones.
68
-    *  `obtstacle.h` y `obstacle.cpp`: contienen la definición de la clase `Obstacle`, los métodos de esta clase y sus declaraciones.
69
-    * `play.h` y `play.cpp`: contienen la definición de la clase `Play`, los métodos de esta clase y sus declaraciones.
70
-    
71
-
72
-    Familiarízate con los métodos en estos archivos. Pon énfazis en los siguientes métodos:
73
-
74
-    * `Car::getYCar()`: Devuelve la coordenada en $Y$ de la posición del carro en la pista.
75
-    * `Flag::getXFlag()`: Devuelve la coordenada en $X$ de la posición de la bandera en la pista.
76
-    * `Flag::getYFlag()`: Devuelve la coordenada en $Y$ de la posición de la bandera en la pista.
77
-    * `Flag::hide()`: Esconde la bandera.  Desaparece de la pista.
78
-    * `Obstacle::getXObstacle()`: Devuelve la coordenada en $X$ de la  posición del obstáculo en la pista.
79
-    * `Obstacle::getYObstacle()`: Devuelve la coordenada en $Y$ de la posición del obstáculo en la pista.
80
-    * `Play::setScore(n)`: Recibe un número entero y lo suma a la puntuación del juego.
81
-    
82
-
83
-    Nota que no hay método `getXCar()` porque el  carro no se desplaza en el eje de $X$.  
84
-
85
-### Ejercicio 2: Completar la función para cambiar la pista del juego.
86
-
87
-En este ejercicio utilizarás la estructura de condición de C++ **switch** para cambiar los atributos de la pista. Completarás el método `setTrack` que se encuentra en el archivo `work.cpp`. Este método cambia el ambiente de la pista del juego dependiendo del valor que recibe el parámetro `track_type`.  
88
-
89
-El método `setTrack`  recibe un valor de tipo `Track` que puede ser:
90
-    
91
-    * play::DAY - para la pista de día
92
-    * play::NIGHT - para la pista de la noche
93
-    * play::BEACH - para la pista de la playa
94
-    * play::CANDYLAND - para la pista de dulces
95
-
96
-Los atributos de la pista que se pueden cambiar son: 
97
-
98
-    * la imagen de la pista usando la función `setTrackPixmap()`
99
-    * la imagen de los obstáculos usando la función `setObstaclesPixmap()`
100
-
101
-La función `setTrackPixmap(Track)` ya está definida y recibe una variable de tipo `Track` que puede ser un valor entre (**play::DAY**, **play::NIGHT**, **play::BEACH**, **play::CANDYLAND**).
102
-
103
-La función `setObstaclePixmap(string)`  ya está definida y recibe una variable de tipo `string` que puede ser un valor entre (**"hole"**, **"cone"**, **"it"**, **"zombie"**, **"spongebob"**, **"patric"**, **"monster"**).
104
-
105
-**Instrucciones**
106
-
107
-Para completar la función `setTrack()`:
108
-
109
-1. Cambia la imagen de la pista de acuerdo al valor `Track` recibido.
110
-
111
-2. Cambia la imagen de los obstáculos utilizando la estructura de selección `switch` de modo que los obstáculos cambien de acuerdo al valor recibido por `setTrack()`. Si el tipo de pista que se recibe es:
112
-
113
-    * `play::DAY` - los obstáculos sean de tipo "hole" o "cone", si el  
114
-    * `play::NIGHT` - los obstáculos sean de tipo "it" o "zombie"
115
-    * `play::BEACH` - los obstáculos sean de tipo "spongebob" o "patric"
116
-    * `play::CANDYLAND` - los obstáculos sean de tipo "monster"
117
-
118
-    En las opciones que tengan dos posibles obstáculos utilza  `rand() % 2`  para escoger aleatoriamente entre un obstáculo u otro. 
119
-
120
-
121
-### Ejercicio 3: Completar la función para colisiones con obstáculos. 
122
-
123
-En este ejercicio completarás el método `obstacleCollision` que se encuentra en el archivo `work.cpp`. La función recibe un objeto de clase `Obstacle` y otro objeto de clase `Car` y debe detectar si hay colisión o no entre el carro y el obstáculo. La función devuelve cierto si hay colisión entre el carro y un obstáculo y falso si no hay colisión.
124
-
125
-Para detectar la colisión la función debe solicitar las coordenadas del obstáculo y la coordenada en $Y$ del carro.  Recuerda que el carro no se desplaza en la coordenada $X$, esa coordenada es fija y está guardada en la variable constante `CARX`.  La colisión ocurre si el obstáculo tiene la misma coordenada en $X$ y está a cierta distancia hacia arriba y abajo de la coordenada en $Y$ como muestra la Figura 1. El rango de distancia del centro del carro hacia arriba y abajo se encuentra guardada en la variable constante `OBSTACLERANGE`.
126
-
127
-Si se detecta una colisión la función debe devolver `true` y si no debe devolver `false`.
128
-
129
----
130
-
131
-![ColisionC.png](images/ColisionC.png)
132
-
133
-**Figura 1.** La imagen muestra las coordenadas $(CARX,Y)$ que debe tener el obstáculo para que ocurra una colisión.
134
-
135
----
136
-
137
-### Ejercicio 4: Completar la función para colisiones con banderas.
138
-
139
-En este ejercicio completarás el método `flagCollision` que se encuentra en el archivo `work.cpp`. La función recibe un objeto de clase `Obstacle` y otro objeto de clase `Flag` y debe detectar si hay colisión o no entre el carro y la bandera. Esta función es bien similar a la función del Ejericio 3, excepto que esta función no devuelve valor.  Las acciones que ocurren cuando se detecta la colisión se van a tomar dentro de la función.
140
-
141
-En este caso si se detecta una colisión, se debe aumentar la puntuación del juego 30 puntos utilizando la función `setScore` y esconder la bandera  utilizando la función `flag.hide()` para crear la ilusión de que se recogió la bandera en la colisión.
142
-
143
-
144
----
145
-
146
----
147
-
148
-## Entregas
149
-
150
-Utiliza "Entrega" en Moodle para entregar el archivo `work.cpp` que contiene el código con las soluciones para escoger la pista y detectar las colisiones. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
151
-
152
-
153
-
154
----
155
-
156
----
157
-
158
-## Referencias
159
-
160
-[1] Dave Feinberg, http://nifty.stanford.edu/2011/feinberg-generic-scrolling-game/
161
-
162
-    
163
-
164
----
165
-
166
-[English](#markdown-header-selection-structures-car-scrolling-game) | [Español](#markdown-header-estructuras-de-seleccion-juego-de-desplazamiento-de-carro)
167
-
168
-# Selection Structures - Car Scrolling Game
169
-
170
-![main1.png](images/main1.png)
171
-![main2.png](images/main2.png)
172
-![main3.png](images/main3.png)
173
-
174
-When we want to solve a problem, most of the time there is one or more options that depend on certain conditions being met. Computer programs are written to solve problems, and should therefore have a structure that allows it to make decisions. In C++ the decision (or conditional) instructions are structured using if, else, else if or switch. These structures usually involve the use of relational expressions and logical operations. In today's laboratory experience you will practice the use of certain decision structures to complete the design of a car and obstacle collision game application. 
175
-
176
-##Objectives:
177
-
178
-1. Use relational expressions and select appropriate logical operators to make decisions.
179
-2. Apply decision structures.
180
-
181
-
182
-## Pre-Lab:
183
-
184
-Before arriving at the laboratory you should have:
185
-
186
-1. Reviewed the following concepts:
187
-
188
-   a. logical operators
189
-
190
-   b. if, else, else if, switch
191
-
192
-2. Studied the concepts and instructions for the laboratory session.
193
-
194
-
195
----
196
-
197
----
198
-
199
-
200
-##Car Scrolling Game
201
-
202
-Collision games consist of maneuvering an object in order to dodge incoming objects to avoid possible collision. The collision can lower the player's score, or stop the game. Sometimes, colliding with certain objects may increase the player's score. In the game from today's laboratory experience, the object the player controls is a car, the objects that cause the game to stop are pines, holes, among others, and the objects that add points to the score are flags.
203
-
204
-The controls for this game are simple: the up arrow moves the car up and the down arrow moves the car down. During gameplay, the game simulates the movement of the car towards the right using a simple method: moving the background with its obstacles and flags towards the left while the car stays in the same place. The player can move the car up or down to dodge obstacles and to capture the flags. If the car collides with an obstacle, the game ends. The player can continue by pressing the `Retry` button. 
205
-
206
-
207
----
208
-
209
----
210
-
211
-
212
-## Laboratory Session:
213
-
214
-In this laboratory experience you will practice the use of mathematical expressions and condition structures to implement the car's collision detection against obstacles and flags.
215
-
216
-Your task is to complete the design of the game application.
217
-
218
-### Exercise 1: Familiarize yourself with the pre-defined functions
219
-
220
-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 you will complete to detect the collisions. 
221
-
222
-**Instructions**
223
-
224
-1. Download the `Conditionals-CarScrollingGame` folder from `Bitbucket` using the terminal, moving to the directory `Documents/eip`, and writing the command `git clone http://bitbucket.org/eip-uprrp/conditionals-carscrollinggame`.
225
-
226
-2. Load the Qt project `CarScrollingGame` by double clicking the `CarScrollingGame.pro` file found within the `Documents/eip/Conditionals-CarScrollingGame` directory on your computer.
227
-
228
-3. Configure the project. The project consists of various files. **You will only write code on the file** `work.cpp`**. You should not change anything on the other files.**
229
-
230
-4. You are going to need a few methods defined in the following files to create your code.
231
-
232
-   * `car.h` y `car.cpp`: contains the definition of the class `Car`, the methods of the class and their declarations.
233
-   *  `flag.h` y `flag.cpp`: contains the definition of the class `Flag`, the methods of the class and their declarations.
234
-   *  `obtstacle.h` y `obstacle.cpp`: contains the definition of the class `Obstacle`, the methods of the class and their declarations.
235
-   * `play.h` y `play.cpp`: contains the definition of the class `Play`, the methods of the class and their declarations.
236
-
237
-Familiarize yourself with the methods in these files. Emphasize the following methods:
238
-
239
-   * `Car::getYCar()`: Returns the $$Y$$ coordinate of the car's position on the track.
240
-   * `Flag::getXFlag()`: Returns the $$X$$ coordinate of the flag's position on the track.
241
-   * `Flag::getYFlag()`: Returns the $$Y$$ coordinate of the flag's position on the track.
242
-   * `Flag::hide()`: Hides the flag.
243
-   * `Obstacle::getXObstacle()`: Returns the $$X$$ coordinate of the obstacle's position on the track.
244
-   * `Obstacle::getYObstacle()`: Returns the $$Y$$ coordinate of the obstacle's position on the track.
245
-   * `Play::setScore(n)`: Receives an integer number and adds it to the game's total score.
246
-    
247
-There isn't a `getXCar()` method because the car does not move on the $$X$$ axis.
248
-
249
-### Exercise 2: Complete the function to change the game's track.
250
-
251
-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 parameter.
252
-
253
-The method `setTrack` receives a value of type `Track` that can be:
254
-
255
-   * `play::DAY` - for a day track
256
-   * `play::NIGHT` - for a night track
257
-   * `play::BEACH` - for a beach track
258
-   * `play::CANDYLAND` - for a candy track
259
-
260
-The track's attributes that can be changed are:
261
-
262
-   * the image on the track using the function `setTrackPixmap()`
263
-   * the image of the obstacles using the function `setObstaclesPixmap()`
264
-
265
-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**).
266
-
267
-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"**).
268
-
269
-**Instructions**
270
-
271
-To complete the `setTrack()` function: 
272
-
273
-1. Change the image on the track according to the `Track` value received.
274
-
275
-2. Change the image of the obstacles using the `switch` selection structure such that the obstacles change according to the value received by `setTrack()`. If the type of the track that is received is:
276
-
277
-    * `play::DAY` - the obstacles are of type "hole" or "cone"  
278
-    * `play::NIGHT` - the obstacles are of type "it" or "zombie"
279
-    * `play::BEACH` - the obstacles are of type "spongebob" or "patric"
280
-    * `play::CANDYLAND` - the obstacles are of type "monster"
281
-
282
-    With the options that have two possible obstacles use `rand() % 2` to randomly select between an obstacle or the other.
283
-
284
-### Exercise 3: Complete the function for collision with obstacles
285
-
286
-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.
287
-
288
-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`.
289
-
290
-If a collision is detected, the function returns `true`, and if not the function should return `false`.
291
-
292
----
293
-
294
-![ColisionC.png](images/ColisionC.png)
295
-
296
-**Figure 1.** The image shows the coordinates $$(CARX,Y)$$ that the obstacle should have for a collision to occur.
297
-
298
----
299
-
300
-
301
-### Exercise 4: Complete the function for collision with flags
302
-
303
-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.
304
-
305
-In this case if a collision is detected, the game's score should increase by 30 points using the `setScore` function and hide the flag using the `flag.hide()` function to create the illusion that the flag was picked up during the collision.
306
-
307
----
308
-
309
----
310
-
311
-### Deliverables
312
-
313
-Use "Deliverables" in Moodle to hand in 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.
314
-
315
----
316
-
317
----
318
-
319
-### References
320
-[1] Dave Feinberg, http://nifty.stanford.edu/2011/feinberg-generic-scrolling-game/
1
+## [\[English\]](README-en.md) - for README in English
2
+## [\[Spanish\]](README-es.md) - for README in Spanish