diff --git a/source/Entity.h b/source/Entity.h index 6f06509..f00b7b8 100644 --- a/source/Entity.h +++ b/source/Entity.h @@ -45,6 +45,7 @@ typedef struct { bool isCarrying; bool isSwimming; int swimTimer; + int strengthTimer; int score; Inventory* inv; Item* activeItem; diff --git a/source/Globals.c b/source/Globals.c index c2a243f..6e0fe16 100644 --- a/source/Globals.c +++ b/source/Globals.c @@ -4,6 +4,7 @@ char versionText[34] = "Version 1.3.0"; char fpsstr[34]; u8 currentMenu = 0; +bool UnderStrengthEffect = false; void addItemsToWorld(Item item,int x, int y, int count){ int i; @@ -681,6 +682,10 @@ void healPlayer(int amount){ addEntityToList(newTextParticleEntity(healText,0xFF00FF00,player.x,player.y,currentLevel), &eManager); } +void strengthPotionEffect() { + UnderStrengthEffect = true; +} + s8 itemTileInteract(int tile, Item* item, int x, int y, int px, int py, int dir){ // Furniture items @@ -701,6 +706,12 @@ s8 itemTileInteract(int tile, Item* item, int x, int y, int px, int py, int dir) healPlayer(1); --item->countLevel; } + return 0; + case ITEM_STRENGTH_POTION: + if(player.p.health < 20 && playerUseEnergy(2)){ + strengthPotionEffect(); + --item->countLevel; + } return 0; case ITEM_GOLD_APPLE: if(player.p.health < 10 && playerUseEnergy(1)){ @@ -1659,6 +1670,7 @@ void initPlayer(){ addItemToInventory(newItem(ITEM_WORKBENCH,0), player.p.inv); addItemToInventory(newItem(ITEM_POWGLOVE,0), player.p.inv); + addItemToInventory(newItem(ITEM_STRENGTH_POTION,1), player.p.inv); if (shouldRenderDebug == true) { addItemToInventory(newItem(TOOL_SHOVEL,4), player.p.inv); addItemToInventory(newItem(TOOL_HOE,4), player.p.inv); @@ -1680,6 +1692,12 @@ void initPlayer(){ void playerHurtTile(int tile, int xt, int yt, int damage, int dir){ if(shouldRenderDebug) damage = 99; + if(UnderStrengthEffect && player.p.strengthTimer <1000) { + damage = damage + 7; + } else if (player.p.strengthTimer >= 1000) { + UnderStrengthEffect = false; + player.p.strengthTimer = 0; + } char hurtText[11]; switch(tile){ @@ -2197,6 +2215,7 @@ void tickPlayer(){ } if(isSwimming()) ++player.p.swimTimer; + if(UnderStrengthEffect) ++player.p.strengthTimer; if(player.p.attackTimer > 0) --player.p.attackTimer; //TODO - maybe move to own function diff --git a/source/Item.c b/source/Item.c index 9190747..7182192 100644 --- a/source/Item.c +++ b/source/Item.c @@ -151,6 +151,7 @@ char* getItemName(int itemID, int countLevel){ case ITEM_BREAD: sprintf(currentName,"%d Bread", countLevel); return currentName; case ITEM_APPLE: sprintf(currentName,"%d Apple", countLevel); return currentName; case ITEM_GOLD_APPLE: sprintf(currentName,"%d Golden Apple", countLevel); return currentName; + case ITEM_STRENGTH_POTION: sprintf(currentName,"%d Strength Potion", countLevel); return currentName; case ITEM_COAL: sprintf(currentName,"%d Coal", countLevel); return currentName; case ITEM_IRONORE: sprintf(currentName,"%d Iron ore", countLevel); return currentName; case ITEM_GOLDORE: sprintf(currentName,"%d Gold ore", countLevel); return currentName; @@ -298,6 +299,7 @@ char* getBasicItemName(int itemID, int countLevel){ case ITEM_BOOKSHELVES: return "Bookshelves"; case ITEM_MAGIC_DUST: return "Magic Dust"; case ITEM_COIN: return "Coin"; + case ITEM_STRENGTH_POTION: return "Strength Potion"; case TOOL_BUCKET: switch(countLevel){ case 1: return "Water Bucket"; diff --git a/source/Item.h b/source/Item.h index 622ae7b..f2e6111 100644 --- a/source/Item.h +++ b/source/Item.h @@ -76,6 +76,7 @@ #define TOOL_BOW 102 #define TOOL_MAGIC_COMPASS 103 #define ITEM_GOLD_APPLE 104 +#define ITEM_STRENGTH_POTION 105 typedef struct Inventory Inventory; diff --git a/source/Render.c b/source/Render.c index 7baf559..6bd688c 100644 --- a/source/Render.c +++ b/source/Render.c @@ -1490,6 +1490,9 @@ void renderItemIcon(int itemID, int countLevel, int x, int y) { case ITEM_GOLD_APPLE: render(x, y, 177, 160, 0); break; + case ITEM_STRENGTH_POTION: + render(x, y, 177, 160, 0); + break; case ITEM_SLIME: renderb(x, y, 88, 152, 0, 0xFF4DC04D); break; diff --git a/source/main.c b/source/main.c index 0e9274d..b95a97b 100644 --- a/source/main.c +++ b/source/main.c @@ -203,7 +203,7 @@ int main() { cfguInit(); CFGU_GetSystemModel(&MODEL_3DS); FILE * file; - shouldRenderDebug = true; + shouldRenderDebug = false; if ((file = fopen("settings.bin", "r"))) { fread(&shouldRenderDebug,sizeof(bool),1,file); fread(&shouldSpeedup,sizeof(bool),1,file); @@ -322,7 +322,7 @@ int main() { offsetY = 0; if(shouldRenderDebug){ - sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(), player.x, player.y, eManager.lastSlot[currentLevel]); + sprintf(fpsstr, "FPS: %.0f X:%d Y:%d E:%d %d", sf2d_get_fps(), player.x, player.y, eManager.lastSlot[currentLevel], player.p.strengthTimer); drawText(fpsstr, 2, 225); }