Week 5 (7-13 Nov 2022)

In this week, I focussed on recreating my game after losing it last week. We also covered two forms of collision detection, these being ray casting and continuous collision detection detection.

Recreated Code

Here is a look at how the player was created, along with the code for movement and rotation;

Load sprite sheet
Creating inputs
Creating animation for the player
Places the sprite into a random position in the game world
This line of code sets the position, size and the collision boundaries with the world
This is the players movement code, it also plays a walking animation

I also implemented the reticle as I needed this for the player’s character to face;

Loads the sprite sheet
The animation for the target
Spawns the reticle and makes it play the animation on loop
Sets the origin of the reticle, display size and collision properties

This chunk of code makes it so that when the player clicks onto the game, it will lock their mouse into the game preventing the player from clicking outside of the game. The code also allows the player to press Q or ESC to unlock the mouse if they wanted to tab out of the game. The last bit of this code moves the cursor animation with similar movements as their mouse.

Next bit of code below combines the reticle and player functions to create an animation in which the player faces the reticle.

Collision Detection

We looked at some types of collision detection such as continuous collision detection and ray casting collision detection. Continuous collision detection is where a game object will have a pre-generated collision box which will detect if anything collides with that box. Ray casting is more interesting to me as it turns out that’s how games like DOOM and Wolfenstein 3D display the graphics, it works by shooting rays in directions until it collides with something.

Next weeks plans

The deadline is getting closer and I still need to include features such as an enemy, a win condition and collectables. I think I’ll design the enemy to chase the player with shooting it being the only way to slow it down. The win condition must be tied to the collectables as that will make the game more enjoyable.

Leave a comment

Your email address will not be published.