WILD WILD TAXI!

Concept:

I originally had this idea in thinking about OOP and continued to work on it since. Wild Wild Taxi is a game that I have played for the majority of my life, even now, most of my friends know how much I enjoy the game. Unfortunately, as I mentioned before because Flashplayer is no longer available I have decided to recreate the game so be able to enjoy the game in some way now.

In the actual design of the game, in all of the different versions of the game, there has been a different theme, from basic car driving, to what I wanted to look like the highways of Abu Dhabi, to what is now the streets of New York. Looking at the game now, it just is nice to look at than before and feels more like a game.

Implementation:

To be able to actually recreate the game I knew there would have to be different states, or screens of the game, which I’ll call START, INSTRUCTION, GAME, GAME OVER. In each of these pages there were different components, the first two START and INSTRUCTION, are images I created based on the taxi theme and using the key pressed function to move onto the next mode. Once on the GAME mode, you can use the left and right arrows to move from lane to lane within the set boundaries that are the lanes. In the GAME mode, you don’t lose unless you click the left or right arrow, which in a way isn’t very accurate of a game, but I appreciate games that don’t make me lose when I am not playing since I often tend to multitask, but in the future, this could be a pause mode so that the entire game pauses. Once you crash into a car, from any of the four corners, the game is then over and you can restart the game, and continue where you left off. With all of this, there is a sound that is in the background that adds to the effect of the chaos or the “Wild Wild” component.

Challenges:

In envisioning the game, I didn’t realize all the different components that went into creating a game. In the end, there were two main challenges, first, while there is sound, the sound I originally wanted was to play an ignition sound during the START and INSTRUCTION phase, then a sound of cars driving in the GAME phase, and finally a crash sound when the cars crash and the game is over. As it is now, is also okay, but I think having the sound as feedback to the actions of the player adds to the interaction between the game and the player. While I was able to overcome this challenge, I didn’t realize the about of thinking that would go into making the game end when the cars are crashing, it was all very logical, but it took a lot of thinking to understand and account for all the scenarios in which a car is crashing in relation to the X and Y position of both the Taxi and the other cars.

Reflection:

Overall, this was definitely another learning experience. I got off to a slow start, but I am satisfied with the current state of the game. Throughout this process, and at this point in the semester I have realized that I have two major challenges within the class that was apparent throughout this project. First, I think coding requires you to think logically while also paying attention to details in a way that I am not used to. I think this forces you to look at every line of code and think in the order of what needs to happen when, for example, what line needs to be drawn, and does it happen before or after the cars move. And I think along with this, I like to understand why something is the way it is, so as I am trying to figure out what exactly needs to be written in the code, I am also trying to understand every component of the line and where it is overall. In time, I think this will get better, but for now, it is intimidating. The other major challenge, that I think is, even more, intimidating in a way is the endless amount of possibilities when I am creating something, the ability do that makes me feel like I have to think of all the possibilities and consider which I will like the most in the end, the process in coding it, and then the visual component that I in every assignment, I spend the most time. Overall, this has all made me appreciate WILD WILD TAXI more, and excited to continue to work on it to ultimately replicate the original version.

With that, here is WILD WILD TAXI!

*sound doesn’t work when embedded

Yunho Lee Midterm Project – Golem Hunters

Game theme and Concept

  1. Genre – First Person Shooter (FPS) game
  2. The main goal of the game – get a higher score by shooting as much as golems as possible using the limited amount of bullets provided

Implementation

  1. Structure of the overall program
    1. Setup()
      1. set variables to avoid unexpected bugs
      2. set frameRate to 60 to make sure all computers display the same result
      3. Divide the PNG file into frames of each sprite (Gun, Golems)
      4. Create a pool of Golems that respawn when killed
    2. mousePressed()
      1. Pause Button
      2. Resume Button
      3. Click to Shoot – Only when you have enough Ammo
      4. Start Button
    3. draw()
      1. make objects move according to the movement of the mouse cursor
      2. display Golems
      3. Display Cross in the middle of the screen
      4. Display PauseUI / StartUI when the game is paused/starts
    4. GunClass
      1. display() – display the sprite images by frames
      2. move() – Shooting motion when the mouse is clicked
    5. Golem
      1. display() – display the sprite image by frames
      2. alive() – the movement of golem when it is moving across the screen
      3. deadMotion() – movement of golem when it is shot
      4. respawn() – waits for a few frames and resets itself in a random position
  2. Techniques Used
    1. Instead of adding an extra golem whenever a golem is killed, I decided to reset the golem that is killed so that there is less use of data and reduce the amount of trash data by recycling resources. – Advantage of OOP.
    2. By transposing the golems the same amount as the movement of the background image, the game gives a strong conception of being in the middle of the scene, looking at the screen from the first-person’s point of view.

Here below is my final version of the midterm project game! Enjoy!

(Recommended to Play in Fullscreen Version)

https://editor.p5js.org/yl4643/full/Rr46vntt5

 

Midterm Assignment


Idea

First of all, I got inspired by the old game (https://kbhgames.com/game/throw-paper), where a player needed to throw a paper into a trash bin. Then, I decided to modify it, thinking about making a waste sorting game. Honestly, when I see trash bins with different labels, I can get confused about how to do waste sorting. Therefore, my idea developed into a sort of educational game. I made some research and stumbled upon plenty of valuable resources from our university about sustainability and effective recycling. https://www.thegazelle.org/issue/148/features/recycling-rundown?fbclid=IwAR29lGNj9u9fJKsSh04SI1rM-9KAqOV92OBGTBX-ObOIKGupfIssHzaCB2A. https://docs.google.com/presentation/d/1pbGNdAsGjuJ5EpqZOm0oOVZWK7rg-g04gpsV4Wo7e0E/edit#slide=id.p.
Implementation
While thinking about the ways of implementing the game, I came up with the idea of re-creating a Tetris based functioning. Ultimately, I wanted a player to be able to use arrow keys in order to place the trash into the correct bin. First of all, I started with creating bins and trash items as two separate classes. I have included attributes inside each class that help to display and move items due to pressing arrow keys. The items are randomly selected from the trash array and generated at the top of the screen

Challenges

The foremost challenge was how to implement the logic of the game into coding. As it could be seen in my previous post, I struggled with the basic functionality of the game. I spent a lot of time on this while rewinding everything that we learned in the class and going to the Professor’s office hours. After dealing with that, it became easier to add multiple, but small details for the program’s proper functionality and design. The items are supposed to fall into the correct bin. To achieve this, I have created checkTrash() function, which considers the coordinates of the bin to place trash. After finishing working with the game functionality, I added scores and a timer. Every time a player places trash into a correct bin, the score is increased by 100 points, otherwise, he might lose 100 points. Then, I created the menu for the game with two buttons: Play (to start the game) and Instructions (to get acquainted with the game rules). There is a sound when you click on each button. Also, I added background music as well as a cheering sound whenever a player correctly sorts out the trash.


Reflection

The beginning of the midterm project was chaotic and challenging, but, eventually, I am satisfied with the final version of it. Through this assignment, I could consolidate the material that we learned during the first half of the semester. Generally, that was a fun experience.

Shama’s Midterm: Guitar Hero

By looking at the time this is posted, you can tell there were a lot of last minute tedious fixes I had to make to make my game work smoothly. I will begin with the details that surprisingly took the longest. After my first draft, I noticed that the space in between my menu buttons (easy,medium, hard etc.) were clickable, and this was the same for the x-axis of my buttons. The issue was that the buttons had a very badly adjusted offset, I fixed this through trial and error (easy but extremely tedious). My next issue came when I realized that my game didn’t end after the songs ended, I had to create an if statement for this (pretty easy fix). After thinking everything was going well, I then noticed that if the window was resized, everything would get thrown off course, so I aligned each elements position to be relative to the next so that it can be responsive to any window size changes.

After going through these tedious changes, I had to start focusing on the actual songs and the creation speed of my arrows. I wanted the songs and the arrows to be in sync almost. While I could’ve calculated this more technically using each song’s bpm, I decided that based off the song’s tempo, I would assign them to the level difficulties. Starting from there the songs and the symbols were not so out of sync, but this wasn’t enough. I took a more tedious route here by adjusting the speed and vertical distance of my arrows to suite each song and level difficulty, if you pay close attention a majority of the arrows will perfectly line up with the song’s beats.

My biggest issues with this project was understanding how to rework my code in a simpler and cleaner way, I kind of took the long messy route because its what I understood best.

I really enjoyed making my own designs and deciding which interaction to use based on what I already know from playing different versions of guitar Hero. I previously experimented with using a sound response for each key pressed on time, but that ended up clashing with the music in the background and sounding awfully annoying, so I decided to go with a box that lights up green when the key is detected to be pressed in the proper range using the splice function. The screen will flash red otherwise.

I also decided to make the game over screen appear if 6 keys were missed in a row, I chose this number after testing it on my friend who said “6 missed keys are fair enough to lose the game, but also challenging enough to want to play again”.

Overall, I learned tremendously a lot from working on this game and by taking the long route, I began to understand what shortcuts I can begin to make instead. In the future, I would like to be able to fluently implement faster code, instead of taking 10 lines to do one thing I’d like to be able to do it in 1.

And finally, here is my Midterm project !!!!! (feel free to resize the window😎 )

Benny the Fish (Midterm Entry)

Benny The Fish 🐳

Final Product 💥

Concept 📌

As explained during my first blog entry, I wanted to turn Benny the Fish, my CommLab comic into a game. The art style, design and plot of the comic would be reflected in my creative process for the game. In its current and final form, the game goes like this:

      1. The players begin in an introductory screen where they see the logo, the playable character, and a short set of instructions. They begin to play by pressing any of the keyboard arrow keys.
      2. Then, they will be able to move the character around in a setting that resembles a fishbowl. As the first level of this game, the background parallels the initial fishbowl where Benny is. In this case, however, Benny has to evade water bottles and eat food.
        1. – Every piece of food eaten increases the player’s score. Every 5, the size of Benny increases by 10%, making the game harder.
        2. -If the player touches a bottle, they will be taken to a screen reiterating it is bad for Benny to touch plastic. Then, with arrow keys, players can continue exactly where they left off. Bottles around the fish are moved back as to not cause problems.  Every time this happens lives (initially 3) decrease by 1.
      3. If the player runs out of lives, they are taken to a game over screen indicating Benny’s death and prompting the user to restart the game.
      4. After 25 pieces of food, the player is taken t o level two. Benny grows into a whale (Plot Twist) and there is a new enemy in sight. The rest of the mechanics are the same.
      5. Upon  reaching a score of 50, the user is taken to a winning screen. Benny can’t stop growing and, thus, they are prompted to click anywhere to restart the game.

Materials 🔎

    • The idea for the comic and characters was  in collaboration  Jeongin Lee, Chaehyun Ha and Mike Kattan.
    • All of the objects were designed by me in Adobe Illustrator, and the backgrounds & logos in Procreate.
    • The sounds were taken from  https://freesound.org/

Reflection 👨🏼‍💻

Working on Benny was a big challenge for me. It was a great exercise to make sure I was proficient in all of the concepts covered in class, and made me grow a lot as a coder. I learned that there is not always one way to solve a problem. Creativity, resilience and patience are necessary to make sure you can execute your vision. Having started which such a defined and specific vision for my game made it so that I had to adapt the code to my preferences. Not the other way around. For this, I am very proud. Albeit Failing to do the sprite sheet for Benny, I managed to include all of the other elements and mechanics that I wanted to, ending with what I believe to be a very successful game. Me and my roomates have played the game a few times and can vouch for it having a logical flow and technical stability. I am very proud of the final result. I hope you enjoy meeting Benny the Whale.

Journey 🛬

Given the fragility of my computer and previous experiences, I saved multiple backups of the game throughout my process. These are shown in all of my updates, and display my progress through time. Here are the updates in my project since March 2nd. (See previous post for updates 1, 2, villains)

Update 3: Conditionals & Design (March 3rd – 6th) 🏞

This might be one of the, if not the biggest update for Benny the Fish. After integrating the villains & controls during Wednesday’s class I spent a lot of time with the conditionals. During the initial days of this weekend, I wrote in my code a switch statement that would create the modes of (1) intro screen, (2) gameplay, (3) losing screen, (4) winning screen. This allowed me to have a much more structured product. I also added if statements to build the killing of Benny mechanism, while adding a live count.  I also added images as backgrounds which make the experience of playing much better. Currently, the game has many elements to be fixed, bugs and improvements, but as soon as I add the designs for the villains and figure out how to restart the bottles.push() & canPlastic.push() for loops, the game will be a playable and great initial product. I still have a lot of work ahead, but believe the game looks very promising.

As always, my immediate next steps are:

    1. Designing the villains & adding them into the game.
    2. With the villains’ design, I can make sure that the distance interactions are as accurate as possible to give the game a better feel. (Not looking forward for this step)
    3. Add Background music, bumping, dying, & eating sounds.

Some overall steps I want to take are:

    1. Figure out how to win. Time? Eating Mechanism?
    2. Adding different levels. I would love for Benny to grow & change of scenery as he does in the comic.
    3. Adding the tail animation for swimming.

Update 4: Error Fixing (March 6th) ⚓️

When hit by a villain, I would press any arrow key to continue playing, but would often find myself amongst a group of villains, making it impossible to continue the game. Thus, I spent a lot of time trying to reset the for loop that moved the villains. Nevertheless, I was able to more easily fix this situation by adding a conditional statement within the function  moveVillain() to reset the positions of the villains surrounding the starting area of Benny. Finally I managed to have the dynamic be: if Benny is killed, he stays in the place he died, where the player can continue. However, all villains in a 200 px would move to y=0.

I also added a little element so that you can see the silhouette of Benny when killed, and organized some of the code.

Update 5: Food, Water Bottles & Lives Counter (March 7th) ❤️❤️❌

An important element I wanted to include in my game was a way to win. In the comic, Benny ends up in the ocean and growing. I needed to include this in the game. Thus, I added a food mechanism that allows the fish to eat, and increase the player’s score.

I also designed a temporary image for the villain water bottles. I switched the circle for a rectangle and spent an embarrassing amount of time playing with the distance function to make sure the dynamics feel natural but are a little forgiving.

My next steps after this update would be to:

    1. Add a growing Mechanism
    2. Add a second level & winning screen
    3. Add sounds to the game

Update 6: Level 2 & Winning Screen (March 8th) 🪜

This is probably the update that took the longest to make. I wanted update 6, the last update before the final entry to be a submittable project. That is, a sketch that would fulfill all the requirements for this midterm assignments. I added a second level with the whale sprite as I wanted to be a little more faithful to the comic, and I added a winning screen. This allowed Benny the Fish to be a much more complete experience. Furthermore, I added upbeat music for the background of the game to simulate previous experiences I’ve had with games.

Midterm Game: Soceroo

Idea and Inspiration

The idea I had for my game for this midterm assignment was the classic breakout game. From a young age I had played this game and I really wanted to code this game out and re-create my childhood experience. As simple as this game looks, this 2D game isn’t as easy as it appears to be. I wanted to speed up the game and decreased the paddle width as the user loses its lives.

Game Implementation 

I want to start by coding how the game would work and by coding out the main object in the game which is the ball, bricks, paddle. After any shading all my global variables I created a bricks array which would hold each brick as an instance just like the object oriented assignment. I also populated and array with the brick colors in order to create a fading effect by using colors close to one another. I then created a function for paddle which was responsible for moving its position left and right depending on the key pressed which would raise a Boolean flag that triggered the movement. 

Then I went on to create the ball which was essentially a circle but this was the most time consuming function. After carefully figuring out the math I was able to get the moving and bouncing effect. I used several if conditions to restrict the circles X and Y coordinate in between the canvas and the interaction with the paddle. The hardest part of all this was the collision detection. For this, I created a different function which checked for the collision at the bottom of the brick by looking at the coordinate range where the ball’s radius would overlap with the bricks dimension which would mean there was a collision and it will return true.

In order to make the brick disappear after the collision I iterated through the bricks array and checked for collision between the ball and the particle brick and if so I used the splice() function in p5.js to remove the brick from the array. I would also increment the score at this point. For the loss of life it was fairly easy since I would just check if the circles y-coordinate was greater than the height of the canvas which meant that the player had failed you make contact with the paddle and has lost a life. 

For creating the bricks on the board are used functions in a way that allowed the bricks to be populated across the canvas using nested for loops. The growing of brick would just fill each brick with its corresponding color and simply create a rectangle with respected coordinates.

Furthermore, for the paddle I wanted to make it as realistic as possible. Of course there wasn’t much physics but i used a simply inverted the x direction when the ball hit the paddle. In order to get this to work correctly, I tried several different approaches like reflecting the angle if it hit ton either half of the paddle but it didn’t work logically and kept bouncing on the same side. So i resorted to using the negative and positive direction (+dx/-dx) for the switching the side and bouncing it to its respective opposite side. However, an additional effect that I implemented was the ball bouncing off the edge of the paddle to the same side.

I tried to increase the difficulty for the user by slowing increasing the speed of the ball as the game progressed and to make it more challenging the player had to move the paddle faster, which also decreased in width as the score went up. I also added sound when the user got a point (which was one brick was destroyed). Sound effects were also played when the user lost a life, game was over or won the game.

 

Midterm Game

Idea
As mentioned in my midterm progress post, for this game, I took inspiration from the game ‘Flappy Bird’ where you have to control the bird by not letting it touch the green pipes. I wanted to incorporate a similar concept therefore went with the idea of having to keep a butterfly away from the fly traps (as I love butterflies).

How Are 'Flappy Bird' and 'Candy Crush' Still Making So Much Money? - Pacific Standard
Original version of the game

Process & Implementation (step by step)
Step 1: I made a basic layout with shapes, butterfly and background.
Initially I had images of real traps however then changed these to rectangular shapes as it was becoming difficult in step 4 when I was working on the collisions.

Before

 

 

 

 

After

Step 2: I made a butterfly class and stored all its features then added movement and control of this movement through the keypressed function.
Step 3: Similarly, I made a trap class (the rectangles with curved edges which I made first but then changed to regular rectangles as the curved edged ones were not detecting collisions accurately) and stored its features such as width, spacing, height, color, etc. I generated random heights within certain limits so that they have appropriate spacing to allow the butterfly to fit through.
Step 4: Once all this was figured out, I had to check for collisions so that if the butterfly touched the traps, the color of the trap would change to indicate it has been hit (from white to red). This was one of the most difficult steps of the process.
Step 5: Once the trap is hit, I wanted the game to stop and show the game is over. Hence, I added on screen text to signify this.
Step 6: Then, I created and inserted a start-up instruction page using mode and switch mode within the draw function.
Step 7: I then created buttons to start and restart the game. I did this by going into the html and adding ‘dom’ to one of the lines of code.  To allow the buttons to work and restart the entire game, I had to make a game class to store the features I wanted. At first the buttons were very small and not as aesthetically appealing thus then played around with it in the style.css tab.

Before
After

Step 8: Next, I added a scoring system, which is placed on the bottom right of the screen.
Step 9: Lastly, I added instrumental sound in the background.

Reflection 
I am happy with how the game turned out and thoroughly enjoyed making it. Some parts were more difficult than others however taking it step by step really helped. I was able to apply skills used in class as well as learn how to do new things. For next time, I would like to have different levels of difficulty. Also, I would want the music to stop when game is over and then start playing again when the game is restarted. In addition, I would want to add a butterfly sprite so that each time the space bar is pressed, the butterfly flaps its wings.

My Game

  The buttons below the canvas do not show here.

 

Nicholas- Midterm Game

Idea

For my midterm, I decided to create a game based on old flash games: simple premises with a hint of an 8 bit aesthetic. The game Lift involves the player spamming their space bar to lift the barbell. The user can choose their difficulty in the form of the weight, and is given 10 seconds to complete the game, or else they lose. To give the user some feedback, I added a progress bar on the left of the screen and a progressing image of a person lifting the barbell.

Implementation

I first created a class that represented the game, featuring a weight and a set of reusable buttons that started or increased/decreased the game difficulty. I reflected the game difficulty with a changing color for the text and the start and restart had moving text that oscillated to draw the players attention.

As the user plays the game, the image and flame behind the image would progress to indicate how close the user is to completing the game. A sound would play to give a sense of feedback to the user. I also increased the size and redness of the time left text to create a sense of urgency for the player. The image used is a trace of myself, but shaded black to look less awkward.

I controlled the mouse clicks and button presses by game screen state in order to ensure nothing outside the screen was being modified. The shaking and game end time were calculated by taking the current time and adding them to a variable, and I used perlin noise for the duration after a user pressed the space bar to shake the images and display the fire.

Reflection

I enjoyed making this game as I think I was able to make it function consistently with a set style. I think there is some tweaking necessary in terms of difficulty as weights over 300kg feel practically impossible, but someone with fast fingers could prove me wrong. I would also like to see a leaderboard functionality, but outside of the local scope that would require some type of file manipulation or connection to an external database.

Midterm – Reflex Shot

Game Idea

Reflex Shot is a 2D arcade shooting game in which enemies pop up on the screen at random locations and the user has to click them as fast as possible to score points. There is a crosshair on screen at all times and each time a shot is fired a gun fire sound is played. Each game lasts 60 seconds and at the end, the final score, high score, accuracy, number of targets hit, number of targets missed and average time taken to hit a target will be displayed on the screen. The game begins with a starting page which gives the player the option to start of change crosshair size. When the start button is clicked, the game instructions are then displayed on the screen and the user has to click the screen again for the game to start. Once the game ends, the statistics will be shown and the user will have the option to play again.

Implementation

In my code, I had 3 classes: a Game class, Crosshair class, and an Enemy class.

In the game class, I controlled what would be shown on the screen depending on the current stage of the game using functions. In the draw function, I had many else ifs with a variable that dictated which stage was currently to be displayed to decide which function within the class was to be called. Also, the Game class had variables that counted all the statistics to be shown at the end of the game. The screen backgrounds were also loaded within the class.  There were also a few functions to update the score and high score when required.

The crosshair class had two attributes, length and gap size. Each time the change crosshair size button is pressed, these two values are incremented by a fixed amount, but when a certain size is reached, the values are reset back to their original values.  Other than this, there was just the drawCrosshair function which drew the four lines required for the crosshair.

The enemy class had two attributes x and y to determine the position of the enemy on the screen, a function to move the enemy when it is shot by the user and a function to draw the enemy. The moveEnemy function is used to make it seem like a new enemy spawns when one is shot, but in reality the current enemy just moves to a different location on the canvas.

Outside these 3 classes, my mousePressed function was very important since my game uses the mouse as its only input device. I had a switch case for the game.state variable in which each case called a function to decide what each mouse click would do. Inside these functions, I used if statements when I had buttons to detect if mouse clicks were inside the buttons. Similarly, to detect if mouse clicks were on enemies, I used the mouseX and mouseY values to see if the clicks were inside an invisible rectangle around the image of the enemy. This did lead to some inaccuracies in the clicks, though, as some clicks were registered as hits even if they were in the empty space under the enemy’s arm and above the leg.

In terms of sounds, I added a gun draw sound that plays when the game starts. I had a gun fire sound that plays whenever the user shoots, and a body hit sound that doesn’t sound too pleasant but is used to indicate when an enemy is hit. When an enemy is clicked on, both the hit marker sound and the gun fire sound play at the same time therefore the gun fire sound can’t be heard when an enemy is hit. When the user misses, however, it is clearly heard and it is clear to the user that the shot didn’t hit an enemy.

Overall, I’m pretty satisfied with my work and I think it is a fun game to play. Hope you have fun playing it!

Week 6 – Midterm Project

Ideation

For my midterm, I wanted to make some form of pixel art-type monster fighting game in a 2D world. My inspiration for this comes from games like pokemon that I played on my Gameboy as well as newer Nintendo Switch games like Towerfall. I drew up a sketch of what I wanted my game to look like but I was open to making changes so that the gameplay is smooth.

I know this is going to be challenging and quite time-consuming but I want to see how far I can push myself and create a fun game that I and others can enjoy.

Assets

I was thinking of making my own pixel art assets but soon found that I do not have the skills nor the time to learn the skills to make them myself right now. I would like to explore this further in the future but for now, I used assets from Itch.io. I found some player and object and skeleton sprite sheets that are free for non-commercial use. I got sounds from Freesound.org and mixkit.co for all the game feedback sounds and the soundtrack from here. P.S the player dying sound was recorded by me (Professor Aaron thought it would be a nice touch and I agree)

I found this Desdemona font that matched the look I was going for so I used this custom font in my game.

Stage

I was hoping to find a stage online that I could use for my game but I didn’t really find anything that I liked. I did some googling and found something called tilesets which is similar to sprite sheets but for building 2D levels. I use this dungeon tileset that was free to download along with Tiled to create my own basic level.

Movement

I flipped the sprite sheet to obtain movement in the left and right directions with Preview on my laptop. Using the boilerplate code from class that Professor Aaron provided, I was able to get my player up and running.

Attack

This was a bit tricky as I wanted all the attack sprites to loop with a mouse click. I couldn’t figure it out at first because I was using a while loop which made my program freeze. With some help from the class Discord, I implemented it using an attack boolean. Although this increased the amount of code I had, the attack was working fine now. I added a sword slash sound to make it more realistic. If the skeleton is within the range of the player and the player attacks, then the skeleton would collapse into a pile of bones, and bones falling soundtrack would be played.

Enemies

For my enemies, I used the skeleton sprites from Assets and gave it movement. To attack, I created a range where if they detected the player, the attack motion would play and if it lands on the player they would die. The corresponding sound effects are also played when the player dies.

To follow the player, I would simply use their x and y position and move the enemies accordingly. You can see that after a while the enemies will start to pile up, but that is because they are not solid body objects so there is no collision detection. This seemed quite tricky to implement so instead, I added a random change to their speed to make sure they didn’t bunch up into one all at once.

In order to prevent the player from killing all the enemies at once, I added a break after each enemy dies so that only one skeleton can be killed with one mouse click.

The enemies also spawn once every 50 frames, with each new skeleton speeding up, and the game ends once you kill 50 skeletons.

OOP

I created classes for the Player, Skeletons, and the Stage. The stage object is where the whole game plays out. It controls the loading of the player and the enemies and handles the game logic such as showing the start, end, and playing screen. It also allows the player to restart the game when they die or lose.

Controls

w – move up
s – move down
a – move left
d – move right

mouse left click – attack

Game