Functions and Game HW

EJ Gerth
2 min readMar 2, 2021

Here is the pseudocode I wrote for this program:

/*
Pseudocode:
Elements:
Playarea-Space Background-No Behavior
Flying Saucer-Floats around, don’t get hit, if hit lose life, 3 strike you’re out
Asteroid-Random genration-flies/floats around screen
Timer-displays length of time survived
Death message?-shows score and time survived

Behaviors:
flyingSaucer- moves along x and y axis w/ arrow keys
Asteroid- random ellipse generation, moves
Timer- counts up
*/

References Images:

The original art for asteroids is mostly vector based, but I went a different direction and tried to make my spaceship game with solid shapes. I made a little UFO out of some ellipses and used the changes in gamestate to call the function. It uses conditionals within a separate function to move around the screen. There is also a function that makes the asteroid bounce around on the screen. I tried getting a way for the game to reach an end state, but after trying to implement for a few hours, I kept running into problems where it either wouldn’t run when I tried implementing it or it would end the game right away so I’m not sure. There is another function that is a timer that starts to count up when the main stage of the game begins to tell you how long you have survived.

--

--