Total Pageviews

Thursday, September 15, 2011

How to make an RTS

J'ai été creuser un peu dans mes vieux travaux du cegep, du temps qu'on temptait de réaliser un RTS en utilisant Python... ahh good times... beaucoup plus complexe qu'on le croie!

À la base tout jeu de stratégie va avoir besoin de certaines "Features"


Liste des Features nécessaires pour un RTS : Glièse
-          Camera isométrique
o   Movable using the arrow keys until edge of map
o   Movable by bringing the cursor to the edge of the screen until edge of map

-          Modification du pointeur afin qu’il prenne des coordonnées XY
o   Curseur libre
o   Local int MouseX, MouseY;
o   GetCursorPosition(MouseX,MouseY);

-          Multi-sélection
o   Aussi bien d’unités que de buildings.

-          Behaviors
o   Mouse
§  Lorsque que la sourie se trouve sur un ennemi, ou une unité du joueur.
·         Le curseur changera de texture lorsque la position de celui-ci se trouvera sur la même position que quelque chose d’autres. Sinon de base elle se trouve sur « none » qui sera l’état de défaut du curseur.
§  Clicking
·         Right-clicking on a friendly unit to follow
·         Right-clicking on a enemy unit to follow and attack it
·         Left-clicking to select
·         Use the scroll to browse saved groups
o   Keypresing
§  Hotkeys utilisés pour les groupes sauvegardés (1-0)
§  Hotkeys de base pour les unités (M to move, A to attack, P to patrol, S to stop, h to hold)
§  Hotkeys spéciaux utilisé selon l’unité (select Peon unit, press B for build, and A for armory)
o   Standard
§  Default behavior of a unit while nothing is happening
o   Encounter
§  React to ennemy units entering its field of vision
·         Attack it if in range
·         Follow and attack it if not on hold

-          Pathfinding
o   Most critical element
§  Units must avoid obstacles to get to destination.
§  Calcul de l’angle d’approche
·         distX = dx2-ox1 (calcul de la distance X)
·         distY = dy2-oy1 (calcul de la distance Y)
·         angle = (tan(distY,distX) % (2.0*π)) * (180.0/ π)
·         Une fois l’angle calculé on peut utiliser pytagore entre les distances afin de trouver le chemin le plus optimal. Par la suite, s’il y a un obstacle sur le chemin, le chemin optimal afin de contourner l’obstacle sera utilisé selon la même méthode en calculant la grosseur de l’obstacle.

-          Factory class
o   Complete with countdown
o   Used to create new units.

-          AI
o   Création d’une intelligence artificielle qui prendra en compte les éléments suivant:
§  Quantité de ressources
§  Pourcentage du territoire contrôlé
§  Nombre d’unités contrôlé
§  Tout ce qu’elle connait du joueur opposer ou de l’AI opposé
·         Positionnement des bâtiments rencontré
·         Positionnement des joueurs (de base)
·         Type d’unités rencontré
o   Exemple : joueur A possède énormément d’infanterie légère, l’AI B construira donc des unités anti infanteries le plus rapidement possible pour contre carré le joueur A
·         Survivre!

-          Alliance state machine
o   Gère les différentes alliances
§  Unit control
§  Shared vision
§  Declare war
§  Offer Peace
·         If an AI is in bad shape it may offer Peace with a warring player
§  Offer secret treaty against other player (Galactic Civ style)

-          Ressources collection
o   Ressource gathering of :
§  Metal
§  Food
§  Gliesyte (formely known as macguffinium)
§  Man power

-          Ressource trade
o   Trade resources with an allied player
o   Ask for resources from an allied player

-          Timer/clock
o   Timer (how long has the game been going)
o   Countdown (how long until the end of game (victory or defeat)
o   Control countdown (how long until designated spot is under control)

-          New UIScene
o   Minimap
o   Tooltips
o   Buttons
o   In case of multi-selection
§  See all units selected
·         Health
·         Energy (for special units)

-          Networking
o   Server host
§  The server host is the one hosting the game.
§   It’s created as Base to keep track of the game.
§  Does every operation asked by the clients
§  Is responsible for syncing the 2 (or more clients) every 0.4 millisecond.
o   Clients
§  Clients allow you to view the game and interact with the server. When you move a unit the client sends a request to the host to move a unit using its ID and the destination point.
§  Clients update every new sync to make sure the player sees what is really happening in game.

No comments:

Post a Comment