The draw function is used in conjunction with many other sub-functions like RECT, CIRCLE, FILLEDRECT, LINE, and more. There are many of them. It also uses some parameters, but they changes depending on the sub-functions. Let's see how to call the DRAW command:
Syntax:
DRAW element subfunctions
In all following examples I will use the element earth as the 'element' parameters. It will be shown as ELEMENT:Earth<br> All X and Y coordinate will be based on cursor position. Cursor position in BS2 are X,Y.
Syntax:
DRAW ELEMENT:Earth POINT X Y
Syntax:
DRAW ELEMENT:Earth RECT '''''X Y WIDTH HEIGHT''''' DRAW ELEMENT:Earth FILLEDRECT '''''X Y WIDTH HEIGHT'''''
Just a little note for this function, until alpha 3 its included with BS2. It was not before.
Syntax:
DRAW ELEMENT:Earth REPLACEFILLEDRECT X Y WIDTH HEIGHT REPLACE_ELEMENT
The REPLACE_ELEMENT correspond to an element you want to replace by earth (in this example).
So if i want to replace the Clear by Earth, i would just replace REPLACE_ELEMENT by ELEMENT:Clear
Syntax:
DRAW ELEMENT:Earth CIRCLE X Y RADIUS DRAW ELEMENT:Earth FILLEDCIRCLE X Y RADIUS DRAW ELEMENT:Earth RANDOMFILLEDCIRCLE X Y RADIUS RATE
Syntax:
DRAW ELEMENT:Earth FILLEDCIRCLE X Y RADIUS REPLACE_ELEMENT
Again this is the same as REPLACEFILLEDRECT but for a filled circle.
Syntax:
DRAW ELEMENT:Earth LINE X Y DX DY DRAW ELEMENT:Earth LINE X Y DX DY REPLACE_ELEMENT
Ok here the DX,DY parameters need a little explanation. You can go [http://www.fallingsandgame.com/wiki/images/b/b5/Line_function.png here] for a visual explication.
Basically the DX,DY are the distance from the starting point.
So let's say X=100 Y=100 DX=10 DY=-10.
This mean that the line will start at 100,100 and end at 110,90.
Why 110,90 because it like drawing a line from X Y (X + DX) (Y + DY).
Since (X + DX) is (100 + 10) then the result is 110.
Since (Y + DY) is (100 + -10) then the result is 90.
This is how we get a line from 100,100 to 110,90.
Syntax:
DRAW ELEMENT:Earth FILL X Y DX DY
This work the same way as the LINE function except it will fill anything it cross with the choosen element (Earth).
Syntax:
DRAW 0 ROTATE X Y WIDTH HEIGHT 1 DRAW 0 ROTATE X Y WIDTH HEIGHT -1
First the 0, is because we dont really need an element here, as it will rotate anything in given coordinate.
Then the first line is to rotate clockwise (1) and the second line to rotate counterclockwise (-1).
* Note that this will work only with square, not with rectangle.
Syntax:
DRAW 0 COPYRECT X Y WIDTH HEIGHT ToX ToY
Again the 0 mean we dont need to send an element, but there must be one so put at least 0 or any element.
Copyrect work like a rect, so first 4 parameters work the same.
ToX,ToY correspond to where you want to copy the RECT. It will copy the rect you selected starting at those coordinate.
This work almost the same way as the COPYRECT except that instead of copying the rect to a coordinate on the screen, it copy the rect to the memory, and you give it an ID to be able to PASTE where you want, when you need.
Syntax:
DRAW 0 COPYSTAMP X Y WIDTH HEIGHT STAMPID
DRAW 0 PASTESTAMP X Y WIDTH HEIGHT STAMPID Same as above for the 0. The STAMPID is a number you give to your stamp so you can paste it after.
Syntax:
DRAW 0 SWAPPOINTS X1 Y1 X2 Y2
This will, like it says, swap two points. So X1,Y1 are the first point, X2,Y2 is the second point. What are at both coordinate will be exchanged with the other.
So if you have Earth at the fist coordinate and TNT at the second coordinate, after the function is executed you will have TNT at first coordinate and Earth at second coodinate.
Syntax:
DRAW ELEMENT:Clear OBJECT X Y 1 ELEMENT:Wall 2 ELEMENT:Earth {
"121"
"22 "
"121"
}
This will create an object at the x,y position you use. Wall will be drawn at 1 and Earth at 2. If there is a space in the data, Clear will be assigned to that pixel.