Refactor the exercises into their own directories
This commit is contained in:
parent
d5379872ce
commit
770e7b5e76
28 changed files with 95 additions and 195 deletions
9
exercises/16/unique_ptr_pacman/exercise.md
Normal file
9
exercises/16/unique_ptr_pacman/exercise.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Memory and RAII
|
||||
|
||||
(corentin: maybe something about } that destroys things)
|
||||
We are going to play with using std::unique_ptr as we discussed in the slides. Since we will be reverting these changes
|
||||
back, do take a copy of the GameState files before we start. We will change PacMan within GameState into a std::
|
||||
unique_ptr<PacMan>, once this has been done the code will not compile, because there are further changes needed within
|
||||
the GameState class. Go through and figure out what needs to be updated. Can we change one of the ghosts into a std::
|
||||
unique_ptr? Are there any current design problems we will run into? What do these design issues say about ownership of
|
||||
data?
|
|
@ -5,3 +5,5 @@ behavior.
|
|||
|
||||
Clyde always chases PacMan so the only thing you should need is where PacMan is currently located. But Clyde also has
|
||||
the scatter behavior as the other ghosts.
|
||||
|
||||
Where are the graphics for Clyde in the assets file and how can we make sure the ghost will be correctly rendered?
|
5
exercises/21/is_intersection/exercise.md
Normal file
5
exercises/21/is_intersection/exercise.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# std::array and ranged for
|
||||
|
||||
waage: Maybe the "isIntersection" for the AI. Create an array of GridPosition and array of bool and loop through to
|
||||
check "isWalkableForPacMan" and then return the different kinds of intersections (top/right, right/bottom, bottom/left,
|
||||
left/top)
|
7
exercises/23/algorithm_pellets/exercise.md
Normal file
7
exercises/23/algorithm_pellets/exercise.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Iterators and algorithms
|
||||
|
||||
Use algorithms in Pellet and SuperPellet
|
||||
|
||||
# Pellet
|
||||
|
||||
Turn algorithm into raw loop, make students use algorithms.
|
3
exercises/24/lambda-fy/exercise.md
Normal file
3
exercises/24/lambda-fy/exercise.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Lambdas
|
||||
|
||||
Find a small function and turn it into a lambda.
|
|
@ -1,15 +1,3 @@
|
|||
## Exercises
|
||||
|
||||
# Exercise: PacMan Bot
|
||||
|
||||
PacMan can be controlled with the keyboard, but those inputs can be automated. The only thing that needs to change is
|
||||
the value within the InputState class.
|
||||
|
||||
Start by giving InputState random values on each update and then program in a fixed set of movement. For example "Go
|
||||
Right for 3 seconds, then down, right, up, right". This should pickup the first super pellet.
|
||||
|
||||
In this exercise, the input code in processEvents is not needed.
|
||||
|
||||
# Exercise: PacMan AI
|
||||
|
||||
The exercise above is fixed based on the layout of the board and is hard to make generic.
|
||||
|
@ -22,7 +10,3 @@ For example if pacman is at an intersection and can go either right or up, and t
|
|||
then pacman will go up. Then while pacman is going up, a ghost enters that path, pacman will go back.
|
||||
|
||||
You only need to worry about the grid itself and any ghosts on the North/South/East/West axis of PacMan.
|
||||
|
||||
# Exercise: ?
|
||||
|
||||
Extra
|
9
exercises/25/pacman_bot/exercise.md
Normal file
9
exercises/25/pacman_bot/exercise.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Exercise: PacMan Bot
|
||||
|
||||
PacMan can be controlled with the keyboard, but those inputs can be automated. The only thing that needs to change is
|
||||
the value within the InputState class.
|
||||
|
||||
Start by giving InputState random values on each update and then program in a fixed set of movement. For example "Go
|
||||
Right for 3 seconds, then down, right, up, right". This should pickup the first super pellet.
|
||||
|
||||
In this exercise, the input code in processEvents is not needed.
|
|
@ -1,48 +0,0 @@
|
|||
# Mod(C++) - Pac-Man Exercise
|
||||
|
||||
## Make Speedy
|
||||
|
||||
1) Make a new ghost class for Speedy
|
||||
2) Pick the right sprite
|
||||
3) Pick the right scatter target
|
||||
|
||||
Advanced:
|
||||
|
||||
4) Try to chase PacMan
|
||||
|
||||
Hints: (links)
|
||||
|
||||
## Implement eating of pellets
|
||||
|
||||
1) Make a Pellets class (look at SuperPellets)
|
||||
2) Implement eating of pellets
|
||||
|
||||
Advanced:
|
||||
|
||||
3) Try to keep score
|
||||
|
||||
Hints: (links)
|
||||
|
||||
## Add cherries
|
||||
|
||||
1) Implement cherries (look at SuperPellets)
|
||||
2) Change the ghost speed and look
|
||||
|
||||
Hints: (link)
|
||||
|
||||
## Add Levels
|
||||
|
||||
## Add kill screen
|
||||
|
||||
## Add win
|
||||
|
||||
## Add high score (std::filesystem)
|
||||
|
||||
### Ghosts characters and algorithms
|
||||
These will probably become relevant
|
||||
* https://en.wikipedia.org/wiki/Ghosts_(Pac-Man)
|
||||
* [Video: Pac-Man Ghost AI Explained](https://youtu.be/ataGotQ7ir8)
|
||||
* https://gameinternals.com/understanding-pac-man-ghost-behavior
|
||||
* https://www.gamasutra.com/view/feature/3938/the_pacman_dossier.php?print=1
|
||||
* https://www.slideshare.net/grimlockt/pac-man-6561257
|
||||
* http://donhodges.com/pacman_pinky_explanation.htm
|
2
exercises/advanced/blue_pellet/exercise.md
Normal file
2
exercises/advanced/blue_pellet/exercise.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Blue Pellet?
|
||||
A pellet that makes the ghosts stop
|
10
exercises/advanced/game_over/exercise.md
Normal file
10
exercises/advanced/game_over/exercise.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Exercise: Game Over
|
||||
|
||||
In this exercise you will add a game over state to the game. After PacMan has lost all of his lives the game will be
|
||||
over. PacMan should not respawn and the ghosts should stop.
|
||||
|
||||
The GameState class has the number of lives and they are already drawn on screen so that information can be used to
|
||||
indicate the game over state itself.
|
||||
|
||||
If the game is over, the text "Game Over" should be drawn over the game board. You do not need to implement a new game,
|
||||
for this exercise restarting the application is enough.
|
8
exercises/advanced/generic_teleporting/exercise.md
Normal file
8
exercises/advanced/generic_teleporting/exercise.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Exercise: Generic Teleporting
|
||||
|
||||
In the game and the exercise above, the teleports are linked to each other. These systems are not very generic. Update
|
||||
the teleporting system so that two teleport doors are linked with each other.
|
||||
|
||||
For example so you can enter a teleport from somewhere on the bottom row and exit from somewhere on the right column.
|
||||
|
||||
You do not need to allow for many teleports like this, only 2 doors.
|
1
exercises/advanced/high_score/exercise.md
Normal file
1
exercises/advanced/high_score/exercise.md
Normal file
|
@ -0,0 +1 @@
|
|||
(std::filesystem)
|
3
exercises/advanced/hitbox_collision/exercise.md
Normal file
3
exercises/advanced/hitbox_collision/exercise.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Hitbox collision
|
||||
|
||||
AABB
|
|
@ -1,5 +1,3 @@
|
|||
## Exercises
|
||||
|
||||
# Exercise: Increased Ghost Speed
|
||||
|
||||
Currently the ghosts move at a fixed rate. But in the original game, the ghosts would move slightly faster and faster as
|
||||
|
@ -13,11 +11,3 @@ You could increase the speed after each time the ghost is eaten for example, or
|
|||
after N seconds.
|
||||
|
||||
Also ask yourself, how would you test this?
|
||||
|
||||
# Exercise: ?
|
||||
|
||||
Extra
|
||||
|
||||
# TODO Changes
|
||||
|
||||
Pinky as main exercise and Clyde as Extra.
|
|
@ -0,0 +1,5 @@
|
|||
# Exercise: Multiple Generic Teleporters
|
||||
|
||||
Continuation from above. Take the generic teleporting system you made and allow for more than 1 set of doors.
|
||||
|
||||
You might want to look into coloring/tinting each pair a certain color so the player will know what door leads to where.
|
7
exercises/advanced/new_level/exercise.md
Normal file
7
exercises/advanced/new_level/exercise.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Exercise: New Level
|
||||
|
||||
In this exercise you will need to reset the game board but keep score and lives the same. This should happen when PacMan
|
||||
eats the last pellet or super pellet.
|
||||
|
||||
The ghosts and pacman should go back to their original position and all of the pellets should respawn. This can go on
|
||||
forever, but you can look at the next exercise for more information.
|
5
exercises/advanced/vertical_teleport/exercise.md
Normal file
5
exercises/advanced/vertical_teleport/exercise.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Exercise: Vertical Teleport
|
||||
|
||||
The teleporters are programmed to work only on the horizontal axis. Change the board to add teleporters at the top and
|
||||
bottom row. This also requires a code change when teleporting happens. These new teleporters only need to function like
|
||||
the existing teleporters and you do not need to add more than one on each row.
|
9
exercises/advanced/victory/exercise.md
Normal file
9
exercises/advanced/victory/exercise.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Exercise: Victory
|
||||
|
||||
As a continuation of the Game Over and New Level exercises. If PacMan beats 3 levels, the game has been beaten and a
|
||||
victory screen should be shown.
|
||||
|
||||
A count of how many levels have been beaten needs to be stored and this should be checked when transitioning between
|
||||
levels.
|
||||
|
||||
This should function similarly to the Game Over state but used to indicate that the player won the game.
|
|
@ -1,30 +0,0 @@
|
|||
## Exercises
|
||||
|
||||
# Exercise: Game Over
|
||||
|
||||
In this exercise you will add a game over state to the game. After PacMan has lost all of his lives the game will be
|
||||
over. PacMan should not respawn and the ghosts should stop.
|
||||
|
||||
The GameState class has the number of lives and they are already drawn on screen so that information can be used to
|
||||
indicate the game over state itself.
|
||||
|
||||
If the game is over, the text "Game Over" should be drawn over the game board. You do not need to implement a new game,
|
||||
for this exercise restarting the application is enough.
|
||||
|
||||
# Exercise: New Level
|
||||
|
||||
In this exercise you will need to reset the game board but keep score and lives the same. This should happen when PacMan
|
||||
eats the last pellet or super pellet.
|
||||
|
||||
The ghosts and pacman should go back to their original position and all of the pellets should respawn. This can go on
|
||||
forever, but you can look at the next exercise for more information.
|
||||
|
||||
# Exercise: Victory
|
||||
|
||||
As a continuation of the Game Over and New Level exercises. If PacMan beats 3 levels, the game has been beaten and a
|
||||
victory screen should be shown.
|
||||
|
||||
A count of how many levels have been beaten needs to be stored and this should be checked when transitioning between
|
||||
levels.
|
||||
|
||||
This should function similarly to the Game Over state but used to indicate that the player won the game.
|
|
@ -1,22 +0,0 @@
|
|||
## Exercises
|
||||
|
||||
# Exercise: Vertical Teleport
|
||||
|
||||
The teleporters are programmed to work only on the horizontal axis. Change the board to add teleporters at the top and
|
||||
bottom row. This also requires a code change when teleporting happens. These new teleporters only need to function like
|
||||
the existing teleporters and you do not need to add more than one on each row.
|
||||
|
||||
# Exercise: Generic Teleporting
|
||||
|
||||
In the game and the exercise above, the teleports are linked to each other. These systems are not very generic. Update
|
||||
the teleporting system so that two teleport doors are linked with each other.
|
||||
|
||||
For example so you can enter a teleport from somewhere on the bottom row and exit from somewhere on the right column.
|
||||
|
||||
You do not need to allow for many teleports like this, only 2 doors.
|
||||
|
||||
# Exercise: Multiple Generic Teleporters
|
||||
|
||||
Continuation from above. Take the generic teleporting system you made and allow for more than 1 set of doors.
|
||||
|
||||
You might want to look into coloring/tinting each pair a certain color so the player will know what door leads to where.
|
|
@ -50,3 +50,13 @@ from the player (or a bot).
|
|||
Because updates of game state and drawing the game on screen are completely separate, we can create game state within
|
||||
unit tests and give it arbitrary delta time and call whatever functions we want to simulate the game being played. Most
|
||||
unit tests only focus on one single class but some (like `testFruits`) use the `GameState` class.
|
||||
|
||||
## Ghosts characters and algorithms
|
||||
|
||||
These will probably become relevant
|
||||
* https://en.wikipedia.org/wiki/Ghosts_(Pac-Man)
|
||||
* [Video: Pac-Man Ghost AI Explained](https://youtu.be/ataGotQ7ir8)
|
||||
* https://gameinternals.com/understanding-pac-man-ghost-behavior
|
||||
* https://www.gamasutra.com/view/feature/3938/the_pacman_dossier.php?print=1
|
||||
* https://www.slideshare.net/grimlockt/pac-man-6561257
|
||||
* http://donhodges.com/pacman_pinky_explanation.htm
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# Pellet
|
||||
Turn algorithm into raw loop, make students use algorithms.
|
||||
|
||||
# Lambdas
|
||||
Find a small function and turn it into a lambda.
|
||||
|
||||
# Blue Pellet?
|
||||
A pellet that makes the ghosts stop
|
||||
|
||||
# Hitbox collision
|
||||
AABB
|
|
@ -1,58 +0,0 @@
|
|||
# Functions and Parameter Passing
|
||||
|
||||
In Board.cpp we have functions to detect the state of the game board. Let's add a few helper functions and create unit
|
||||
tests for them.
|
||||
|
||||
Add a function that will check if a cell on the board is a wall. Then use that function in "isWalkableForPacMan" and "
|
||||
isWalkableForGhost". Remember you will need to add the function into the Board.hpp header file to be able to use it in
|
||||
the unit tests.
|
||||
|
||||
# Game - Foundation
|
||||
|
||||
?
|
||||
|
||||
# Compilation, Linking and Assets
|
||||
|
||||
One of the PacMan ghosts is missing and we will implement this ghost later. But for now, let's add the cpp and hpp files
|
||||
and run CMake to see the file added to our project. Then let's create an empty class called Blinky that looks like the
|
||||
other Ghost classes but it can be empty at this time. Where are the graphics for Blinky in the assets file and how can
|
||||
we make sure the ghost will be correctly rendered?
|
||||
|
||||
# Memory and RAII
|
||||
|
||||
(corentin: maybe something about } that destroys things)
|
||||
We are going to play with using std::unique_ptr as we discussed in the slides. Since we will be reverting these changes
|
||||
back, do take a copy of the GameState files before we start. We will change PacMan within GameState into a std::
|
||||
unique_ptr<PacMan>, once this has been done the code will not compile, because there are further changes needed within
|
||||
the GameState class. Go through and figure out what needs to be updated. Can we change one of the ghosts into a std::
|
||||
unique_ptr? Are there any current design problems we will run into? What do these design issues say about ownership of
|
||||
data?
|
||||
|
||||
# Classes and Structs
|
||||
|
||||
Within the GameState class, we often call all of the ghost functionality at the same time. So lets create a class that
|
||||
will contain all the ghosts. It can be called GhostState and the only member variables will be the ghosts. This class
|
||||
then needs to be contained within GameState instead of the ghosts. Then you need to write the functions for this
|
||||
GhostState class that are called within the GameState class.
|
||||
|
||||
# std::array and ranged for
|
||||
|
||||
waage: Maybe the "isIntersection" for the AI. Create an array of GridPosition and array of bool and loop through to
|
||||
check "isWalkableForPacMan" and then return the different kinds of intersections (top/right, right/bottom, bottom/left,
|
||||
left/top)
|
||||
|
||||
# std::vector
|
||||
|
||||
?
|
||||
|
||||
# Iterators and algorithms
|
||||
|
||||
Use algorithms in Pellet and SuperPellet
|
||||
|
||||
# Lambdas and Function Templates
|
||||
|
||||
?
|
||||
|
||||
# Algorithmic Thinking
|
||||
|
||||
?
|
Loading…
Reference in a new issue