Function + Game

Hunter Maul
2 min readFeb 27, 2021

Reference Images:

Sky Dancer, Sky Runner, Dino Game

Elements:

My four main elements are my ninja, the walls, the shuriken, and the surrounding imagery.

Ninja: The ninja and his jetpack are drawn by the function runner(). In the draw function, I have logic increasing or decreasing the ninja’s Y value depending on whether the mouse is being pressed or not. This same logic calls the flame() function when the mouse is being pressed. This function draws the jetpack’s flame.

Walls: The rocks() and moreRocks() functions draw the walls and move them along the screen at a steady rate. The rockReset() and rock2Reset() functions reset the wall’s x position at a random value offscreen. These functions are called whenever the walls go off of the screen, or by the distance check in my draw function.

Shuriken: The shuriken() function is called by the draw function once the score is greater than 8. This function behaves the exact same way as the walls except, it is above the ninja, and draws a more complex shape.

Surrounding Imagery: The surrounding imagery is primarily the background gradient and the clouds, both of which are nested within the sky() function. This function is called by the draw function. It draws the background, draws the clouds, moves the clouds, and resets the cloud's x value when they go off of the screen. The game() function is responsible for keeping score whenever the ninja successfully makes it over a wall.

--

--