I have built a bit of a tower defence prototype, but I can’t post it up here yet because this blog is still hosted on wordpress.com for now and can’t display flash content. For what it’s worth, it is a simple example of a tile map with enemies (spheres) spawning on one side and attempting to get to the other side while several towers (cubes) fire bullets (small spheres) at them constantly. Here’s a screenshot.

What I’m going to do in this post though, is go over some of what I’ve learned, as well as how I’m structuring the project a bit. Note that I’m not actually copy/pasting my code from the project for this. It’s more to show the structure and how I’m going about things, rather than the real code in my project.
To start off, I’ll remind you that I’m using Flare3D for this. This post isn’t going to go into how to set up and use Flare3D, but I might make a post about that later. For now, you just need to know that there is a Scene3D object that you add various Pivot3D objects to, to build the scene. Pivot3D is the basic visual object within a scene, which I’ll be extending to build various game classes. Once initialized, Flare3D handles the rendering of any objects you’ve added to the scene, and fires off an UpdateEvent every frame where you can do things like move objects around, handle user interaction, etc. I’ve decided to give each game object the ability to update themselves, rather than having a single update function that would have to loop through each object to update them all, which would get really verbose and complicated. To do this, I am creating an Entity class that extends Pivot3D and listens for the scene’s UpdateEvent.
public class Entity extends Pivot3D
{
private var myScene:Scene3D=null;
public function Entity()
{
super();
}
public function spawn(startX:int, startY:int, startZ:int):void
{
myScene = Engine.scene;
myScene.addChild(this);
setPosition(startX, startY, startZ); // inherited from Pivot3D
myScene.addEventListener(Scene3D.UPDATE_EVENT, onUpdate, false, 0, true);
}
private function onUpdate(event:Event):void
{
// override to update your Entity
}
public function despawn():void
{
myScene.removeEventListener(Scene3D.UPDATE_EVENT, onUpdate);
myScene.removeChild(this);
myScene = null;
}
}
Note: Engine is a class I’ve built within my project that I won’t be detailing here. I am, however, using a static scene property on it to get a reference to the game’s Scene3D instance.
That creates a basic Entity that you can spawn or despawn at will. For non-static entities, you’ll need to extend this and override the onUpdate function to bring them to life. I’m not going to go over all the classes, but lets do the Actor class, which we’ll extend even further to create a Tower class. Actor will be used to provide some basic properties that classes like Tower and Enemy will share.
public class Actor extends Entity
{
public var maxHealth:int;
public var curHealth:int;
public var sightRange:int;
public var attackRange:int;
public var attackSpeed:int;
public var attackDamage:int;
public var attackDelay:int;
public var currentTarget:Actor;
public function Actor(health:int=100, sight:int=50, range:int=50, speed:int=50, damage:int=50)
{
super();
maxHealth = health;
curHealth = maxHealth;
sightRange = sight;
attackRange = range;
attackSpeed = speed;
attackDamage = damage;
currentTarget = null;
}
override public function spawn(startX:int, startY:int, startZ:int):void
{
super.spawn(startX, startY, startZ);
attackDelay = 0;
curHealth = maxHealth;
}
private function shoot(target:Pivot3D):void
{
// function that will create/reuse a bullet object and fire it at the target.
Engine.spawnBullet(getPosition(), target, range);
}
}
Not much to the Actor right now, but it will save us some time later and avoid duplicate properties in both the Tower and Enemy classes.
public class Tower extends Actor
{
public function Tower(health:int=100, sight:int=50, range:int=50, speed:int=50, damage:int=50)
{
super(health, sight, range, speed, damage);
}
override public function onUpdate(event:Event):void
{
shootDelay--;
var needsTarget:Boolean = false;
// Vector3D.distance() is a Flare3D utility function to find the distance between two Vector3D positions
// getPosition() is inherited from Pivot3D and returns the current x, y, and z properties as a Vector3D object
if(currentTarget == null || Vector3D.distance(getPosition(), currentTarget.getPosition()) > attackRange)
{
needsTarget = true;
}
if(needsTarget)
{
currentTarget = getTarget();
}
if(currentTarget != null)
{
lookAt(currentTarget.x, currentTarget.y, currentTarget.z); // inherited from Pivot3D
if(shootDelay <= 0)
{
shootDelay = shootRate;
shoot(currentTarget); // inherited from Actor
}
}
}
private function getTarget():Actor
{
// Engine keeps an up to date Dictionary of enemies as they spawn and despawn
var enemies:Dictionary = Engine.enemies;
for each(var enemy:Enemy in enemies)
{
if(Vector3D.distance(getPosition(), enemy.getPosition()) <= attackRange)
{
return enemy as Actor;
}
}
}
}
I am overriding the onUpdate function from Entity to have our tower search for enemies within it’s attackRange and shoot at them. I have made getTarget() a separate function so that when we start to extend this Tower class to make more specific towers, we can override getTarget() so that they can prioritize targets differently. The default here simply prioritizes the “oldest” enemies, aka it targets the first enemy it finds in the Dictionary.
We could now create specific towers such as Archer, and define default health, attack range, etc. as well as customize things like how they prioritize targets and, of course, use the inherited Pivot3D capabilities to load in appropriate 3D models and animations, etc.
So that’s the basics. I will eventually get this blog moved over to a proper webhost so I can upload the prototype for you to see. In the meantime, I have it working on an Android tablet. Let me know what you think of how I’m doing things, or if you’re working on a project of your own, if this has helped you out at all.
I am in the process of putting together a bit of a game prototype, but I promised I would post more details on the Tower Defense designs so here I am.
As a bit of a recap, the initial release of the game will be a fully featured isometric 3d tower defense game;
The concept behind it is that you are in charge of a small group that has been stranded on a mysterious island after surviving an apocalyptic event. You could possibly be the last survivors of the human race. You have set up a rudimentary camp but quickly draw the attention of the native wildlife and are attacked. Your job is to defend your camp from the hostiles so that your civilization has a chance to survive and rebuild.
Each level in the game has you defending your growing city from larger and larger threats. You start off with only a few combat-worthy men that you can deploy strategically around your camp. As the levels progress, your city trains a militia and obtains the resources required to build more permanent defenses.
Note that unlike many tower defense games, the enemies fight back. Most of them will attack and damage your towers, and kill your men, if you don’t stop them.
The game will have day and night cycles. Typically you will do the majority of your building and preparation during the day, and then the enemies assault you at night. Only certain actions can be performed while the assault is happening, for example you can give your units/towers orders, but you can’t build, recruit, or repair anything. The time progresses steadily, giving you a limited time to work before the next attack arrives. If you finish your preparations quickly, there will be a button to instantly advance the time to dusk. Of course, you will also be able to pause the game at any point, but the map will not be visible when paused so you can’t use this to do more work or planning in the limited time.
Tower/defense progression example:
Swordsmen (limited at first)
Militiamen
Archers
Spearmen
Simple/makeshift wooden walls
Wooden gates
Wooden archer towers
Swordsmen (not limited)
Crossbowmen
Knights
Wizards
Catapults
Ballistas
Squads of the above units
Enemy progression example:
Wolves and other animals
Goblins, kobolds, or similar creatures
Savages, Orcs, Undead
Centaurs, Minotaurs, Harpies
Demons and devils
Dragons
In this version of the game, you gain resources steadily over time rather than gaining gold for defeating enemies. You can use these resources to train defenders, build, or research upgrades. Later, in an expansion, you will be required to gather/harvest these resources yourself as part of building your city, rather than having them simply increasing on their own.
Resources will include:
Food – all units have a maintenance cost in food
Wood – basic buildings and weapons cost wood
Stone – strong buildings cost stone
Iron – advanced weapons
Different towers will have different attack types, attack ranges, and do different damage amounts, as well as having different defense values/armor and durability/health. In most tower defense games, all the towers are ranged, but here not all are. Melee units are useful to place in choke points like gates. They tend to be significantly tougher than other units, and do more damage, to make up for their lack of range. Units can be told to either hold position or move to engage targets, which can be useful for using melee units to defend a larger area.
Walls can be built to block enemies, but your city always needs access to the outside world, so you will need either an open path or a gate. Units can be placed in these choke points to block enemy advancement, but be careful, enemies don’t block each other, so your defenders can be quickly overwhelmed if you’re not careful. Also, intelligent enemies may realize that it might be easier to break down the wall than to fight through your tough guards.
Many of your towers/defenders will have optional upgrades that cost more resources but can improve their effect dramatically. Archers, for example, will use wooden arrows by default, but can be changed to use flaming arrows (attack slower but add fire splash damage) or stone arrows (cost a little stone, but do more base damage to one target) – in this case, these upgrades are mutually exclusive but not all would be. These upgrades are selected when the unit is recruited or can be upgraded later, but these usually can’t be downgraded later.
All enemies will move differently and have their own tactics. For example, wolves travel in packs, so instead of attacking one at a time, they will group up, if possible. More intelligent enemies may walk around the outside of the range of your towers to avoid fire, instead of running in a straight line towards their target. Also, enemies wont be attackable by some towers, such as flying creatures that your swordsmen can’t reach. Others will be resistant or immune to some damage types, such as devils that are immune to fire and therefore take less damage from your archers’ flaming arrows, and no damage from your wizards’ fireballs.
Gameplay
Players receive resources at a predetermined rate on each level, and must spend these strategically to maximize their defences. They might choose to deploy an extra archer, or to upgrade an existing archer to deal splash damage. Each choice might be more or less effective on different levels since every enemy has strengths and weaknesses as well.
The city has scouts that give the player some basic information about the next wave, such as enemy types and rough indicators of their numbers, but these are purposefully vague so there is always an element of surprise. On easier difficulties, this information is more reliable. Once an enemy type is encountered, there is an in-game reference to help track their stats.
There will be tons of achievements in the game, for discovering enemy types, killing large numbers of enemies, training large numbers of troops, beating levels with interesting and challenging troop combos, and so on. You will be able to share your achievement unlocks with your friends, as well as challenge them to get those same achievements. Some towers and upgrades are unlocked by gaining certain achievements.
So, what do you think? Does this sound fun? None of this is set in stone, and I’d love some feedback to help evolve these ideas.
I’ve mentioned that I plan to build the game in several stages and I thought I’d go over these plans in a little more detail, so here goes… Note that this is very high-level. None of this is set in stone, and I’d like your feedback to help iterate on everything here. Also, at the time of this writing, anything beyond the initial release is fairly far in the future. Splitting the game into multiple releases like this is being done for the purpose of keeping things manageable. The initial release, for example, is a fairly simple game for a reason. It is not supposed to be a full MMO at this stage.
Initial Release
The game will start out as a Tower Defense game. You will be able to play a “custom game” where you can simply pick a map and a difficulty and go, but the real game is in the campaign mode. In campaign mode, you are stranded on a strange island and are forced to survive. You’ve established a basic settlement but are constantly being harassed by the island’s indigenous life.
In each level of the campaign, your settlement grows, but you also attract the attention of more dangerous creatures on the island. You will start battling against basic pests, but quickly are besieged by predatory animals and eventually intelligent and exotic creatures. The “towers” available in the game will evolve as you advance as well, starting as basic troops such as archers and militia, but as your civilization and resources grow, you can start to build actual towers and battle emplacements, city walls, and so on.
The first release (maybe some sort of beta) will have fairly simple enemies and tower types, but I have many ideas for interesting innovations that will help make the game stand out from the many tower defense games out there. I will go into more detail about the tower defense design decisions in another post.
Second Release
The second step will be a direct expansion to the tower defense game. This will give the player control over the settlement that they’re working so hard to defend. It will add city-building mechanics to the game in a new game mode. The player will need to gather resources and build up their settlement between attack waves. This will include management of food, building materials, labour, and so on. Something of a tech tree will be introduced, letting the player unlock new types of troops and towers by constructing and upgrading different buildings.
Once again, the initial release of this system will be fairly basic, giving access to a small portion of the planned tech tree and feature-set. This will allow the core mechanics to be polished through player feedback before adding too much complexity.
Third Release
Release number three will take things in a different direction, adding RPG mechanics and bringing the experience online. This will follow the original game almost like a sequel, taking place after the original tower defense game has finished. The attack waves have slowed and you play a character that gets to strike out and explore the island that is your new home. You will be able to team up with other players to explore, complete quests, and defeat epic monsters.
This step will introduce the majority of the social features that will be the game’s focus and transform it into the Persistent World Social Roleplaying Game that it is designed to be. Some of these are character advancement and customization, and a complex guild system.
Fourth Release
Once players have explored a significant portion of the world, this release will allow them to clear out and claim land for themselves. When they do this, they bring the game full circle, starting the city building tower defense game over again but this time with more investment, more risks, and more rewards. These new cities will be managed by entire guilds rather than a single player, and the guilds will be free to set up their own political systems and to hand out responsibilities as they see fit. As the city grows and is upgraded, it will open up advancement potential for it’s players. For example, building and upgrading an archery range in your city will allow your guild mates to learn archery and learn advanced archery techniques.
Players will be able to take part in the defense of the city, in addition to the standard defense emplacements that the city builds. Attack waves will act similarly to what many other MMOs call raids, except obviously they will start out very easy and will be accessible to all players. The attack wave’s strength will be determined by the city’s size, allowing players to control the difficulty somewhat, so they don’t get overwhelmed when they’re not ready. Attacks will usually occur once or twice a week, and will, similar to raids in current games, be scheduled. This allows players to defend when it’s convenient for the guild. One wave per week is mandatory, and if a wave is not completed by the end of the week, it automatically plays out at the end of the week, against only the city’s physical defences (towers). If a defense fails, the creatures will rampage through the city, doing damage based on the strength of the wave and how many attackers survived the assault. Damage to the city can range from simply stolen food stores, all the way to complete destruction of the city – as I said, there are risks!
Expansion potential here is to allow cities to declare war against each other, allowing them to create attack forces that raid the enemy towns. Players on both sides would help in the battle.
What do you think?
The main reason for this blog is to get feedback and gauge interest, so please leave a comment below. What do you like, and what do you hate? Do you have any questions or suggestions?
This blog is going to be about my new project, Shadowed Hope (working title), that I will be working on in my spare time. It is a Persistent World Social Role-Playing Game, also known as a Massively Multiplayer Online Role-Playing Game (MMORPG). It will be primarily designed and developed by yours truly, but I want to make it an open project. The game concept and most of the major design decisions are already made, but I will be making posts here as I flesh out the details, to encourage feedback, constructive criticism, and promote discussion, which will influence my design decisions and affect the game.
I am building the game in Actionscript and using the Flex SDK. Recent updates to the Flash Player in the browser and Adobe AIR on desktops and mobile, such as Stage3D, enable applications to be built that utilize hardware acceleration for advanced 3D graphics. The platform has a lot of potential to allow games to be built that can be played anywhere. One game, on social platforms like Facebook and Google+, as well as on mobile devices as native applications.
There are a few 3D rendering engines available, and for various reasons I’m opting to use Flare3D. I considered, and dabbled a bit in, building a custom engine and working with Stage3D directly, but with the scope of the project, and limited development time, it is best to use a pre-built 3D engine. Flare3D is not a complete game engine on it’s own though, and I will still have the task of building the base isometric engine and incorporating all the extras such as networking, physics, and much more. Development posts will detail many of these steps. Some of these posts will be formatted almost like tutorials. Others might be requests for feedback or assistance – this project is a large and complicated undertaking, and I’m not afraid to admit I will need help along the way.
As I said, this is currently a one-man project. It really is quite massive, and I will mostly just be working on it in my spare time, so it will surely take years to complete. I would love to be able to put together a team, make this project a full-time thing, and get it completed sooner, but of course there are obvious reasons that’s not possible right now. If you follow this blog and like the project, please consider contributing. Leaving comments and feedback on the posts will let me know there is community interest and keep me motivated, and you can help to shape the game at the same time. You can also check out the Contribute page for more ways you can help.

