Skip to content

Commit

Permalink
Regen potion and stuff, other little things
Browse files Browse the repository at this point in the history
  • Loading branch information
ElijahZAwesome committed Jan 23, 2018
1 parent 5e06ba0 commit 2456782
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 34 deletions.
4 changes: 2 additions & 2 deletions source/Crafting.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ void initRecipes(){
enchanterRecipes.recipes[6] = defineRecipe(ITEM_WALL_GEM,1,1,ITEM_GEM,10);
enchanterRecipes.recipes[7] = defineRecipe(ITEM_GOLD_APPLE,1,2,ITEM_APPLE,1,ITEM_GOLDINGOT,15);

potionMakerRecipes.size = 2;
potionMakerRecipes.size = 3;
potionMakerRecipes.recipes = (Recipe*)malloc(sizeof(Recipe) * (potionMakerRecipes.size));
potionMakerRecipes.recipes[0] = defineRecipe(ITEM_STRENGTH_POTION,1,3,ITEM_GOLD_APPLE,1,ITEM_GLASS,10,ITEM_IRONINGOT,10);
potionMakerRecipes.recipes[1] = defineRecipe(ITEM_SPEED_POTION,1,4,ITEM_GEM,2,ITEM_GLASS,10,ITEM_IRONINGOT,10, ITEM_GOLDINGOT,15);

potionMakerRecipes.recipes[2] = defineRecipe(ITEM_REGEN_POTION,1,3,ITEM_GOLD_APPLE,2,ITEM_GLASS,10,ITEM_GEM,10);
}

/* Free up allocated memory */
Expand Down
16 changes: 13 additions & 3 deletions source/Globals.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Globals.h"
#include "Menu.h"

char versionText[34] = "Version 1.3.2";
char versionText[34] = "Version 1.4";
char fpsstr[34];
u8 currentMenu = 0;
bool UnderStrengthEffect = false;
Expand Down Expand Up @@ -696,6 +696,9 @@ void strengthPotionEffect() {
void speedPotionEffect() {
UnderSpeedEffect = true;
}
void regenPotionEffect() {
regening = true;
}

s8 itemTileInteract(int tile, Item* item, int x, int y, int px, int py, int dir){

Expand Down Expand Up @@ -729,6 +732,12 @@ s8 itemTileInteract(int tile, Item* item, int x, int y, int px, int py, int dir)
speedPotionEffect();
--item->countLevel;
}
return 0;
case ITEM_REGEN_POTION:
if(player.p.health < 20 && playerUseEnergy(2) && player.p.strengthTimer == 0){
regenPotionEffect();
--item->countLevel;
}
return 0;
case ITEM_GOLD_APPLE:
if(player.p.health < 10 && playerUseEnergy(1)){
Expand Down Expand Up @@ -1693,6 +1702,7 @@ void initPlayer(){
addItemToInventory(newItem(ITEM_POTION_MAKER,0), player.p.inv);
addItemToInventory(newItem(ITEM_STRENGTH_POTION,1), player.p.inv);
addItemToInventory(newItem(ITEM_SPEED_POTION,1), player.p.inv);
addItemToInventory(newItem(ITEM_REGEN_POTION,1), player.p.inv);
addItemToInventory(newItem(TOOL_SHOVEL,4), player.p.inv);
addItemToInventory(newItem(TOOL_HOE,4), player.p.inv);
addItemToInventory(newItem(TOOL_SWORD,4), player.p.inv);
Expand Down Expand Up @@ -2249,8 +2259,8 @@ void tickPlayer(){
}
}

if (regening && player.p.regenTimer % 60 == 0) {
if(!shouldRenderDebug) --healPlayer(1);
if (regening && player.p.regenTimer % 90 == 0) {
if(!shouldRenderDebug) healPlayer(1);
}

if (k_pause.clicked){
Expand Down
2 changes: 2 additions & 0 deletions source/Item.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ char* getItemName(int itemID, int countLevel){
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_SPEED_POTION: sprintf(currentName,"%d Speed Potion", countLevel); return currentName;
case ITEM_REGEN_POTION: sprintf(currentName,"%d Regen 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;
Expand Down Expand Up @@ -304,6 +305,7 @@ char* getBasicItemName(int itemID, int countLevel){
case ITEM_COIN: return "Coin";
case ITEM_STRENGTH_POTION: return "Strength Potion";
case ITEM_SPEED_POTION: return "Speed Potion";
case ITEM_REGEN_POTION: return "Regen Potion";
case TOOL_BUCKET:
switch(countLevel){
case 1: return "Water Bucket";
Expand Down
1 change: 1 addition & 0 deletions source/Item.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#define ITEM_GOLD_APPLE 76
#define ITEM_STRENGTH_POTION 77
#define ITEM_SPEED_POTION 78
#define ITEM_REGEN_POTION 79

#define TOOL_BUCKET 101
#define TOOL_BOW 102
Expand Down
32 changes: 3 additions & 29 deletions source/MenuTutorial.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ void renderTutorialPage(bool topScreen){
break;
case 7: // Potion Brewing
drawTextColor("Brewing",(400-6*12)/2,40,0xFF007FBF);
drawText("Use the Potion Maker to make potions",(400-29*12)/2,74);
drawText("The potions give you abilities",(400-20*12)/2,94);
drawText("Create potions.",(400-13*12)/2,74);
drawText("The potions give you abilities",(400-29*12)/2,94);
drawText("Like speed and strength",(400-22*12)/2,114);
drawText("They are hard to obtain",(400-22*12)/2,134);
drawText("So get to it!",(400-24*12)/2,154);
break;
}
} else {
Expand Down Expand Up @@ -242,32 +241,7 @@ void renderTutorialPage(bool topScreen){
render(130,56,144,144,0); // Gold Pickaxe
break;
case 7: // Brewing
render16(23,32,464,48,0); // iron ore
render16(23,52,480,48,0); // gold ore
render16(23,72,496,48,0); // gem ore
renderb(41,38,88,152,0,ironColor); // Iron ore item
renderb(41,58,88,152,0,goldColor); // Gold ore item
render(41,78,112,152,0); // Gem item
drawText(">",104,74);
drawText(">",104,114);
drawText(">",104,154);
render16(60,32,112,128,0); // Furnace
render16(60,52,112,128,0); // Furnace
render16(60,72,240,128,0); // Enchanter
drawText(">",160,74);
drawText(">",160,114);
drawText(">",160,154);
renderb(88,36,96,152,0,ironColor); // Iron ingot item
renderb(88,56,96,152,0,goldColor); // Gold ingot item
renderb(88,76,152,144,0,goldColor); // Gem Pickaxe
drawText(">",200,74);
drawText(">",200,114);
render16(106,32,64,128,0); // Anvil
render16(106,52,64,128,0); // Anvil
drawText(">",244,74);
drawText(">",244,114);
render(130,36,136,144,0); // Iron Pickaxe
render(130,56,144,144,0); // Gold Pickaxe
render16(65, 56, 240, 96, 0);
break;
}

Expand Down
3 changes: 3 additions & 0 deletions source/Render.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,9 @@ void renderItemIcon(int itemID, int countLevel, int x, int y) {
case ITEM_SPEED_POTION:
render(x, y, 191, 160, 0);
break;
case ITEM_REGEN_POTION:
render(x, y, 198, 160, 0);
break;
case ITEM_SLIME:
renderb(x, y, 88, 152, 0, 0xFF4DC04D);
break;
Expand Down

0 comments on commit 2456782

Please sign in to comment.