The Fifth Blogpost

Hello and welcome to my fifth and also last blogpost. To be honest I have not done that much since last blog. It’s been mostly polishing and adding the few things that needed to be implemented before the beta.

Either way, today I will be talking about our mana that you can use to either teleport to the mouse position or you can press space to use your power up which increases your fire rate and your projectiles also has increased movement speed. The teleport costs one mana and the power up costs 3 mana. After a certain amount of time you get one mana back.

But what I have been focusing the most on this week is the restiction of using your power up if you do not have enough mana. It has been a little complicated because I did it in the wrong way in the beginning.

The first thing I did was to just bring the variable from the teleport script to the different scripts that I needed the variable in by defining the script and then naming it for the script I was trying to use it in. ”Teleport tp”. And then I was just typing ”if the mana is higher or equal to 3” use this function(But in programming language ofcourse  ;))

The problem now was that I had just used the variable ”mana” so there was nothing checking how much mana I actually had all the time which did so that the function was never called if I pressed the space button.

What I did to fix the problem was first of all. I created an integer in the different classes that needed to know what mana it is. I also created a player object. Then I set that integer to be equal to the mana in the teleport script that was used in the player object. I used that row of code in both the start function to get the correct starting value and in the update function so that it would all the time check how much mana I had.

This was kind of brief but I really did not know what to talk about.

Hope that you learned something. Peace!17199989_1385107881511245_1012117184_o.png

 

About Oscar Berggren

2016 Programming