PAPER WARRIOR

Hunter Maul
2 min readMar 8, 2021

BEFORE I EXPLAIN IT I AM LINKING MY P5 BECAUSE I COULDN’T FIGURE OUT HOW TO UPLOAD MY SOUNDS/SPRITES BECAUSE PETER SAID AND I QUOTE “CODEPEN SUCKS”

Reference

Super Smash Bros PictoChat stage, Lunar Hero, and Jetpack Ninja

Ship

This game was originally spaceship inspired, so forgive the irrelevant names of my classes. Anyways, my Ship consists of a constructor method and a render method. The constructor() method defines the local variables which are an X, a Y, and a velocity variable. The render() method takes an X and a Y value and draws the hero sprite that I made at those values. The values increase or decreased based upon keyboard input that is detected within the draw function.

Bullet

My bullet class has a constructor, a shoot, and a render method. The constructor() defines an X, a Y, a velocity, and a bulletRemoved variable. The shoot() method is responsible for the bullets motion, and is called whenever a bullet is drawn. The render() method takes an x and a y value (in this case the x and y value of my character) and draws the bullet sprite I made at that location. A new bullet object is created and added to my bulletArray every time the mouse is clicked, these objects are then removed from the array whenever the bullet flies off screen or collides with an enemy.

Asteroid

My asteroid class has a constructor, a render, and a reset method. The constructor() defines an X, a Y, and a velocity variable. The render() method draws the evil sprite I at random y values and at constantly decreasing x values. The reset method resets the x and y values that are fed into the render method, and is only called when an evil sprite goes off screen, the sprite makes contact with a bullet, or the game is over.

Game

My game class has a constructor(), a scoreIncrease(), and a render() method. The constructor() defines a score variable. The scoreIncrease method is called whenever a bullet collides with an enemy and the native score variable within my game class is increased. The render method then displays the score in the top left corner of the screen.

--

--