Feb 13th Post

Updating Schmeat vs. Greens.

By JAXON G February 13th,  2023, 12:57 a.m. PST

I spent the day working on an update for Schmeat vs. Greens, which is the most recent project I started.  It's a tower defense game, the game is coming along nicely.  So far I've worked on it for 6 days, and most of the game's functionality is in.  Today I added tower upgrades and some other stuff, you can find the update's details here.  The main part of the update was the tower upgrades, which to add there was a variety of things needed for it to function the way I wanted.  Starting out I added a canvas, with a few text objects and a couple of buttons, one of the buttons is used for upping the fire rate speed of the tower, and the other ups the damage.

After adding the text stuff I had to code it.  Starting with adding damage and speed levels to the towers.  The way I did this was I had an int variable for the current level of each, and another int for the current experience value out of the final variable, which is the max level up exp value.  To make the calculation for the max level-up value(on the damage side), I used the line below.

This line takes the current damage level of the tower times 10 and multiplies it by 1.09 to the power of damage level.  This variable is then used when checking if the player has enough gold to level up the damage of this tower.  The other thing that goes into checking the gold needed to level up the damage is the current experience variable that was mentioned earlier.  I wanted the towers to be able to slowly get better over time, so I added code to give experience for certain actions.  On the damage side, the experience is given every time the tower fires, or triggers(for the towers that don't fire projectiles).  This just adds a very simple change to checking if the player has enough to afford the level-up.  The code went from "if(gameManager.currency >= nextLvlDamageCost)" to "if(gameManager.currency >= nextLvlDamageCost - LvlDamageCurrent)" then if the player has enough gold or "currency" it adds a level to the damage level variable, and runs a calculation function.

The calculation function just runs that previously shown line, and calculates the new damage value, which is upped by about 5% per level up.  Since this is rounded to the nearest whole number it doesn't really affect much in the current update because the damage numbers and enemy healths are too low.  But that will be changed in the coming updates, back to the function, it then checks if the canvas that holds all the buttons and text objects is active.  If it is active then it sets the text of the two different text objects that have to do with damage, which is the cost and level number.  Other than that, that's pretty much how it works for the damage, then it's just pretty much duplicated to the speed side with some minor changes.  Also, my code probably isn't too great, because I've only been "learning" how to code for about a year, this is just more for me sharing what I did, so I should probably not try to explain stuff, but whatever.

The Game Can Be found here.

If you like my games and want to support the quest toward survivability consider tipping me on Ko-fi, it is greatly appreciated.