MicroTD - Tower Defense for Arduboy

thank you verry much :heart_eyes_cat:
…now it looks like warcraft 3 tower defens Micro, perfect :scream_cat:

1 Like

This is one of my favorite game. One of my main suggestion is to increase the non-demon enemies’ HP to make the game longer or end the game once you successfully made your super sonic speed aura water tower to make those demon very easy to destroyed. Quitting the game does not save your high score. Maybe at round 100, you have to destroy a mega-boss to win that map.

1 Like

Hi, I am writing this from the age of which we shall not name, the one year that will be burned out of the history books due to *5G towers (*just myth not true) and I don’t really expect a response but I’m gonna ask anyway. You see i have recently bought an arduboy and have a minimal amount of coding experience with an arduino board. I am really enjoying this tower defense game and would like to add another tower called the bank. This tower would give you a certain amount of money each round but would not attack enemies. To do this though I (with my caveman brain) need some help understanding how money is distributed and how upgrades function because i have no idea just from looking at the code. I know this is becoming quite a long comment and I’m writing this 2 year after the game was published but I would love to add this tower and bring something new to the game.

1 Like

Hey I find it awesome you’re interested in adding something! It’s been some time since I’ve written it, so give me a second to figure this out :slight_smile:

2 Likes

thanks I’m gonna try and reverse engineer it or whatever the term is so I create some more towers and maps, I think that would satisfy me for a while :slight_smile:

Ok, I don’t have Arduino environment set up currently, so I can’t test what I’m writing, plus I am no longer writing C++ nowadays, so I can just guide you here, but if you have trouble I’ll be here to help.

The best way to do modifications if you have no clue about what the code does is to work incrementally, i.e. start by just adding a new menu item, then make the button build the tower, then make the tower work. If you don’t know where to start, just copy what’s already there, e.g. duplicate one tower, and then start changing it. If you don’t know where e.g. money variable is, look for things that modify it, e.g. buying a tower. These are just general tips. I’ll probably miss some things but anyway I’ll try to give some direction about adding a new tower here (if you get stuck just write here again!):

For start add new tower sprite here.

Add a new constant for the tower type here, e.g.:

...
#define TOWER_WATER            6
#define TOWER_FIRE             7
#define TOWER_BANK             8  // <-- add this
#define TOWERS_TOTAL           9  // don't forget to bump this to 9
...

Also here shift all menu item positions by one as we add new tower before them (yes, it’s awkward, feel free to fix my bad code :slight_smile: ):

#define GAME_MENU_UPGRADE1     9   // 8 -> 9 etc.
#define GAME_MENU_UPGRADE2     10
#define GAME_MENU_DESTROY      11
#define GAME_MENU_NEXT_WAVE    12
#define GAME_MENU_QUIT         13

For start maybe just try to add the tower to the game menu and just see if it appears there. Here is the function that defines menu items, you’ll have to make some changes in it (there are hardcoded numbers, YES I AM A BAD PERSON):

    ...

    if (index < 14)  // <-- change 13 to 14, the new no. of menu items

    ...
    
      if (index < 7) // <-- change 6 to 7
        result.mIcon = towerSmallImages + index * TILE_SIZE * 3;
      else           // big towers + other icons
        result.mIcon = menuIcons + (index - 7) * TILE_SIZE;
                                   // ^ also here change to 7

    ...
        case TOWER_WATER:   C('w')C('a')C('t')C('e')C('r')C(0)       break; 
        case TOWER_FIRE:    C('f')C('i')C('r')C('e')C(0)             break; 
        case TOWER_BANK:    C('b')C('a')C('n')C('k')C(0)             break; 
             // ^ add this
    ...

If you see the tower in the game menu now, you can start making it actually work.

Set the tower properties here:

const TowerType towerTypes[TOWERS_TOTAL] =
{
// sprite         rng spd dmg price  upgrade 1       upgrade 2
  ...
  {TOWER_BANK,    0,  0,  0,  100,  {UPGRADE_RANGE,  UPGRADE_DAMAGE}}
  // ^ add something like this
};

Now here is the code that defines how the tower behaves. If the new tower is going to do nothing, you can probably just add something like this:

  void update(CreepInstance *creepArray, uint8_t creepArraySize,
    const CreepPath *creepPaths, BytePosition tile, uint16_t frame,
    uint16_t *money)
  {
    if (this->getTypeIndex() == TOWER_BANK) // <-- if bank then do nothing
      return;
  
    BytePosition selfPosition = getCenter(tile);
    
    ...

Now player’s money are stored here, so if you want to give money to the player each round, you can do it e.g. here where you get the wave reward. You can add a loop that will scan the whole playfield, count how many bank towers are built, and give corresponding extra money.

Also I haven’t thought about upgrades here, that can be left later.

1 Like

Thanks for the help I really needed it. I have made a model for the bank and will add it soon, I have also taken your advice and it now counts how many towers you have on the stage and gives you a multiplier to your wave reward based on that number. I’m working on an upgrade for the amount of money you get per bank and some other upgrade to fill the second slot. thanks for the help btw it has been really fun adding the tower. :slight_smile:

3 Likes

Hey I’m really loving this game but I have run into an issue. I’m playing this on the arduboy-fx so it came preinstalled.
I’m unable to buy the water or fire even when I have more then enough funds so it become impossible to get past when the demons come out

This game hasn’t been actively developed for quite a while. I am not sure the FX version is any different from the code originally published- it could be a long-term bug?

Hey, thanks for the report! Sorry if this has been an inconvenience.

As has been said I haven’t touched this in years. I’m on a vacation now and can’t focus on this, feel free to bump this in about a week from now so I can take a look at it. Not promising anything though. Anyway, if anyone’s feeling adventurous in the meantime, you may try to dig for the bug, it shouldn’t be too difficult to get grasp of the source code and compile it.

Just had a look at the code … both the water and fire are 2 x 2 tiles. You must have a spare tile above the one you are on, to the left and to the upper left.

The image belwo shows how it would look … my cursor is to the lower right of the tower.

ArduboyCapture (1)

1 Like