Sourcecode |
This text was wrote for BlitzBasic-source code. But with some luck, you can use this for sources written in other languages. Notice: source code for other languages are projects from other programmers. |
Include mapengine |
You find complete mapengine in directory "Source\BlitzBasic\Mapengine". Copy this directory to another place. Use preview_bb2d.bb-file as template - copy also this file. This line is very important: Include "mapengine\mapengine.bb" This program was wrote in BBplus - but you can run it also in BB2D or BB3D. Commands LoadImage and LoadAnimImage have each new parameter in BBplus. If this program do not start, modify only this lines (with errors) - remove only last parameter ",2". |
Find and manipulate object |
After you load a map-file with map_load()-function, you can identify object at they names. Use this functions: obj.layer=layer_find("obj") or obj.geo=geo_find("obj") Typicaly, you should find objects only one time after loading a map-file. Later, you can access identified objects and manipulate object properties: obj\ascii All objects: Metadata is stored as binary (0) or ascii (1) data. You must convert metadata manually to a string! obj\bank1 Layer: Memory bank handle to basedata. Basedata contain tile-values, which are used to draw a layer. obj\bank2 Layer: Memory bank handle to datalayer. obj\bank3 All objects: Memory bank handle to metadata. obj\bank4 All objects: Memory bank handle to variables. obj\code All objects: Type of object (1=map, 2=iso1, 3=iso2, 4=hex1, 5=hex2, 6=clone, 7=image, 8=block, 9=point, 10=line, 11=rect, 12=oval) obj\depth1 Layer: Basedata-depth in bit obj\depth2 Layer: Datalayer-depth in bit obj\frame Image or block: Frame number (hardcoded) obj\layer Clone or block: Layer handle to reference object obj\mask Map, image or block: Masked graphic off (0) or on (1) obj\mode Image or block: Animation mode (0=default, 1=paused, 2=forward, 3=backward) Map-layer: endless layer repeat (0=no, 1=yes) obj\name$ All objects: Object name obj\parax Block: Adjustment X Other objects: Parallax X-value obj\paray Block: Adjustment Y Other objects: Parallax Y-value obj\posx Block: Tile coordinate X Other objects: Pixel coordinate X obj\posy Block: Tile coordinate Y Other objects: Pixel coordinate Y obj\sizex Layer: Layer width in tiles Line: Endpoint X Rect: Object width Oval: Radius X obj\sizey Layer: Layer height in tiles Line: Endpoint Y Rect: Object height Oval: Radius Y obj\start Iso2, hex1 oder hex2: Tile shift (0/1) Image or block: Animation start frame obj\tile Layer, image or block: Tileset handle obj\time Image or block: Last millisecs value used for independent animation timing (TMP) obj\tmp Image or block: Last frame value used for independent animation timing (TMP) obj\visible All Objects: Object invisible (0) or visible (1) |
Background |
Background-data is not stored as a object. You find all data in global variables included in map.bb-file. All variables begin with prefix "map_". Names are identical with object-properties (see above). |
Steps for beginner |
First steps 1) use map_load() to load map-file and map-images 2) check returned value for errors 3) identify all important objects Main loop 1) modify object position (layer\posx, layer\posy) 2) modify camera position with map_scroll() 3) update animations with tile_animate() 4) use CLS or draw background graphics, if needed 5) draw map width map_draw() 6) draw overlay graphics 7) use FLIP How to convert mouse coordinate to tile position 1) get mouse coordinates 2) use layer_map_coord, layer_iso1_coord etc. commands How to convert global object coordinate to tile position 1) get global object coordinates 2) convert global coordinates with map_getscreen() 3) use layer_map_coord(), layer_iso1_coord() etc. commands How to read out tile value 1) calculate tile coordinate 2) use layer_getcode() and layer_getvalue() to read tile value Tip) use layer_setvalue to set tile value How to read out data value 1) calculate tile coordinate 2) use layer_getdata() to read data value Tip) use layer_setdata to set data value |