Link to Sketch: https://editor.p5js.org/ma9331/full/ZSQDV21v5
Concept
For my midterm project, I decided to make it Star Wars-themed. The main character of the game is Luke Skywalker, who is on a mission to defeat the Galactic Empire. Luke is on the Death Star (the enemy’s base), where he encounters countless Stormtroopers whom he needs to defeat.
Instead of having a main objective to achieve, I made it a score-based game. In this one-player game, the user plays as Luke Skywalker and slashes as many Stormtroopers (enemies) on the ship before the timer runs out and gets their score at the end.
This is my initial sketch which ended up being pretty similar to the final game’s outcome. The Stormtroopers emerge from the far right side of the screen and move towards the other end of the screen. Luke moves using the arrow keys and attacks by holding the “e” key.
I made two separate classes: one for Luke (the player) and one for the Stormtroopers (NPC enemies). Luke has a constant speed but the Stormtroopers have a random speed to make it a bit more challenging.
Code I’m Proud of
//initial/starter enemies new Stormtroopers(windowWidth, windowHeight * 1.2, scale, enemies); stormtroopers.push( new Stormtroopers(windowWidth + 200, windowHeight * 1.2, scale, enemies) );
function spawnEnemies() { //respawn function stormtroopers.push( new Stormtroopers(windowWidth, windowHeight * 0.8, scale, enemies) ); stormtroopers.push( new Stormtroopers(windowWidth - 10, windowHeight * 0.8, scale, enemies) ); }
if (stormtroopers[i].x < -10) { // enemies go offscreen stormtroopers.splice(i, 1); // remove from array once offscreen if(score>0){ score -=10; // decrease score, keep >= 08 }
I had a lot of issues with the enemies spawning and positioning. At first, only a few enemies would spawn at the start of the game but would not respawn. This was because i set the Stormtroopers to stop walking at x=0, so they could never reach less than x=-10 and trigger the respawn function. I had to experiment with different values because the first enemies spawn as soon as you click run (because they’re in the function setup), so their positioning in fullscreen was different from the ones that respawn after. Ultimately, the Y-positioning for the initial enemies had to be windowHeight*1.2, and for the respawns it had to be set to windowHeight*0.8 in order for it work on fullscreen, and to be in the same Y-position as the initial enemies.
Design
For the end screen in my game, I took inspiration from the title screen at the start of every Star Wars movie.
This is what my end screen looks like:
And this is the title screen from Star Wars films:
I thought it would be a really cool but simple nod to the movies.
Areas of Improvement
If I had more time, I would’ve experimented more with the Stormtroopers’ abilities and gave them their own attacks: one attack could be that they shoot the player from their guns and deal damage to the player. Also, I had the thought of adding a health bar for both Luke and the enemies to make the game a bit harder (killing the enemies would require more than just one slash) and not time-based.