diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2017-03-12 21:09:29 +0100 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2017-03-12 21:09:29 +0100 |
| commit | 6628e7de58425b3e93da9ae6fcb7347137d96096 (patch) | |
| tree | 336d1f74961187aad7c85ba06dcdd0684c003282 /Building.c | |
| parent | f416816883545433ea33ca410983371e657dba18 (diff) | |
| download | pocketempires-6628e7de58425b3e93da9ae6fcb7347137d96096.tar.gz | |
* Player can now select nearest unit or building. Multiple buildings and units can be selected at the same time.
* Unit module moved from C++ to C (only extension change - and compiler - was needed).
* GfxGetHeightFromSpriteData and GfxGetWidthFromSpriteData were getting incorrect data! Incorrect memory address was being read when calling pgm_read_byte, and caused unexpected behaviour under real hw.
Diffstat (limited to 'Building.c')
| -rw-r--r-- | Building.c | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -47,13 +47,7 @@ uint8_t BuildingGetHpFromID(uint8_t id) void BuildingSelectedOptions(TYPE_BUILDING * ptrBuilding) { - char str[8]; - GfxDrawRectangle(0, Y_SCREEN_RESOLUTION - 8, X_SCREEN_RESOLUTION, 8, GFX_WHITE); - - snprintf(str, 8, "HP=%d", ptrBuilding->hp); - - GfxPrintTextFont(str, font3x3, 4, Y_SCREEN_RESOLUTION - 4); } @@ -79,21 +73,29 @@ void BuildingDraw(TYPE_CAMERA * ptrCamera, TYPE_BUILDING * ptrBuilding, bool bSe GfxDrawSprite(BuildingSprTable[id]); + int8_t color = GFX_WHITE; + if( (bSelected == true) && (ptrBuilding->selected == false) ) { - TYPE_COLLISION_BLOCK cb; - - cb = CameraApplyCoordinatesToCoordinates(ptrCamera, ptrBuilding->x, ptrBuilding->y); - - GfxDrawCircle(cb.x + 3, cb.y + 3, BuildingGetWidthFromID(ptrBuilding->id) >> 2, GFX_GRAY); + color = GFX_GRAY; } else if(ptrBuilding->selected == true) { - TYPE_COLLISION_BLOCK cb; + color = GFX_BLACK; + } + + if(color != GFX_WHITE) + { + TYPE_COLLISION_BLOCK cb = CameraApplyCoordinatesToCoordinates(ptrCamera, ptrBuilding->x, ptrBuilding->y); - cb = CameraApplyCoordinatesToCoordinates(ptrCamera, ptrBuilding->x, ptrBuilding->y); + cb.w = BuildingGetWidthFromID(ptrBuilding->id); + cb.h = BuildingGetWidthFromID(ptrBuilding->id); - GfxDrawCircle(cb.x + 3, cb.y + 3, BuildingGetWidthFromID(ptrBuilding->id) >> 2, GFX_BLACK); + GfxDrawRectangle( cb.x - (cb.w / 10), + cb.y - (cb.h / 10), + BuildingGetWidthFromID(ptrBuilding->id) + (cb.w / 5), + BuildingGetHeightFromID(ptrBuilding->id) + (cb.h / 5), + color ); } } |
