Structs.h
From OPU Wiki
CAUTION: for ALL Map_Coordinates used on this page, be sure to add (+31,-1)
[edit]
LOCATION
Where ever you need to supply a LOCATION to any OP2 procedure, use this class.
To create a location, use the constructor. Some examples; they are all valid:
int x=40; int y=20; LOCATION ( x,y ); // (1) LOCATION loc= LOCATION( x,y ); // (2) LOCATION loc( x,y ); // (3) LOCATION loc; // (4) loc.x=x; loc.y=y; LOCATION loc2= loc; // (5)
- this version is to be used INSIDE a procedure, like this: TethysGame::CreateUnit( u, map_Lynx, LOCATION(40,20), 1, map_Laser, 0);
- creates a variable called loc and initializes it to 40,20
- does the exact same, but is a shorter version
- is a longer version. This way the loc definition can be put at the start of the procedure, and its initialization further on. Also, once you've used any versions 2,3 or 4, later on in your procedure you can change loc by using method #4 (but omit the first line, the variable definition)
- this one initializes loc2 to whatever loc is at that time. In other words: move the contents of loc into loc2
[edit]
MAP_RECT
Where ever you need to supply a MAP_RECT to any OP2 procedure, use this class.
To create a location, use the constructor. Some examples; they are all valid:
int x1=40, y1=20, x2=50, y2=30; LOCATION topleft( 40,20 ), botright( 50,30 ); MAP_RECT ( x1,y1,x2,y2 ); // (1) MAP_RECT rect= MAP_RECT( x1,y1,x2,y2 ); // (2) MAP_RECT rect( x1,y1,x2,y2 ); // (3) MAP_RECT rect( topleft,botright ); // (4) MAP_RECT rect; // (5) rect.x1=x1; rect.y1=y1; rect.x2=x2; rect.y2=y2; MAP_RECT rect2= rect; // (6)
- this version is to be used INSIDE a procedure, like this: group1.SetRect( MAP_RECT( 40, 20, 50, 30 ));
- creates a variable called rect and initializes it to a rectangle with topleft=40,20 and botright=50,30
- does the exact same, but is a shorter version
- same again, but using LOCATIONs as params, instead of just the 4 ints
- is a longer version. This way the rect definition can be put at the start of the procedure, and its initialization further on. Also, once you've used any versions 2,3,4 or 5, later on in your procedure you can change rect by using method #5 (but omit the first line, the variable definition)
- this one initializes rect2 to whatever rect is at that time. In other words: move the contents of rect into rect2
Categories: Coding | SDK
