![]() |
HEL's map-system implementation supports large maps. The map-drawer only updates dirty regions, instead of always redrawing the whole map!
The map-drawer is faster than the original HAM map functions. It uses LookUpTables whereever possible to gain maximum speed.
It can be combined with HEL's Tile Functions to dynamically reload tiles which gives you the possibility to create more extended levels.
It supports parallax scrolling using fixed point math.
It supports Virtual Maps. A Virtual Map in HEL's sense is an invisble datalayer, which can be used as a collision or event map. There is no limit in creating Virtual Map's!
|
Scroll multiply layers at the same time.
// Flags is our flag list result, BgNo is the Background you want to check // and Axis is either 0 for X, or 1 for Y. // This assumes you are storing the MapInfos in numerical order in the MapInfos array (0-3) // If you are not just store the result and AND it against the proper bit as shown above. // Example: ScrollResult & BIT4 <-- X Axis of 3rd BG stored in MapInfos array. #define CheckBGScroll(_Flags, _BgNo, _Axis)(_Flags) & (1 << (((_BgNO) << 1) + (_Axis))) TMapScrollInfo MapInfos[2]; MapInfos[0] = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); MapInfos[1] = hel_MapInit(1, 4096, 32, FALSE, Layer1_Map); while(GameLoopActive) { if(NewFrame) { if(UserPressedRight) { // Scroll one pixel to the right u32 ScrollResult = hel_MapBatchScrollBy(&MapInfos, 1, 0, 2); // Check to see if background 0 X axis scrolled if(CheckBGScroll(ScrollResult, 0, 0)) { HEL_DEBUG_MSG("BG0 scrolled on X."); } // Check to see if background 1 X axis scrolled if(CheckBGScroll(ScrollResult, 1, 0)) { HEL_DEBUG_MSG("BG1 scrolled on X."); } // Check to see if BG0 OR BG1 Y axis scrolled if(CheckBGScroll(ScrollResult, 0, 1) || CheckBGScroll(ScrollResult, 1, 1)) { HEL_DEBUG_MSG("BG0 or BG1 scrolled on Y."); } } } }
|
|
Scroll multiply layers at the same time.
|
|
De-Initialize a map.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); // Lots of stuff here ... hel_MapDeInit(&MapInfo);
|
|
Get custom data.
|
|
Get the current map position in tiles.
TMapScrollInfo MapInfo; TPoint32 Pt={0,0}; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPosition(&MapInfo, 512, 0); Pt = hel_MapGetPosition(&MapInfo); HEL_DEBUG_MSG("Position in tiles X: %d \n", Pt.X); HEL_DEBUG_MSG("Position in tiles Y: %d \n", Pt.Y);
|
|
Get the current map position in pixel.
TMapScrollInfo MapInfo; TPoint32 Pt={0,0}; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPosition(&MapInfo, 512, 0); Pt = hel_MapGetPositionInPixel(&MapInfo); HEL_DEBUG_MSG("Position in pixels X: %d \n", Pt.X); HEL_DEBUG_MSG("Position in pixels Y: %d \n", Pt.Y);
|
|
Get position of a tile.
TPoint32 Pt = hel_MapGetPositionInPixelFrom(&g_MapInfo, 2, 3);
|
|
Get Scrollflags.
|
|
Get a maptile.
u16 Index = hel_MapGetTileAt(&g_MapInfo, 98, 56);
|
|
Get a pointer to a maptile.
u16 Index = *(u16*)hel_MapGetTilePtrAt(&g_MapInfo, 98, 56);
|
|
Initialize a map.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, // BgNo 4096, // Map-width in tiles 32, // Map-height in tiles FALSE, // Is it a rotation map? Layer0_Map); // Pointer to map-data
|
|
Initialize a map.
TMapScrollInfo structure, which is used by most of the hel map functions. The hardware map is set to 32x32 tiles.
The For a normal map use one of these:
For a rotation map use one of these:
TMapScrollInfo MapInfo; MapInfo = hel_MapInitEx(0, // BgNo 4096, // Map-width in tiles 512, // Map-height in tiles TRUE, // Is it a rotation map? MAP_SIZE_ROT_64X64, // hardware map size Layer0_Map); // Pointer to map-data
|
|
Initialize a VirtualMap.
TMapScrollInfo MapInfo; MapInfo = hel_MapInitVirtual(128, 32, sizeof(u16), (void*)sample_Collision);
|
|
Check if a map uses boundschecking.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); if (hel_MapIsBoundsCheckEnabled(&MapInfo)) HEL_DEBUG_MSG("Boundscheck enabled\n"); else HEL_DEBUG_MSG("Boundscheck disabled\n");
|
|
Check if parallax is enabled.
|
|
Jump to a border of the map. The hel_MapJumpTo jumps to a border of the map. It can jump to the left or right as well as to the top or bottom. You can combine the JumpToFlag's in order to move the map in more than one direction with only a single call to hel_MapJumpTo.
// Jumps to the very right bottom position hel_MapJumpTo(&MapInfo, MAP_JUMPTO_RIGHT | MAP_JUMPTO_BOTTOM);
|
|
Redraw the map.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapRedraw(&MapInfo);
|
|
Scroll the map. The hel_MapScrollBy function scrolls the map and redraws only the dirty map cells (tiles), instead of redrawing the entire screen.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); while(GameLoopActive) { if(NewFrame) { if(UserPressedRight) { // Scroll one pixel to the right u8 ScrollResult = hel_MapScrollBy(&MapInfo, 1, 0); // check if it was able to scroll on x-axis if(ScrollResult & BIT1) { HEL_DEBUG_MSG("Scrolled on X"); } // check if it was able to scroll on y-axis if(ScrollResult & BIT2) { HEL_DEBUG_MSG("Scrolled on Y"); } } } } hel_MapDeInit(&MapInfo);
|
|
Scroll map to a specific position automatically.
TMapScrollInfo g_MapInfo; // X/Y Tile-Position (Camera Key-Points) const TPoint16 CamKeyPoints[5]= { // X, Y Tile Positions {10, 5}, {28, 5}, {15, 5}, {15,25}, { 0, 0} }; // Map Cinema Scrolling Information TMapCamScrollInfo g_MapCamInfo = { &CamKeyPoints, // Pointer to keypoints 5, // Count of keypoints 0 // Start keypoint }; // Init map g_MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); u8 CamScrollWorking=1; while(1) { if(NewFrame) { if(CamScrollWorking) { CamScrollWorking = hel_MapScrollTo(&g_MapInfo, &g_MapCamInfo, 1, 1); } NewFrame=FALSE; } } |
|
Setup map bounds checking.
pMapInfo . This means, you cannot scroll out of the map. It stops scrolling when it hits the "edges" of the map. It's turned on by default when you use hel_MapInit.Disabling this feature means you can scroll out of the map and this could end up in tile-curruption when you do not code an own "is current position still in map" routine.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); // Turn off boundscheck hel_MapIsBoundsCheckEnabled(&MapInfo, FALSE);
|
|
Setup map notify-callbacks.
TMapScrollInfo MapInfo; // Is called whenever a new row has been drawn void MapOnTopRowChanged(TMapScrollInfo *pMapInfo, u32 X, u32 Y) { HEL_DEBUG_MSG("MapOnTopRowChanged\n"); HEL_DEBUG_MSG("X: %d\n", X); HEL_DEBUG_MSG("Y: %d\n", Y); } // Init map MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); // Set callback function(s) hel_MapSetCallbacks(&MapInfo, (PMapNotifyFunc)MapOnTopRowChanged, NULL); // Scroll the map by 32 pixels in X and Y hel_MapScrollBy(&MapInfo, 32, 32);
|
|
Set custom data.
|
|
Enable/Disable dynamic tile reloading. The hel_MapSetDynamicTileReloading function can be used to force the mapsystem to dynamically reload tiles. Before enabling dynamic-tile-reloading, you must init a tile-system (hel_TileInit)!
// Init the tile-system first hel_TileInit(0, world_Tiles, 451, BufferA, 224, BufferB, 1, 0); // Init map g_MapInfo = hel_MapInit(0, MAP_WORLD_WIDTH, MAP_WORLD_HEIGHT, FALSE, (void*)world_Map); // Use dynamic tile reloading hel_MapSetDynamicTileReloading(&g_MapInfo, TRUE);
|
|
Enable or disable Parallax support.
TMapScrollInfo structure specified by pMapInfo . Specify TRUE to enable, or FALSE to disable.
|
|
Set parallax X/Y ratio.
pMapInfo . This function automatically enables parallax-support for the specified structure.
hel_MapSetParallaxRatio(&MapInfo, PARALLAX_FLOAT_TO_RATIO(0.7), // Ratio on X PARALLAX_FLOAT_TO_RATIO(0.8)); // Ratio on Y
|
|
Set map position in tiles.
X and Y must be specified in tiles.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPosition(&MapInfo, 512, 0);
|
|
Set map position in pixels.
X and Y must be specified in pixels.
TMapScrollInfo MapInfo; MapInfo = hel_MapInit(0, 4096, 32, FALSE, Layer0_Map); hel_MapSetPositionInPixel(&MapInfo, 512, 0);
|
|
Set Scrollflags. The hel_MapSetScrollFlags function can be used to prevent the mapsystem to scroll into specific direction and to automatically update the map-position in VRAM. For example: you disable scrolling for the left direction. When you call hel_MapScrollBy with DeltaX lesser than 0 (which indicates you want to scroll to the left), the system will handle the DeltaX parameter as 0 (zero) and therefore will not scroll to the left.
|
|
Transmit position to hardware.
The hel_MapTransmitPosition function transmits the position of the map specified by
|