space invaders.png

Basic Game

Creative Technology – Design Challenge #4

Use p5.js and Objects/Classes to create a basic interactive game.

Design Challenge #4: Basic Game Creative Technology ATLAS Institute University of Colorado Boulder Use p5.js and Objects/Classes to create a basic interactive game.

Creative Technology – Design Challenge #4

Use p5.js and Objects/Classes to create a basic interactive game.


 For this design challenge, I decided to recreate the arcade classic Space Invaders. To complete the challenge, I made all of the various game elements into classes.

The first class I created was the user-controlled tank. The tank class included built in functions to display the object, to move the tank based on user input, to determine if the object was hit, and how to reset after losing a life.

The next class I created was for the barriers that the player can use for protection from the aliens. The barrier class includes built in functions to display the barriers, and to determine if a shot hits the barrier.

Another class was used to represent the aliens. An array of the objects was generated in order to display 40 in the same way. The alien class includes functions to display the object, to move the object across and down the screen, to determine if the alien is hit and how to react, to determine how often to fire, and to determine if the user has lost the game.

Finally, I created a class to represent the user’s shots and the aliens shots. Each of those classes include functions to display the shot and to move the shot up or down the screen.

The end result is a fully functional, and fully interactive recreation of the game Space Invaders. The code used to create the game can be found here: https://editor.p5js.org/jppoulter/sketches/WquRBZXUV