Monday, July 20, 2009

Draft of GUI Design



The picture above is a draft for the Graphical User Interface (GUI) of my game. The picture is little bit blurry, you can left-click on it to see an enlarged image.

Don't know what should I write for this post. I think the picture is enough clear to explain everything for the in-game interface. However, I should mention something.

The timer is used to countdown for the next wave of enemies. When it reaches to zero (0), the next wave of enemies will automatically appear on the battlefield. The message of enemy description will be shown when the timer countdowns to 15 seconds. It pauses the game for the player to read the message. Player can resume the game by closing the message box.

Player can take the challenge by pressing the button of "Send Next" to immediately send out the next wave of enemies. Player will receive a reward of gold or money by taking this challenge. The number of money depends on the remaining time on the timer. The earlier the player presses the "Send Next" button, the more money the player receives.

There are 4 tabs on the right panel at the bottom of game screen:
Building
-Shows a list of available towers for the player to build on the battlefield.
Add-on
-
Shows a list of weapon add-ons that gives bonus to the attribute of weapon or adds special effect to an attack and a list of equipments that improves the attributes of any tower.
Ability
-
Shows a list of purchasable active or passive abilities that can be added to any tower to gain a new ability for permanent use and a list of instant abilities that can be used instantly by spending money for each use.
Item
-
Shows a list of items (Item of Add-on and Item of Ability) that are purchased or obtained from the dropping of enemies on battlefield and currently in the player's item bag.

Sunday, July 19, 2009

Error Detected on Laser Trail


I have found out that there is an error on the ability of Laser Launcher - Laser Trail in the game demo on the post of "The Excited Moment".

Error description:
The ability of Laser Trail can damage up to unlimited number of target within its duration if the first parameter of Laser Launcher's "Trail" attribute (number of targets) is set to at least 1. In fact, Laser Trail should only damage up to a specific number of targets.

Problem solved:
The Laser Trail can only damage up to a number of targets depending on the setting number in the first parameter of Laser Launcher's "Trail" attribute.

The above-mentioned problem is solved and the updated version of game demo is uploaded to the same post.

Wednesday, July 15, 2009

The Excited Moment


Finally, I can show my game demo!!

This demo shows my current progress of my Tower Defense (TD) game.

Currently, the things I have done are:
-Figure designs of Free Runner (The First Enemy), Missile Launcher, Laser Launcher, Arrow Shooter, Dart Thrower, Lightning Catapult, Shockwave Tower, and Empowering Beacon.
-Actions of Free Runner include moving from one point to another point and turning to another direction.
-Collision detection for Free Runner (This may be unnecessary in my TD game).
-Tiled-based algorithm for reducing calculation purpose.
-Attack detection and animation for all the defenders.
-Special attack ability for all the defenders such as Multiple Shooting, Laser Trail, Split Arrow, Strikesmore, Great Explosion, Multi-strikes and Powerful Signal.
-Weapon upgrade for all the defenders and upgrade for Empowering Beacon.
-Hitpoint display for Free Runner.
-Game Objects Selection.
-Construction and destruction for all types of defenders.
-Control of all defenders to attack a selected enemy unit or a location.
-Game pause. (Player can give commands to all the defenders on the battlefield during the game pause)



Are you ready to kill those Free Runners that are moving around on the battlefield?



Select one of tower images on the left panel at bottom. As the picture above, I am selecting the image of Missile Launcher. Press the left key on mouse to select it.


After that, move your mouse cursor to the battlefield, you will see a half-transparent tower image following your cursor. You can move your cursor to choose a place on the battlefield in order to build the selected tower. If the image suddenly disappears before you build it, it means that you are unable to put the tower on the location. If you do not want to build the tower, press "C" to cancel it.



After you build a tower, you can select it. Firstly, move your cursor to the tower. When your cursor is on the tower, you will see a light purple selection around it. Then, press left key on mouse to select the tower. There is a blue selection representing that you are selecting a tower.


When you are putting mouse over the tower or selecting the tower, there is a red circle around the tower representing the attack range of the tower. Any enemy unit moves into this area will be detected by the tower and becomes one of the attack targets.



Meanwhile, you can see the right panel at the bottom showing the status of the selected tower including its attack damage, attack range, attack cooldown, and special attack ability.

There is an excited thing I should tell you that you can edit the status of any tower.


By editing the number of minimum attack damage, move the cursor to the text box beside "Damage", press left key on mouse, delete the number in the text box and enter the new number. After that, you should remember to press the "Update" button to update the new status. If not, you change nothing.

By the way, if you put the minimum number of attack damage is bigger than the maximum number, the 2 numbers will be swapped so that the minimum number is never bigger than the maximum number. The lowest time for attack cooldown is 0.1 second. The input number for chance is from 0 to 100.

Description of Attributes
Damage-Minimum Attack Damage ~ Maximum Attack Damage
Range-Attack Range
Cooldown
-Attack Cooldown in second, which is the waiting time to start next attack after an attack. (For all types of tower except Empowering Beacon)

-
Attack Cooldown Reduction in second, which reduces the waiting time of attack for the nearby defenders. (For Empowering Beacon)
Number-Number of targets for an attack. (For Missile Launcher)
Trail
-This attribute has 2 parameters (2 text boxes), first one is the maximum number of targets that the laser trail can damages, second one is the duration of the laser trail. (For Laser Launcher)
Number-Number of arrows will be shot on one attack. (For Arrow Shooter)
Bounces
-This attribute has 2 parameters, first one is the number of bounces for the throwing dart, second one is the bouncing range for the dart. (For Dart Thrower)
AoE
-The radius of lightning ball's explosion area. (For Lightning Catapult)
-The radius of empowering area that gives bonus to the nearby defenders. (For Empowering Beacon)
Chance
-The chance to do an extra attack after an attack. (For Shockwave Tower)


While you are selecting a unit, you can press the "Destroy" button to kill or remove the unit and press the "Cancel" button to cancel the selection.

There is a "Add Creature" button on the left panel, you can press this button to spawn more Free Runner at the random location on the battlefield. The number of Free Runner on the battlefield is limited to 20 units. You can press "Q" to see the hitpoint bar showing the life of every Free Runner on the battlefield.


The command for selecting an attack target only works during the game pause mode. Press "Space Bar" to pause the game, you will see that the figure of mouse cursor is changed. Select a tower and press "A", the figure of mouse cursor will be changed to an Attack Symbol. Then, you can select any enemy unit you want to attack. For Arrow Shooter and Lightning Catapult, you can target either an enemy unit or a location. When your tower is targeting at a location, you can press "S" to stop its attack.

Command List
CCancel the tower building selection.
Q
Display the life bar of every enemy unit.
A
Change to Selecting Target mode and select an enemy unit for the selected tower to attack.
S
Stop the current action. This command only works for Arrow Shooter and Lightning Catapult when they are targeting at a location.
Space Bar
Pause the game.


Interesting? Thank you for trying my game demo. If you find out that there is any bug in my game demo, please tell me! I will appreciate you very much. Hope you enjoy it.

Monday, July 13, 2009

Show The True Power


Missile Launcher

Missile Launcher, a basic shooter, which has good attack range and excellent attack speed. It can be said as the fastest speed attacker compared to other defenders. It attacks a target with guarantee hit after a bullet has been shot out unless the target has any ability to evade an attack.

The weapon of Missile Launcher can be upgraded to shoot multiple targets at once. Each level of upgrade increases the number of attack targets by 1. Therefore, every upgrade can be considered as giving the equal attack power as an extra Missile Launcher for a single defender. Although the upgrade for higher level weapon costs a lot of money, but you can save the money in upgrading the attribute such as attack damage, attack range and attack speed for a single defender with equal power as multiple defenders instead of upgrading for several defenders.

Building Cost:275
Attack Damage:35 ~ 42
Attack Range:180 units distance
Attack Speed:1.1 seconds cooldown
Upgrade Name:Multiple Shooting
Upgrade Method:Increases the number of attack targets for an attack.
Upgrade:Level 0
-
Attacks 1 target only.
Level 1
-
Costs 150. Attacks 2 targets.
Level 2
-
Costs 225. Attacks 3 targets.
Level 3
-
Costs 325. Attacks 4 targets.
Level 4
-
Costs 450. Attacks 5 targets.


Laser Launcher

Laser Launcher, is a powerful attacker with good attack range and speed. It also never miss a hit on a target during attack. By using the power of laser, its attack can pierce multiple enemies which are stacking together. When it launches laser at a location, any enemy unit which touches the laser takes the damage. This defender is good in attacking when many enemy units are sticking together.

The laser of Laser Launcher can be upgraded to leave a laser trail on the ground for a short duration after hitting a target. The laser trail has the same damage and attack effects. It can only damage up to a specific number of target. This laser trail is very useful when the enemy units are moving one by one to the same direction. When one of the enemies is shot by the Laser Launcher, a laser trail will be left on the location which the launcher shoots at. The enemy units which follow behind move through the laser trail one by one and take the damage as they are touching it.

Building Cost:320
Attack Damage:30 ~ 32
Attack Range:160 units distance
Attack Speed:1.65 seconds cooldown
Upgrade Name:Laser Trail
Upgrade Method:Leaves a laser trail with the same damage and attack effects for a duration after hitting a target. Any unit which passes through the trail takes the damage and attack effects of the trail. The laser trail can only damages up to a limited number of target.
Upgrade:Level 0
-
No laser trail.
Level 1
-
Costs 75. Damages up to 1 target, lasts 1.5 seconds.
Level 2
-
Costs 150. Damages up to 2 targets, lasts 2 seconds.
Level 3
-
Costs 250. Damages up to 2 targets, lasts 2.5 seconds.
Level 4
-
Costs 400. Damages up to 3 targets, lasts 3 seconds.


Arrow Shooter

Arrow Shooter, is a great archery shooter with piercing arrow that is able to attack multiple targets in a line. The disadvantage of this defender is easy missing on an attack. Besides, it has a short delay to shoot an arrow when it senses a target because it needs to pull arrow on the bow (A bit old style...). The arrow moves to a direction and deals damage to any enemy unit it touches. The damage of the arrow is reduced by 15% whenever it pierces a target. So, the arrow will deal lesser damage for the subsequent targets.

The accuracy is a weakness, but its upgrade helps to reduce this weakness. Each level of upgrade increases the number of arrows by 1 so that it shoots several arrows to the same direction at one time. By using several arrows, the hitting rate is greatly risen up as well as dealing the multiple damage if more than 1 arrow hit the target.

Building Cost:405
Attack Damage:40 ~ 46
Attack Range:140 units distance
Attack Speed:1.85 seconds cooldown
Upgrade Name:Split Arrow
Upgrade Method:Increases the number of arrows for shooting at one time.
Upgrade:Level 0
-
Shoots 1 arrow only.
Level 1
-
Costs 200. Shoots 2 arrows.
Level 2
-
Costs 350. Shoots 3 arrows.
Level 3
-
Costs 550. Shoots 4 arrows.
Level 4
-
Costs 800. Shoots 5 arrows.


Dart Thrower

Dart Thrower, is very powerful in attacking multiple targets. But, it throws dart to a target in a short range. Whenever its dart hits a target, the dart will bounce to the next nearest target if the dart's bouncing range is enough. The dart cannot bounce again after it hits a specific number of targets. The other case that a dart cannot bounce anymore is when it hits air. When it is moving toward a target but before hitting the target, the target is killed by someone else. In this moment, it hits nothing and loses the bouncing ability.

If there are only 2 enemy units moving too near with each other, it is good for Dart Thrower to destroy them immediately. The dart of Dart Thrower is never been wasted unless it hits a dead target. It throws a dart to hits one of them, the dart bounces to hit another one. If the dart can bounce again, it will hit back to the first one for the second time. If it still can bounce, it hits the second one again. Let's say the dart can bounce for 3 times, both of them takes twice damage.

The upgrade of its weapon increases the dart's number of bounces by 1 and bouncing range by 15 units. With the higher number of bounces, the dart can hit more targets. With the longer bouncing range, the dart can bounce to hit the further target.

Building Cost:465
Attack Damage:32 ~ 36
Attack Range:100 units distance
Attack Speed:1.5 seconds cooldown
Upgrade Name:Strikesmore
Upgrade Method:Increases the throwing dart's number of bounces and bouncing range.
Upgrade:Level 0
-
Bounces 2 times in range of 70 units.
Level 1
-
Costs 125. Bounces 3 times in range of 85 units.
Level 2
-
Costs 200. Bounces 4 times in range of 100 units.
Level 3
-
Costs 325. Bounces 5 times in range of 115 units.
Level 4
-
Costs 500. Bounces 6 times in range of 130 units.


Lightning Catapult

Lightning Catapult, is a great destroyer in cleaning a group of enemies in an area. It has a huge attack range and great damage. When it detects a target, it aims the location of the target. Then, it needs a short time to charge the lightning power. After it finishes charging, it launches a lightning ball to the location it aimed before instead of the target it detected. The hitting rate seems to be very low, but when the lightning ball reaches the location, it explodes and deals damage to all the enemies in an area.

The explosion area of the lightning ball can be enlarged by upgrading its weapon. Each level of upgrade increases the radius of explosion area by 15 units.

Building Cost:510
Attack Damage:45 ~ 55
Attack Range:250 units distance
Attack Speed:2.3 seconds cooldown
Upgrade Name:Great Explosion
Upgrade Method:Increases the radius of explosion area for the lightning ball.
Upgrade:Level 0
-
Explodes in radius of 60 units.
Level 1
-
Costs 125. Explodes in radius of 75 units.
Level 2
-
Costs 175. Explodes in radius of 90 units.
Level 3
-
Costs 300. Explodes in radius of 105 units.
Level 4
-
Costs 450. Explodes in radius of 120 units.


Shockwave Tower

Shockwave Tower, is a super eliminator. It attacks all the nearby enemy units in an area around it. When it detects a target, it launches a shockwave around. The shockwave expands in 0.5 second and deals damage to all the enemies it touches.

The weapon of Shockwave Tower can be upgraded to increase the chance for Mutli-strikes, which is doing an extra attack after an attack. When it launches a shockwave, the probability of Multi-strike will be checked to see whether it can successfully do an extra attack. If it is successful, it launches another shockwave. Because the extra shockwave is also considered as an attack, it gains the probability checking again subsequently to see if there is more shockwave to be launched. By this token, Shockwave Tower may do 2, 3 or more attacks at once depending on the chance of Multi-strikes.

Building Cost:540
Attack Damage:25 ~ 27
Attack Range:55 units distance
Attack Speed:2.8 seconds cooldown
Upgrade Name:Multi-strikes
Upgrade Method:Increases the chance for doing an extra attack.
Upgrade:Level 0
-
0% chance. Because no Multi-strikes ability.
Level 1
-
Costs 100. Gives 15 % chance.
Level 2
-
Costs 225. Gives 25 % chance.
Level 3
-
Costs 375. Gives 40 % chance.
Level 4
-
Costs 600. Gives 60 % chance.


Empowering Beacon

Empowering Beacon, is a supporter for all the defenders. It gives bonus attack damage, bonus attack range and bonus attack speed (attack cooldown reduction) to all the nearby defenders which are inside its empowering area of effect. Its upgrade increases the area of effect so that more defenders can get the bonus from it.

Building Cost:750
Attack Damage:+ 5 ~ + 7
Attack Range:+ 25 units distance
Attack Speed:- 0.2 seconds cooldown
Upgrade Name:Powerful Signal
Upgrade Method:Increases the radius of empowering area.
Upgrade:Level 0
-
Area with radius of 80 units.
Level 1
-
Costs 200. Area with radius of 90 units.
Level 2
-
Costs 350. Area with radius of 100 units.
Level 3
-
Costs 550. Area with radius of 110 units.
Level 4
-
Costs 850. Area with radius of 120 units.



Tuesday, July 7, 2009

Tile-based Algorithm


Tile-based algorithm is one of the method to optimize the game. How to say? Because it reduces a lot of unnecessary calculations and increases the game performance.

Many loops of a block of codes slow down the game progress especially doing the complicated calculation for many times. The way to prevent from lagging is reducing the number of loops. So, how to reduce? Tile-based algorithm can solve this problem.

Although by using this method I have to do more works but it can greatly improve the game performance to run smoothly. Firstly, I create a 3-dimensional array. What is the usage of this array? It is used to track the location of every object.

3D Array Structure
Main Array = Rows Array
Each item in Rows Array = Columns Array
Each item in Columns Array = Object Container (Array)



In my game, the world is divided into tiles. Each tile is fixed at the specific area. The "Free Runner" locates in the area of tile (1,2) on the map. Therefore, this object is added into the container in Array[1][2]. When it moves into the area of tile (1,3), it will be removed from the container in Array[1][2] and added into Array[1][3] to update its latest location.



Welcome to my another guest - Missile Launcher (ML)! The red circle around it indicates its attack range. How to get the purple area? Let's say the size for every tile is 100 x 100 unit2 and the attack range of the ML is 80 units. Round up ( 80 / 100 ) is 1. So, the purple area only includes the tile that is 1 unit distance away from ML's location which is (3,3).

There are 4 ships with A, B, C, D in the picture. Ship A can be ignored because it is out of the purple area. Ship B, C, and D become the candidates in checking to see which one is inside the area and become one of ML's attack targets. Congratulate to Ship C that it becomes ML's attack target. Because the distance between it and ML is shorter than ML's attack range, it means the ML is able to attack it.

By using this method, I calculates the distance between the ML and each of the 3 objects only instead of 4 objects in the world. In the other words, if the world has 50 objects and there are only 3 objects inside the purple area. I just need to take the 3 objects to do calculation in 3 loops. I can reduce the time for doing 47 loops. But it increases the work for another part. Whenever any object moves from one tile to another tile, it should update the 3D array by removing the object from its old location and adding into new location.

p/s:
I would like to greatly appreciate the God of Programming - Solid X - a.k.a Acefreakz in giving me the idea of this algorithm. His great idea helps me a lot in optimizing the calculation and game performance. Thanks him very much!

Monday, July 6, 2009

Special Effects


Plain attack is too bored, I must play some special thing. Player can add attack abilities to the defender's weapon. When the defenders have their weapon with add-on abilities, they can effectively slow down the enemies' progress and destroy them as well.

How to add ability into weapon? Player can buy power cards and put them into a defender's inventory to gain new abilities. If player put in more than 1 card with same ability, the ability will be upgraded to be more powerful.

Frost PowerEach attack reduces the target's movement speed and turning speed for a duration.
Flame PowerEach attack splashes the damage dealt on the target to the nearby enemy units.
Lightning PowerEach attack has a chance to deal a critical damage that is multiple of normal attack damage.
Explosion PowerEach attack has a chance to deal an extra explosion damage.
Stunning PowerEach attack has a chance to stun the target, causing it unable to move for a duration.
Corrosive PowerEach attack reduces the target's armor for a duration.
Bloody PowerEach attack opens wound on the target, causing subsequent attack to do more damage than previous attack on the same target for a duration.
Poison PowerEach attack poisons the target, causing it to take damage over time for a duration.
Greedy PowerGains extra money from killing an enemy unit.




The demo above shows the figure of "Free Runner" after it takes any effects. You can select multiple effects at once. Have fun!

Sunday, July 5, 2009

The First Victim


It must have some volunteer runner to show how powerful the defenders are. They are very brave. They have no fear to anything in front of them and just keep moving to the destination. Actually they are just trying to show off their armor and movement speed, and how they evade the attack in order to let others to receive it when they are running in group. Well, I should stop nonsense here, let's see the figure of my first "monster".


I name it "Free Runner". It is the first enemy for testing purpose in my game. But I think its figure is also not bad, it should be qualified to be used in my game. How do u think?

The enemy runs according to the waypoints given so that it know where should it goes. Firstly, it runs toward the first waypoint. When it reaches the destination, it turns its body until facing the direction to the next waypoint then it continues running. The process cycle ends when there is no more waypoint for the enemy to run. What it means? It wins the challenge on race. Player should improve his defense to prevent this case from happening again.




Do you see the picture above? It is not a static image! You can play around on it. This is a simple testing. You can write down your command on the text field in order to control the "Free Runner" to move around. The sample coding can be reference for you to write your command.

Keywords:
move-movement speed
turn-turning speed
waypoint-a set of coordinates that "Free Runner" moves to one by one.

The values for "move" and "turn" must be valid positive integers. You should use "=" to set the value for each attribute. A set of coordinates must be between "{" and "}". Every coordinate must start with "(" and end with ")". You should use a "," to separate the values for x-axis and y-axis for each coordinate. The values for x-axis is from 0 to 250 and for y-axis is from 0 to 150. The first coordinate is starting position and the rest are the subsequent waypoints for "Free Runner" to go.

After you press the "Start" button, your command will be executed. The "Free Runner" will go to every waypoint until it reaches the last waypoint. If you press "Stop", the progress will restart. Have fun!

Saturday, July 4, 2009

Introduction of Defenders


In my game design, there are 7 buildings or defenders. Player can place them on anywhere in the battleground except the path for the enemies to run on. Don't talk so much, let's see those defenders right now!

Attributes of defender:
- Minimum Attack Damage
- Maximum Attack Damage
- Attack Range
- Attack Speed
- Upgrade / Power Cards
- Abilities

The defender deals a random number of damage in the range of minimum and maximum attack damage. Any enemy who goes into the defender's attack range will be the attack target. The defender with higher attack speed needs the lesser time to ready the next attack. Player can insert the cards into the defender's inventory to improve its status as well as gain new abilities.




1. Missile Launcher


This defender is the basic attacker that can only attack a target in one time. It can be upgrade to be a powerful attackers that can shoot multiple targets in one time.
(Upgrade Name: Multiple Shooting)



2. Laser Launcher


This defender shoots a laser to damage a target. If other enemies move too near to the target and touch the laser, they also take the same damage. This defender can be upgrade to make its weapon to be more powerful. After its weapon upgrades, whenever it shoot a laser on a target. The laser leaves a trail on the ground for a short duration. Any enemy who walk through the laser trail takes damage as well as effects. The laser can damages up to a specific number of targets.
(Upgrade Name: Laser Trail)



3. Arrow Shooter


This defender launches an arrow to a direction, dealing damage to the enemy units the arrow pierces in a line. Whenever the arrow pierces a target, it has 15 % reduction of the current damage to the next target. This defender can upgrade its weapon to shoot multiple arrows to a direction in one time.
(Upgrade Name: Split Arrow)



4. Dart Thrower


This defender throws a dart to a target. After hitting a target, the dart bounces to the nearest enemy unit which is within its bouncing area and continuously bounces until it hits a specific number of targets. The upgrade of its weapon increases the throwing dart's number of bounces and the bouncing area.
(Upgrade Name: Strikesmore)


5. Lightning Catapult


This defender launches a lightning ball to a location. When the lightning ball reaches the designated location, it explodes and deal damage to all the enemies in an area. The upgrade of its weapon increase lightning ball's area of explosion
(Upgrade Name: Great Explosion)



6. Shockwave Tower


This defender strikes all the surrounding enemies which are inside its attack range. The upgrade of its weapon rises the chance for every attack to do an extra attack. An extra attack also has the chance to do more attack. Therefore, it can do several attacks at once if the chance of Multi-strikes is high.
(Upgrade Name: Multi-strikes)



7. Empowering Beacon


This is a supporter for those defenders. Increasing the number in its status is giving bonus to those nearby defenders inside its area of effect. For example, this beacon has 10 point of attack range, it means that all the nearby defenders gain extra 10 point to their attack range. Its upgrade increases the area of effect.
(Upgrade Name: Powerful Signal)


The Birth of My Tower Defense


My big dream is to create a complicated game that is able to show off my programming skill. Anyway, my game should be full of excitement so that it will not be too bored. The most important thing is my game must be able to give me a lot of difficult problems on programming which allow me to use my brain. Therefore, I love game design as well.

I love mathematics and algorithms so much because I knew that they are very important in creating a game. Algorithms is knowledge. Nowadays we can find many algorithms on the websites to be our reference in order to solve any problems. But, I prefer to think and find out my own algorithm for solution.

Before the idea of this tower defense game, actually I want to create an adventure simulation game (SLG). Player can collect heroes during his journey in game. Each hero can upgrade and carry items to be stronger and gain new abilities. During battle, it is in turn-based SLG style. Player can strategically control his army to move and attack or achieve tasks. This idea was on my mind many years ago but until now I still have not yet start to do it. The idea is too insane for an individual work. It needs many manpowers and time. When I am thinking to begin this project, I suddenly feel nightmare and lazy to start. I think I should make a mini game which needs not terrible much time to complete. Thus, this tower defense is my current idea.

I create this blog with the purpose of sharing my game to as many people as possible. I wish to gain more comments and suggestions from my blog readers so that I can try my best to improve my game. Besides, I also want to note down the history and progress on my game as well as game documentation.