This project is read-only.

I’m a big fan of Tower Defense games and I’ve always wanted to build my own. The main problem with that plan is that I’m not a developer. Script TD was born as a way to abstract the programming and create a Tower Defense engine that could allow anyone to create a TD game with some simple scripting.

Using the Script TD project, you can follow along with me as I walk through each of the elements of the game. By changing the graphics and the attributes of the maps, towers, and creeps, you too can make your own Tower Defense game, and even sell it in the Windows Phone Marketplace. If you’re also a developer you are free to extend Script TD to include new features and additions. Script TD is written so that anyone familiar with any type of scripting would be able to create a Tower Defense game. So let’s get started. We begin by going through the directory structure of the project.


This is the primary directory for game content. If you’re a designer, this is likely the only directory you’ll be working in.


The Audio directory includes two folders, one for Music and one called SFX for sound effects. The music folder is where you would put the music you want to play at the title screen. SFX directory includes game sounds like projectile shots and hits.


The Data directory is the store for Enemies, Maps, Towers, and Game UI. The root of Data includes Maps.xml.


This XML contains the maps that make up your game. In our project it defines 5 maps, 1.xml through 5.xml. We also comment which prerequisite each map requires.


This directory contains all the enemies you’ll have in your TD game.


<Creep ID="flyerfast" CanFly="true" Speed="2" Health="150" Worth="1" Texture="flyer-fast.png" DeathSoundID="29_Fast_Flyer_Death" SpawnSoundID="28_Fast_Flyer_Spawn"/>

This is a typical XML for a “creep” or tower defense enemy. If you want to create a new creep class, you simply create a new XML file like this one. It includes the following attributes:
- SpawnSoundId – This is the sound this class of creep makes on spawn. To use you simply reference the name of the sound file in \Audio that you want to play.
- DeathSoundId – The name of the sound file in \Audio to play when this enemy is killed. - Texture – This is the image for this enemy. To use you reference the name of the image located in the Textures\Creeps\ directory.
- Worth – This is how much money you get for killing this creep.
- Health – The number of hit points required to kill this creep.
- Speed – This is how fast this creep moves.
- CanFly – This is a true or false attribute for whether this is a creep that is ground based or if it can fly over towers.
- Id – The name we’ll use to reference this class creep in other areas.


This is the directory for XML files that define the UI of the game. For typical non-developers, the only things you would change in these files are the position of buttons and the name of the image used to represent the buttons.


This defines the image to use on the background and the text to present when someone is defeated in a TD map.


This is the list of high scores and what image is shown in the background.


This is a significant file in that it defines what your game screen looks like when playing. It includes things like: <Visual> - This node includes the play screen, or the background image behind your play data as well as placement and color of the play data attributes Cash, Lives, Points, and Wave number. Other options include placement of all the buttons in the play screen, like Options, Pause, Next Wave, and Main Menu as well as the row of towers, in our case the 5 used in this demo project. Remember if you create a new creep class, you’ll also need to define in here where the button for that tower should be as well as what image to use for it, and what image to use if it is unavailable.


This is the UI for the level/map selecting screen.


This is the main screen that comes up when the game is loaded. You can define the background image used under the Visual>Image element. Script TD has 5 buttons on the main screen; Resume (in case you were playing a game and tombstoned), Play, Help, High Scores, and Quit. Location of these buttons can be changed with each buttons location attribute.


This is the options screen seen from the Main Menu or when the gear is clicked while playing a game. The Options screen background can be changed through the Visual>Image element. Buttons include volume controls and show grid.


This is the UI for the menu seen around a Tower when selecting it in a game. It currently has two options; Sell and Upgrade.


Victory is the screen shown when a player whens the level.


The Maps directory stores the files for each level in your Script TD game.


1.xml is a typical Script TD level. If you’re making a Script TD game, this is where you will spend most of your time. In this file you will define the level, place entrances and exits, set the background image and define the waves of creeps for the entire level.


FocusColor="128,128,128,255" NumLives="10"
BackgroundTexture="Map5.jpg" StartingCash="100"
FriendlyName="Mission 5"
- MapStartSoundID – This is the name of the sound file in \Audio\SFX\ that plays when the level loads and starts.
- WaveStartSoundID – The sound that plays when a new wave is released.
- DefeatSoundID – The sound that plays if the player loses this level.
- VictorySoundID – The sound that plays if a player wins the level.
- NumLives – The number of lives left. This counts down for each creep that makes it off the map without being killed.
- BackgroundTexture – Background for the current map, references a file located in \Textures\Background.
- StartingCash – How much money you start with on this level.
- Friendly Name – The display title for this level or map.
- MapID – What Script TD knows this map as. </map>


Special Cells
<Cell Y="5" X="0" Type="Entrance" CellID="spawn"/>
<Cell Y="5" X="18" Type="Exit" CellID="exit"/>

Special Cells is a container for map features like walls or unbuildable areas on a map. It is where you define the entrance(s) and exit(s) of the creeps. They can be placed anywhere in the 11x19 grid using the X and Y attributes.

There are currently three types of special cells;

- “Entrance” – Each wave has an assigned entrance that uses the name defined in this types CellID attribute. You can make multiple entrances and exits and have waves come and go through any combination.
- “Exit” – A named door that any given wave can be assigned to leave through.
- “Obstacle” - Any cell on a map can be blocked by using the attribute “Obstacle”. In designing a map, you might use the Obstacle attribute to create a wall that runs across the middle of your map. The entrance and exit could be on either side of the wall. The creeps would then take the shortest path to the exit. Just make sure in the end the creeps have at least one clear path to go to the exit through. Obstacles can also be used to create Tower Defense maps where the creeps are “on rails” or only follow one specific path from entrance to exit.

While not implemented in the current embodiment, things like sand that slows the creeps could be implemented in Special Cells. It is good practice to have the features defined in Special Cells shown in the background graphic for your map.

Allowed Towers
<Tower MaxLevel="3" ID="gun"/>
This element defines which towers are allowed in the map. The Tower has two attributes;

- “MaxLevel” – This is how many times this tower can be upgraded on this map. The characteristics of tower upgrades are defined in the xml for each tower.

- “ID” – This is the name of the tower, in our project we have 5; Gun, Rocket, Missile, Laser, and Earthquake.

<Wave HealthMod="1" WorthMod="5">
<Creep TimeBetweenMs="1000" Number="15" Exit="exit" Entrance="spawn" CreepID="landBasic"/>

Waves are the timed groups of creeps that emerge throughout a level. A map can have any number of waves. The Waves>Wave attributes change the properties of the creeps contained within. As the game continues, players are making money and using it to create mazes of upgraded towers. The two modifers in the Waves>Wave element allow you to control the hit points on waves and the money the players receive.

- HealthMod” – This changes the amount of heath points of a creep. If a creep has 100 hit points and a HealthMod of 1, the creep has 100 hit points. If your HealthMod is 2, they have 200 hit points. You can use decimals to fine tune gameplay, making a game that is hard enough to be fun yet still be able to win.
- WorthMod” – Worth mod works the same way as the HealthMod but with the amount of money a player makes by killing the creep.

This element includes lines of creeps that are contained in the wave. You might have one line with 1 very powerful creep, as in a boss. Or you might have multiple groups of creeps that pour out by the dozens in the case of a final wave in a game. Typically you’ll have one line representing 10-20 creeps in a wave. Let’s look at one below.

<Creep TimeBetweenMs="1000" Number="15" Exit="exit" Entrance="spawn" CreepID="landFast"/>

In this case we will let out 15 “landFast” creeps that were defined in \Data\Enemies\ directory. They will emerge 1 second apart. They will enter through the entrance created in the <SpecialCells> element above and will exit through the exit you define. This line can easily be tweaked to send any number of any creep type you have created out of any entrance, at any rate, heading toward any exit.



This directory will contain the definitions of the towers available in your Script TD game.


A tower definition will define what type of weapon it is, what sounds it makes, what it looks like, and the effect it has on an enemy. Under the Tower element, the tower characteristics are defined by Level nodes.

<Tower WeaponType="DumbProjectile" ID="rocket">
<Level HitSoundID="04_Explosion"


WeaponType defines what type of weapon this is. A gun and a canon may have different graphics, costs, and damage, but they are basically the same weapon – DumbProjectile. In Script TD there are four weapon types; DumbProjectile, SmartProjectile, Laser, and RadialShockwave.

ID lets you name this type of tower. This is the name that you’ll use in the Creep elements in the map XML to call this creep to release.

This starts the first Level element. Everything contained in this node will apply to this tower the moment it is placed in use. Additional levels can follow that allow the placed tower to be upgraded. Simply copy your first level and decide how you want it to upgrade. You can have upgrades use different images for projectiles, different sounds, and of course different ranges and damage levels.
HitSoundID - This is the sound made when this tower hits a creep.
ShotSoundID – The sound made when this tower shoots.
UpgradeSoundID – The sound made when this tower is upgraded.
SellSoundID – The sound made if the player sells this tower.
BuildSoundID – The sound made when the player builds this tower.
HitAnimationFPS – The frames per second in the hit animation.
HitTexture – This is the image used on hit.
CanShootLand – Whether this tower can shoot a land creep or not.
CanShootFlying – Whether this can shoot air-based creeps.
ShotSpeed – The speed of the shot from this tower at this level.
ShotTexture – The image to use for the projectile at this level.
Texture – The image to use for this tower at this level.
MaxRange – The maximum range of the tower at this level.
MinRange – The minimum range of the tower at this level. Some towers you might want to be able to hit creeps that are very close, as in the case of artillery.
ReloadTimeMs – The amount of time it takes to reload the tower weapon at this level.
Damage – The amount of damage the tower causes at this level.
TimeToSellMs – How long it takes to sell a tower. 0 will sell the tower immediately, though you may want to take longer to dissuade players from selling towers rapidly.
TimeToBuildMs – The amount of time to build a new tower, or to upgrade if this is an upgraded level. The tower is inactive during this upgrade time.
Cost – This is the overall cost of this tower to initially place, or the cost to upgrade this tower for this level. Typically upgrades get progressively more expensive.


This is the directory where you’ll put all your images for backgrounds, buttons, creeps and towers.


These are the backgrounds for the main menu, level select screen, loading, and the bar at the top of the game play screen.


These are the buttons used in the game. They include the play and fast forward buttons, next wave, and options.


This is where you’ll put the images used as creeps in your Script TD game.


This is where you place your help screen images, you can create as many as needed to teach players how to play your game.


The explosions for projectiles go in the HitEffects directory.


The Maps directory contains the backgrounds for all of your levels. In addition to the 665x385 map background, you should have a 200x150 iconic image that is used in the level select screen to play that map.


The Towers directory contains the images for each Tower, including images for each version of the upgraded tower.


The Weapons directory contains the images for each shot that comes from a tower.


Last edited May 27, 2011 at 9:33 PM by LarryLa, version 1


No comments yet.