Brooms Tower Defense: The Original Idea That Got Changed To Not Hurt Cleaners Feelings

Capture

I’ve taken the task of recreating a popular flash game, Bloons TD, aka Bloons Tower Defense. The purpose of the game is to prevent balloons, Bloons, from reaching the end of the map. There is a path for them to follow, and each balloon type has different attributes. In order to stop them, you must purchase Towers, mostly monkeys, to pop those balloons before they exit. Monkeys too have different stats, and ways of throwing darts. My version has a starting player-controlled bumblebee, that helps protect you until you can earn enough money to buy towers.

You can play it here: Click Here to Play

THE BASICS

Some main variable crucial to this game are gold, round, and hp, while the more hidden ones are enemies left, and fire ability. 

public int gold;
public int hp;
public int round;

They have their own messages with color variations as well.

message = new Message("Gold: " , 0, gold);
addObject(message,500, 20);
message1 = new Message("HP: ", 1, hp);
addObject(message1,350, 20);
message2 = new Message("Round: ", 2, round);
addObject(message2,200, 20);

Those can be altered in-game, by killing enemies, buying towers, clearing the round, and letting brooms through without killing them.

ENEMIES

The spawning method works rather uniquely, but sure gets those brooms running. The bumblebee code has a check for no enemies, and the pressing of spacebar, which then creates a spawner “house” one the map.

Spawner s = new Spawner();
getWorld().addObject(s, 40, 252);

These houses spawn enemies in their act code until a variable y, reaches the number that should spawn. Y increases by 1 for every broom spawned. There are three houses, the original broom spawner, the mop and then the vacuum spawner. The broom defaults at 1 HP, the mop has 3 HP, and the vacuum holds a hefty 10 HP.

The harder enemies don’t spawn until the spawn number is high enough, so be prepared on those high rounds!

TOWERS

Your two life-savers are on the bottom left of your screen, and only cost the lowest price around town. The teddy bear, retailing at 150 gold, shoots a single bullet every second or so, destroying those horrible brooms before they can clean up any more. It’s sidekick, the frog, features a never before seen burst fire! Although a bit slow,  at 300 gold, he’s a steal any-day of the week. These bad boys turn to the first enemy they see, and fire at will.

turn();
singlefire();

turn();
burstfire();

You, the bumblebee have similar responsibilities as the defenders, but aren’t some coded machine. The mouse controls your aim, and clicking shoots some scary water drops at those brooms, that’ll show ’em.

SHOPPING

This was the most difficult part, more so because it took time, and allowed no mistakes. I had to code a mouse in, (Thanks Google.) that detected contact with the fake defense towers on the bottom. If touching one and clicking, you spawn in a “ghost” of that tower, which will follow your mouse, and place a real one where you click again, removing the ghost as well. Right clicking in ghost mode cancels your purchase, for when you left click, the gold comes right out of your supply. (These are just random excerpts from the mouse, and ghost code)

if(bear != null)
if(frog != null)
public void follow()
public void spawnBear()
public void spawnFrog()
getWorld().addObject(b,this.getX(),this.getY());
w.changeGold(-150);
getWorld().removeObject(this);

OVERCOMING PROBLEMS

To ensure a playable code, I had to make many google searches to understand referencing other objects, methods and variables. For, you cannot simply use a method from another class, without making it public, and using the class name before. An example :

MyWorld w = (MyWorld)getWorld(); 
int c = w.getleft();
int r = Mouse.getAble();

One integer, from the world gets the enemies left, in number form of course, and getAble() checks to see if the bumble can shoot. (If he’s hovering over a a shop item, it does not shoot.) It took me a long time just trying to use methods like those from other classes, severely halting my progress.

LOOKING BACK

I really liked making this project, and I’m convinced now that I could make plenty of other flash games like this in Greenfoot. Also, I found that you can always add more, like always, there could be 100 towers and it would still be possible to add more. So I believe that in order to make a successful game you just need to have a great idea, which is at least somewhat original.

PEACE.

Noah Bucks

 

Leave a Reply

Your email address will not be published. Required fields are marked *