op2_sdk:placing_units

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
op2_sdk:placing_units [2016/01/31 20:43] vagabondop2_sdk:placing_units [2016/01/31 21:11] vagabond
Line 10: Line 10:
  
 Unit positions are represented in game by either the structure LOCATION or by passing 2 integers into a function, representing the x and y position. LOCATION represents the tile currently being occupied by the unit. The Outpost 2 game engine requires units to be placed +31 X tiles and -1 Y tiles from their actual position. For example: LOCATION(21 + 31, 15 - 1) would be the position (21,15) on the map. Unit positions are represented in game by either the structure LOCATION or by passing 2 integers into a function, representing the x and y position. LOCATION represents the tile currently being occupied by the unit. The Outpost 2 game engine requires units to be placed +31 X tiles and -1 Y tiles from their actual position. For example: LOCATION(21 + 31, 15 - 1) would be the position (21,15) on the map.
- 
- 
  
 ===== Building Origin ===== ===== Building Origin =====
Line 21: Line 19:
 {{op2_sdk:buildingoriginexample.png.png?450}}\\ {{op2_sdk:buildingoriginexample.png.png?450}}\\
 <fs small>//Image Credits: Sir Bomber//</fs> <fs small>//Image Credits: Sir Bomber//</fs>
 +
 +===== Vehicle Lights =====
 +
 +When any vehicle is created, it defaults to lights off. The function void ''DoSetLights(int boolOn)'' from Unit.h can be used to turn the lights on.
 +
 +===== Using the CreateUnit Function =====
 +
 +Some variables used in ''CreateUnit'' are not required depending on what unit is being created. For example, a command center cannot have cargo or if you want to create a truck that does not contain any cargo. In these situations use the enum map_id::mapNone to indicate no cargo is required.
 +
 +When placing buildings, the variable rotation does not have any meaning and can be set to any value.
  
 ===== Related Source Code ===== ===== Related Source Code =====
Line 30: Line 38:
     map_id unitType,      map_id unitType, 
     LOCATION location, int playerNum, map_id weaponCargoType, int rotation);     LOCATION location, int playerNum, map_id weaponCargoType, int rotation);
 +</code>
 +
 +//Unit.h//
 +<code cpp>
 +void DoSetLights(int boolOn);
 </code> </code>
  
Line 192: Line 205:
 int InitProc() int InitProc()
 { {
 +    // Create a Command Center for player 1.
 +    Unit commandCenter;
 +    
 +    TethysGame::CreateUnit(
 +        commandCenter, 
 +        map_id::mapCommandCenter, 
 +        LOCATION(30 + 31, 208 - 1), 
 +        0, 
 +        map_id::mapNone, 
 +        UnitDirection::East);
 +    
 +    
 +    // Create an Acid Cloud guard post for player 2.
 +    Unit guardPost;
 +    
 +    TethysGame::CreateUnit(
 +        guardPost, 
 +        map_id::mapGuardPost, 
 +        LOCATION(3 + 31, 2 - 1), 
 +        1, 
 +        map_id::mapAcidCloud, 
 +        UnitDirection::East)
 +    
 +    // Create a ConVec with a Tokamak Kit for player 2 and turn it's lights on.
 +    Unit conVec;
 +    
 +    TethysGame::CreateUnit(
 +        conVec, 
 +        map_id::mapConVec, 
 +        LOCATION(50 + 31, 10 - 1), 
 +        1, 
 +        map_id::mapTokamak, 
 +        UnitDirection::North);
          
 +    conVec.DoSetLights(true);
 } }
  
  • op2_sdk/placing_units.txt
  • Last modified: 2016/10/12 21:32
  • by 127.0.0.1