Week 5 Dev Log (06/11/2022 – 13/11/2022)


Overview Of This Week

This week, my main focus was to create a spell mechanic for my video game by the name of zombie killer boom boom.

Coding Project: Zombie Killer Boom Boom

I managed to get spells to fire from all 8 directions that the player is moving with different numbers from 1-4 on the keyboard that correspond to the appropriate spell. Each spell has it’s own properties such as the speed that it travels among other things. The example of the properties will be show below:

The Properties For The Spells

It is worth noting that the value “manaCost” hasn’t been implemented into anything yet. The values “speed” and “entity” are important for the spells firing in different directions. To check which spell is cast, an if statement will have to check which button is pressed. I will use the example of the basic spell for the following example. When the “1” key is pressed down the if statement below will do its functions:

The Example Of The Basic Spell If Statement

First, the if statement has to check if the Boolean array “spells_Pressed” is not true. This has two main functions: I am pretty sure that Phaser has referencing issues when it comes to sprites being made within the update method (important for destroying the sprite) and, second, this ensures that only one spell is cast per button press; but ensures that the spell will still travel whilst the key is still pressed down. The “entity” value within the “basicSpell” object will now hold the sprite object. The “created” value will turn true, however, it currently has no use but will most likely come in handy when other classes or functions may need this information. The function “shooting_Spell” will be called and pass through the “entity” as well as the “speed” of the “basicSpell” object. The Boolean indexed at 0 will be turned to true to signify that the basic spell has now been pressed and fired. The function to shoot the spell will be shown below:

The Shooting Of The Spell

I chose to use a switch case to retrieve what direction the player is moving which is made in the PlayerMovement JavaScript file. e.g if the player decides to press “A” or “left cursor”, “directionMoving()” will return “left”. The spell will be set the appropriate x and y velocity. Depending on the spell speed from the spell object, it will set the velocity for the spell. Finally each case holds the function “diagonalShooting()” which checks if the player is moving diagonally to set the appropriate value.

As well as pressing the button to shoot the spell, the spell must be extinguished after releasing the button. This is where the check_keys() function is called:

Example Of Releasing The “1” Key

Continuing the example of using the basic spell, This checks if the “1” key is up as well as the Boolean value being true in the “spells_Pressed” array. There has to be a true Boolean as it ensures that the basic spell sprite is created, or else, there won’t be a reference to destroy the sprite object. Everything within the if statement returns the variables to the original values.

Extra things I have learnt or problems I have solved this week

Coding Project: Zombie Killer Boom Boom

Shooting Spells

As shown above, the code shows if the player is moving and shooting. But, what happens if the player stops moving and decides to shoot? The previous moving location will have to be stored and used to shoot the spell in that direction instead of firing nowhere. This problem plagued me for ages in how to implement. I tried to implement it in many ways. The main problem that I was noticing was that I called my movement where the player was shooting and walking rather than just walking. I finally solved it like this:

Checking If Not Moving

This if statement is at the top of the code before any of the spells are set to be read. I added another string value within the “direction_Moving()” function to be returned (“notMoving”) as a default for the switch case that is stored within to check if the player is not pressing any buttons i.e standing still. If the player is moving, the global variable “holdingDirection” will store the string value that is returned. The next step will be show below:

Standing Still

This is an extension of the “shooting_Spell” function shown above. The default of the switch case holds another switch case to check what the global variable holds and repeats the explanation of shooting the spell whilst moving.

Zombies

The zombie sprites also have hit detection with the spell sprites to test if the zombies are hit by the spell. The zombies will also take the appropriate damage from the different spells which is stored in each spell object. If the zombies take a certain amount of damage, they die. The example will be shown below:

The Zombies Losing Health

This method is stored within the “zombie_Man” class. This example is with the basic spell. I used the Phaser physics to test if the two sprites of the spell and zombie overlap. If they do, the zombie will take the damage from that specific spell.

Zombie Losing Health

The first if statement is to show that there are other spells being checked rather than the basic spell. The second if is self explanatory.

I made a game manager to check the status of the game such as the amount of zombies that are dead. When dead the zombie sprites will be destroyed. Once all destroyed, there will be a new wave that spawn. Currently, It is a max of three. The example will be shown below:

Part 1 Of Example
Part 2 Of Example

Plans For Next Week

Coding Project: Zombie Killer Boom Boom

The deadline of the 25th is coming up soon. I will have to finish the whole game by Sunday of next week as I will have to test the game mechanics and write a report of how successful the game is the following week. The current goals are to have a health, mana as well as other properties for the main character; I will have to make a genuine wave mechanic for the zombie. Currently, the zombies don’t follow the player so I will have to make them do it; I will have to make there be different zombies that are resistant to each spell and that is the basic goals that are currently set.

For the stretch goal, I would like to have the different spells interact to make a hybrid spell that can cause interesting effects. For resistances, I would like to try and implement it within a bit flag.


Leave a Reply

Your email address will not be published.