Midterm Progress

Game Idea

My game is going to be a 2D arcade shooting game in which random enemies pop up on the screen and the user has to click them as fast as possible to score points. There will be a crosshair on screen at all times and each time a shot is fired a gun fire sound will be played and there will also be some background music. Each game will last 60 seconds and at the end the final score, high score and average time taken to hit a target will be displayed on the screen. The game will begin with a starting page in which the name of the game (which I haven’t decided yet) will be displayed and the user will have the option to start the game, change the 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 actual game to start. Once the game ends, the statistics will be shown and the user will have the option to play again.


I started by creating a class for the Game in which I would store an integer variable to indicate the current state of the game (state = 0 means menu page, state = 1 means the actual game starts, and so on). This would make it easier to transition from one game state to another and would make it easier to be able to restart the game once it ends without having to re-run the code. I also added a high score variable to store the highest score in the current session. I also made a crosshair class so the user can change the size of the crosshair in game and created a draw function inside the class to draw the crosshair at all times during the game wherever the mouse pointer is.

After this I downloaded an image from this link
to use as a background for my menu screen. The image had a resolution of 1920×1080 so I changed my canvas to a size with the same aspect ratio to make the image not seem stretched or compressed.

I then started working on the buttons for my menu screen and used rect, text and a lot of if statements to do this. Then I worked on my mousePressed function, which would have several parts to it depending on the current state of the game. I also created separate functions to be called within the mousePressed function so that not all my if statements will be in my mousePressed function.

In mousePressed the first thing I did was store the mouseX and mouseY variables in two separate variables just to make the mouse clicks slightly more accurate, because mouseX and mouseY will be changing very fast in the game. I then pass these two variables into the relevant functions as required.

I am using an array of size 3 so that there will only be 3 enemies on the screen at any given moment. As for the enemy hitboxes, I am using a hypothetical rectangle around the png of the enemy to detect if the user clicks on the enemy successfully.

So far I’ve finished the starting screen, the instructions screen and most of the actual game.
Enemies are generated at random locations on the screen and if the mouse is clicked inside any of the enemy hitboxes and the score is adjusted accordingly. Now I have to add all the sounds and make them play on each mouse click and each time an enemy is successfully hit to add feedback and create the game over screen. I also have to add backgrounds to the different game states.

Leave a Reply