DEV Community

TechThatConnect
TechThatConnect

Posted on • Updated on

My new side project

Once you gain the basic knowledge to understand a programming language it's still a while before you feel competent with that language. The best way to learn and gain competence is by making something. Then re-making that thing several times because you just didn't like the way it felt the first few times.

I am working on my proficiency with javascript so I decided to make a game. I picked out a clear goal of what I wanted to make and am fumbling through the logistics. I am learning a lot. Let me go over the idea itself in more detail.

the Idea

To make the logic easier to implement I decided to make a turn based game that two people would play together on one device.  I loved RTS type of games like starcraft, age of empires and stronghold growing up so I was inspired by that. Each player would be building a castle producing gold and using that to buy units that will make more gold or attack the other player. To keep things simple I will only have 2 unit types, one for attacking and one for making gold. Each player has a set of 20 hit points and the goal is to make your opponents hit zero before yours does. 

the Goal

To make this game using a functional appoach so that it may be expanded with ease. Publish all the code on git hub and write detailed blog posts about making the game and how it works which will then act as the docs for the project. Doesnt sound to hard right? Now that I have clear goal its time to get to work.

the gameplay

Each players turn will consist of three phases. The first will be when they select which unit they want to produce. Gold is deducted from the player at this point but the new unit will not appear in their list until the following turn. The second is when they decide on actions for their worker units. Workers have 2 actions make gold and sacrifice for hp. When making gold the unit produces 1 gold added to the players wallet the following turn. When sacrificed the unit is removed from playets list and the player gains 1 hp. The hit point is awarded after all other action have taken place for that turn. Note that if a players hp reaches zero before the awarded points from a sacrifice are added the player whos  hp hit zero still looses the game. The thrid and final phase is actons for fighters who can defend or attack. The attack will inflict 1 damage against the opponents hp. However if set to defend a fighter will cancel out the damage from an opponents fighter set to attack.  Both units will then be removed from the players lists. If you set a fighter to defend and are not attacked nothing happens.

So now the goal is layed out. Still not sure what the UI will look like yet but thats for another post. Just working on the basic logic for now using console.logs to test function outputs. I hope you find this helpful or interesting.

UPDATE
Here is a link to the github repo
The following articles will explain how the code works and why I made the choices I did.

Top comments (0)