Postby oog » Jul 14, 2011 19:38
About drawing trains.
I use strings to define vector graphics items like trains and buildungs. The characters of the string stand for graphics commands and parameters.
There are some subroutines, that help building the string similar to graphics commands.
iAddColor(col) for example adds a color(col) command to the string.
There are also Zoom-Commands iAddZoomIn and iAddZoomOut. They are used to show more or less details in different zoom levels.
Example:
w.iBuild(i)= _
iVehicle _
+iAddZoomOut(200) _
+iAddColor(1) _
+iAddLine(-20,-70,20,70) _
+iAddLine(20,-70,-20,70) _
+iAddZoomIn(200) _
+...
Every vector item will be placed on the screen with two pair of coordinates (PointA and PointB).
A coordinate is a 8 bit value. PointA and PointB are located at (-100,0) and (+100,0) within a (-128,-128) - (127,127) grid. For a train, PointA and PointB represent the axis (wheels).
Test for yourself:
You can place a new item at the cursor position by pressing "n" (new item). A Building will appear under the mouse cursor.
Then click with the left mouse button to select the object (use a short click).
There will appear a yellow circle around PointA and a blue one around PointB.
Press + or - to change the item (other building, train, etc.).
Click into a point marker, hold down the mousebutton and drag it. PointA moves the item while PointB change size an direction.
Press "del" to remove the item, or click outside a Point marker to deselect the item.
The next program version will have a more stable drag function, actually you should not move the mouse too fast while dragging.