Deliverables
This week’s demo uses destructive collision handling to create a version of the Space Invaders game.
Demo
The demo this week is a simple version of Space Invaders.
Your game demo must have the following features (but feel free to play around and implement anything you want otherwise):
- There must be several rows of enemies that move in approximately the same way as our demo (that is, across the screen, then down a “row” repeatedly)
- Both the player and the enemies must shoot projectiles at each other (the enemies automatically, and the player when the space bar is pressed)
- The player must move back and forth based on presses of the arrow keys
- The demo should stop when (1) the player is shot, (2) the player clears all space invaders, or (3) the space invaders ‘fall’ below the ground.
As with last week, this demo may run particularly slowly if compiled with asan. If you want to run it without asan, please run the command make NO_ASAN=true demo
, instead of the regular make demo
, or else you may experience demo slowdown.
Important Changes
Several important and relevant changes to the physics engine are highlighted below:
sdl_wrapper
Changes
We have changed get_keycode
and sdl_render_scene
in the wrapper this week, so
be sure not to overwrite any of those changes when copying and pasting code from
previous weeks over.
Collisions
This week, one of your teammates will implement collision detection. Take a look at collision.h
to see what the find_collision
method should do.
For your demo, you will also have to use some sort of destructive collision. We have defined two destructive collision methods for you in forces.h
and implemented them in forces.c
that you should use.
Body “info” field
Different applications will need to use different extra information about bodies. For example, for Space Invaders, you will need to be able to differentiate between the player
and enemies. Thus, we will add auxilliary data to the body as a void *
. The new body struct has been provided for you in body.c
. Take a look at body.h
to see how to use the new “info” field.
emscripten_main
emscripten_main
returns a bool now and tells the game loop if the game has ended.
If it has, SDL
quits. Look at emscripten.c
to see how it’s being used.
This will be relevant to your win/loss conditions this week.
sdl_render_scene
We’ve added a new aux
argument to sdl_render_scene
. Currently, sdl_render_scene
is implemented so that it assumes that aux
is a body_t
type and renders it on the screen. This
may be helpful if you want to separate a body from the scene (like the pacman and the pellets).
color_compare
We’ve implemented a a new method color_compare
for you to see if two colors are equal. Depending on how you implement the demo, it may or may not be used, but we wanted to let you know for future weeks as well.
Task 0. When you are done, your group should meet and complete the questions here.