Creating a real-time strategy game

7

Stats

13,126 visits, 18,956 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 2 Oct, 2012. Last updated 19 Feb, 2019

I was looking through the tutorials today and realised that there seemed to be a lack of RTS tutorials, therefore since I am developing one, I thought that I'd show you the method that I have been using.

I will start off by saying that there is probably a better method for doing the things I've done, this is simply the way that I accomplished these things.

I will go through every step that I went through in-order to create my own RTS and hopefully, you shall find it useful.

1. First of all you will need sprites for the enemy characters and the ally characters.

2. (this depends on how you want to control your characters) Here, I developed a D-pad as part of the HUD since I was developing for touch-phones. I gave each arrow a different instance variable and set them as seperate objects so that depending upon which arrow was touched the character would move in the direction of that arrow.

You will notice that upon my D-pad, I have also added a 'fire button', also as a seperate object to the rest of the D-pad (so I can set the event to: if [image] touched).

3. I next created health bar graphics (a different graphic for every 10% of health taken off) and added them to the health object as different animations.

4. I created a method of selecting and de-selecting the player's characters, so that when they were de-selected the player could click on the arrows in-order to only move the camera about the environment, without moving the player's (for tactical reconeissance)

Within the above image you can see how I developed the selection and movement of characters, and below is how I de-select characters. Within the events above you can also see that I've accounted for if a character moves out of the player's view, then the screen moves with the character.

5. Next I set-up the player's attack (which is again probably best shown in a screen-cap, rather than described).

6. Now that we have achieved the selection, movement and shooting for the player's characters we should next develop the displays for changes in health and ammo. As described earlier, I created different animations for every 10% of health, this is how it is used to display what percent of player health is left.

and this is how I further dealt with the health of the player's characters:

Please note that the 'deadjeep' variable I have used proably isn't relevant to you (unless you want to implement buying back dead characters later like I have).

I displayed the ammount of ammo left in a similar way to how I displayed the player's health, except rather than using individual animations, this time I decided to change the 'ammo sprite' length based upon how much ammo was left.

7. Now that we have established most of the mechanics related to the player, it is now time to establish the enemy AI (the least fun bit for me as a designer, rather than a programmer, however, I think I've accomplished my own AI in a way that works alright for my game at least).

Since the enemy AI requires so many events in-order to function adequately, I myself split this group into 'Enemy Retaliation' and 'Enemy General', so as to organise the mounds of events better.

As you can see, for the enemy's general movement I have simply set the random selection of an enemy sprite, then either move this sprite randomly or fire a bullet in a random direction.

Next I will show you how I have achieved aspects of the enemy's AI for enemy retaliation:

This means that if the enemy does not choose to fire upon you, after being hit by a bullet from you, then they will rotate in the same direction of your bullet and run away in that direction.

For reference, these are the object variables which I have used:

The 'Number' variable is simply so I know which of multiple similar characters that I am selecting within my events.

The reason that there is both a 'maxhp' and 'maxammo' as well as a 'currenthp' and 'currentammo' is so that I can work out what percentage the current value is of the maximum values (for showing accurate health and ammo graphics).

8. Now providing that you have been able to work out what I have done so far, then you should have all of the key aspects of your RTS developed. What I have next used is, what I have termed 'detection areas' in-order to add further aspects for enemy detection (such as the enemy noticing where you are before you've attacked).

As you can see, I have also attached a detection area and health to the enemy building which I am wanting to attack, so when I approach this building, the enemy's nearby are attacking me.

The detection area is essentially just a circular sprite with low opacity (so the player can only just see it, making the game harder).

In conclusion: I may add more to this tutorial soon, however, for now, providing you've been able to follow my method, you should have all of the basics to achieve an RTS.

Please download the Capx from this game page:

HERE

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!