Skip to content

Commit

Permalink
All the Stuff(Forgot to commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre111 committed Jan 1, 2016
1 parent 7eb2832 commit 7d08458
Show file tree
Hide file tree
Showing 22 changed files with 1,662 additions and 313 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sfillib by xerpi: https://github.com/xerpi/sfillib

zlib: http://www.zlib.net/

Current Version: Version 1.1
Current Version: Version 1.2

You can do anything with the source code (besides sell it) as long as you give proper credit to the right people.
If you are going to make a mod of this version, be sure to give credit to Markus "Notch" Perrson because he did create the original game after all.
Expand Down
Binary file modified data/icons2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/music/floor1_night.raw
Binary file not shown.
72 changes: 49 additions & 23 deletions source/Crafting.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,30 @@ Recipe defineRecipe(int item, int amountOrLevel, int numArgs, ...){
void initRecipes(){

curPlace = 0;
workbenchRecipes.size = 16;
workbenchRecipes.size = 22;
workbenchRecipes.recipes = (Recipe*)malloc(sizeof(Recipe) * (workbenchRecipes.size));
workbenchRecipes.recipes[0] = defineRecipe(ITEM_WORKBENCH,1,1,ITEM_WOOD,20);
workbenchRecipes.recipes[1] = defineRecipe(ITEM_FURNACE,1,1,ITEM_STONE,20);
workbenchRecipes.recipes[2] = defineRecipe(ITEM_OVEN,1,1,ITEM_STONE,20);
workbenchRecipes.recipes[3] = defineRecipe(ITEM_CHEST,1,1,ITEM_WOOD,20);
workbenchRecipes.recipes[4] = defineRecipe(ITEM_ANVIL,1,1,ITEM_IRONINGOT,5);
workbenchRecipes.recipes[5] = defineRecipe(ITEM_LANTERN,1,3,ITEM_WOOD,5,ITEM_SLIME,10,ITEM_GLASS,4);
workbenchRecipes.recipes[6] = defineRecipe(TOOL_SWORD,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[7] = defineRecipe(TOOL_AXE,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[8] = defineRecipe(TOOL_HOE,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[9] = defineRecipe(TOOL_PICKAXE,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[10] = defineRecipe(TOOL_SHOVEL,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[11] = defineRecipe(TOOL_SWORD,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[12] = defineRecipe(TOOL_AXE,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[13] = defineRecipe(TOOL_HOE,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[14] = defineRecipe(TOOL_PICKAXE,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[15] = defineRecipe(TOOL_SHOVEL,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[6] = defineRecipe(ITEM_LOOM,1,2,ITEM_WOOD,10,ITEM_WOOL,5);
workbenchRecipes.recipes[7] = defineRecipe(TOOL_SWORD,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[8] = defineRecipe(TOOL_AXE,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[9] = defineRecipe(TOOL_HOE,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[10] = defineRecipe(TOOL_PICKAXE,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[11] = defineRecipe(TOOL_SHOVEL,0,1,ITEM_WOOD,5);
workbenchRecipes.recipes[12] = defineRecipe(TOOL_BOW,0,2,ITEM_WOOD,10,ITEM_STRING,1);
workbenchRecipes.recipes[13] = defineRecipe(ITEM_ARROW_WOOD,1,2,ITEM_WOOD,2,ITEM_STRING,1);
workbenchRecipes.recipes[14] = defineRecipe(TOOL_SWORD,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[15] = defineRecipe(TOOL_AXE,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[16] = defineRecipe(TOOL_HOE,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[17] = defineRecipe(TOOL_PICKAXE,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[18] = defineRecipe(TOOL_SHOVEL,1,2,ITEM_WOOD,5,ITEM_STONE,5);
workbenchRecipes.recipes[19] = defineRecipe(ITEM_ARROW_STONE,1,3,ITEM_WOOD,1,ITEM_STONE,1,ITEM_STRING,1);
workbenchRecipes.recipes[20] = defineRecipe(ITEM_WALL_WOOD,1,1,ITEM_WOOD,4);
workbenchRecipes.recipes[21] = defineRecipe(ITEM_WALL_STONE,1,1,ITEM_STONE,4);

anvilRecipes.size = 16;
anvilRecipes.recipes = (Recipe*)malloc(sizeof(Recipe) * (anvilRecipes.size));
Expand All @@ -105,27 +111,45 @@ void initRecipes(){
anvilRecipes.recipes[2] = defineRecipe(TOOL_HOE,2,2,ITEM_WOOD,5,ITEM_IRONINGOT,5);
anvilRecipes.recipes[3] = defineRecipe(TOOL_PICKAXE,2,2,ITEM_WOOD,5,ITEM_IRONINGOT,5);
anvilRecipes.recipes[4] = defineRecipe(TOOL_SHOVEL,2,2,ITEM_WOOD,5,ITEM_IRONINGOT,5);
anvilRecipes.recipes[5] = defineRecipe(TOOL_SWORD,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[6] = defineRecipe(TOOL_AXE,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[7] = defineRecipe(TOOL_HOE,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[8] = defineRecipe(TOOL_PICKAXE,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[9] = defineRecipe(TOOL_SHOVEL,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[10] = defineRecipe(TOOL_SWORD,4,2,ITEM_WOOD,5,ITEM_GEM,50);
anvilRecipes.recipes[11] = defineRecipe(TOOL_AXE,4,2,ITEM_WOOD,5,ITEM_GEM,50);
anvilRecipes.recipes[12] = defineRecipe(TOOL_HOE,4,2,ITEM_WOOD,5,ITEM_GEM,50);
anvilRecipes.recipes[13] = defineRecipe(TOOL_PICKAXE,4,2,ITEM_WOOD,5,ITEM_GEM,50);
anvilRecipes.recipes[14] = defineRecipe(TOOL_SHOVEL,4,2,ITEM_WOOD,5,ITEM_GEM,50);
anvilRecipes.recipes[15] = defineRecipe(TOOL_BUCKET,0,1,ITEM_IRONINGOT,10);
anvilRecipes.recipes[5] = defineRecipe(ITEM_ARROW_IRON,1,3,ITEM_WOOD,1,ITEM_IRONINGOT,1,ITEM_STRING,1);
anvilRecipes.recipes[6] = defineRecipe(TOOL_SWORD,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[7] = defineRecipe(TOOL_AXE,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[8] = defineRecipe(TOOL_HOE,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[9] = defineRecipe(TOOL_PICKAXE,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[10] = defineRecipe(TOOL_SHOVEL,3,2,ITEM_WOOD,5,ITEM_GOLDINGOT,5);
anvilRecipes.recipes[11] = defineRecipe(ITEM_ARROW_GOLD,1,3,ITEM_WOOD,1,ITEM_GOLDINGOT,1,ITEM_STRING,1);
anvilRecipes.recipes[12] = defineRecipe(TOOL_BUCKET,0,1,ITEM_IRONINGOT,10);
anvilRecipes.recipes[13] = defineRecipe(ITEM_ENCHANTER,1,3,ITEM_WOOD,10,ITEM_GOLDINGOT,10,ITEM_GEM,20);
anvilRecipes.recipes[14] = defineRecipe(ITEM_WALL_IRON,1,1,ITEM_IRONINGOT,2);
anvilRecipes.recipes[15] = defineRecipe(ITEM_WALL_GOLD,1,1,ITEM_GOLDINGOT,2);

furnaceRecipes.size = 3;
furnaceRecipes.recipes = (Recipe*)malloc(sizeof(Recipe) * (furnaceRecipes.size));
furnaceRecipes.recipes[0] = defineRecipe(ITEM_IRONINGOT,1,2,ITEM_IRONORE,4,ITEM_COAL,1);
furnaceRecipes.recipes[1] = defineRecipe(ITEM_GOLDINGOT,1,2,ITEM_GOLDORE,4,ITEM_COAL,1);
furnaceRecipes.recipes[2] = defineRecipe(ITEM_GLASS,1,2,ITEM_SAND,4,ITEM_COAL,1);

ovenRecipes.size = 1;
ovenRecipes.size = 3;
ovenRecipes.recipes = (Recipe*)malloc(sizeof(Recipe) * (ovenRecipes.size));
ovenRecipes.recipes[0] = defineRecipe(ITEM_BREAD,1,1,ITEM_WHEAT,4);
ovenRecipes.recipes[1] = defineRecipe(ITEM_PORK_COOKED,1,2,ITEM_PORK_RAW,1,ITEM_COAL,1);
ovenRecipes.recipes[2] = defineRecipe(ITEM_BEEF_COOKED,1,2,ITEM_BEEF_RAW,1,ITEM_COAL,1);

loomRecipes.size = 1;
loomRecipes.recipes = (Recipe*)malloc(sizeof(Recipe) * (loomRecipes.size));
loomRecipes.recipes[0] = defineRecipe(ITEM_STRING,1,1,ITEM_WOOL,1);

enchanterRecipes.size = 8;
enchanterRecipes.recipes = (Recipe*)malloc(sizeof(Recipe) * (enchanterRecipes.size));
enchanterRecipes.recipes[0] = defineRecipe(TOOL_SWORD,4,2,ITEM_WOOD,5,ITEM_GEM,50);
enchanterRecipes.recipes[1] = defineRecipe(TOOL_AXE,4,2,ITEM_WOOD,5,ITEM_GEM,50);
enchanterRecipes.recipes[2] = defineRecipe(TOOL_HOE,4,2,ITEM_WOOD,5,ITEM_GEM,50);
enchanterRecipes.recipes[3] = defineRecipe(TOOL_PICKAXE,4,2,ITEM_WOOD,5,ITEM_GEM,50);
enchanterRecipes.recipes[4] = defineRecipe(TOOL_SHOVEL,4,2,ITEM_WOOD,5,ITEM_GEM,50);
enchanterRecipes.recipes[5] = defineRecipe(ITEM_ARROW_GEM,1,3,ITEM_WOOD,1,ITEM_GEM,3,ITEM_STRING,1);
enchanterRecipes.recipes[6] = defineRecipe(ITEM_WALL_GEM,1,1,ITEM_GEM,10);
enchanterRecipes.recipes[7] = defineRecipe(ITEM_WIZARD_SUMMON,1,4,ITEM_CLOUD,100,ITEM_IRONINGOT,10,ITEM_BONE,10,ITEM_LEATHER,10);

}

/* Free up allocated memory */
Expand All @@ -134,4 +158,6 @@ void freeRecipes(){
free(ovenRecipes.recipes);
free(furnaceRecipes.recipes);
free(anvilRecipes.recipes);
free(loomRecipes.recipes);
free(enchanterRecipes.recipes);
}
2 changes: 2 additions & 0 deletions source/Crafting.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ RecipeManager workbenchRecipes;
RecipeManager furnaceRecipes;
RecipeManager ovenRecipes;
RecipeManager anvilRecipes;
RecipeManager loomRecipes;
RecipeManager enchanterRecipes;

void checkCanCraftRecipes(RecipeManager * rm, Inventory * inv);
void sortRecipes(RecipeManager * rm);
Expand Down
122 changes: 114 additions & 8 deletions source/Entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ Entity newFurnitureEntity(int itemID,Inventory * invPtr, int x, int y, int level
return e;
}

Entity newPassiveEntity(int type, int x, int y, int level){
Entity e;
e.type = ENTITY_PASSIVE;
e.level = level;
e.x = x;
e.y = y;
e.hurtTime = 0;
e.xKnockback = 0;
e.yKnockback = 0;
e.passive.mtype = type;
e.passive.health = 20;
e.passive.dir = 0;
e.passive.xa = 0;
e.passive.ya = 0;
e.xr = 4;
e.yr = 3;
e.canPass = false;
return e;
}

Entity newZombieEntity(int lvl, int x, int y, int level){
Entity e;
Expand All @@ -75,17 +94,72 @@ Entity newZombieEntity(int lvl, int x, int y, int level){
e.hurtTime = 0;
e.xKnockback = 0;
e.yKnockback = 0;
e.zombie.lvl = lvl;
e.zombie.health = lvl * lvl * 10;
e.zombie.dir = 0;
e.hostile.lvl = lvl;
e.hostile.xa = 0;
e.hostile.ya = 0;
e.hostile.health = lvl * lvl * 10;
e.hostile.dir = 0;
e.xr = 4;
e.yr = 3;
e.canPass = false;
switch(lvl){
case 2: e.hostile.color = 0xFF8282CC; break;
case 3: e.hostile.color = 0xFFEFEFEF; break;
case 4: e.hostile.color = 0xFFAA6262; break;
default: e.hostile.color = 0xFF95DB95; break;
}
return e;
}

Entity newSkeletonEntity(int lvl, int x, int y, int level){
Entity e;
e.type = ENTITY_SKELETON;
e.level = level;
e.x = x;
e.y = y;
e.hurtTime = 0;
e.xKnockback = 0;
e.yKnockback = 0;
e.hostile.lvl = lvl;
e.hostile.xa = 0;
e.hostile.ya = 0;
e.hostile.health = lvl * lvl * 10;
e.hostile.dir = 0;
e.hostile.randAttackTime = 0;
e.xr = 4;
e.yr = 3;
e.canPass = false;
switch(lvl){
case 2: e.zombie.color = 0xFF8282CC; break;
case 3: e.zombie.color = 0xFFEFEFEF; break;
case 4: e.zombie.color = 0xFFAA6262; break;
default: e.zombie.color = 0xFF95DB95; break;
case 2: e.hostile.color = 0xFFC4C4C4; break;
case 3: e.hostile.color = 0xFFA0A0A0; break;
case 4: e.hostile.color = 0xFF7A7A7A; break;
default: e.hostile.color = 0xFFFFFFFF; break;
}
return e;
}

Entity newKnightEntity(int lvl, int x, int y, int level){
Entity e;
e.type = ENTITY_KNIGHT;
e.level = level;
e.x = x;
e.y = y;
e.hurtTime = 0;
e.xKnockback = 0;
e.yKnockback = 0;
e.hostile.lvl = lvl;
e.hostile.xa = 0;
e.hostile.ya = 0;
e.hostile.health = lvl * lvl * 20;
e.hostile.dir = 0;
e.xr = 4;
e.yr = 3;
e.canPass = false;
switch(lvl){
case 2: e.hostile.color = 0xFF0000C6; break;
case 3: e.hostile.color = 0xFF00A3C6; break;
case 4: e.hostile.color = 0xFF707070; break;
default: e.hostile.color = 0xFFFFFFFF; break;
}
return e;
}
Expand Down Expand Up @@ -141,6 +215,7 @@ Entity newAirWizardEntity(int x, int y, int level){
Entity newSparkEntity(Entity* parent, float xa, float ya){
Entity e;
e.type = ENTITY_SPARK;
e.level = parent->level;
e.spark.age = 0;
e.spark.parent = parent;
e.spark.xa = xa;
Expand Down Expand Up @@ -185,13 +260,44 @@ Entity newSmashParticleEntity(int x, int y, int level){
return e;
}

Entity newArrowEntity(Entity* parent, int itemID, s8 xa, s8 ya, int level){
Entity e;
e.type = ENTITY_ARROW;
e.level = level;
e.arrow.age = 0;
e.arrow.parent = parent;
e.arrow.itemID = itemID;
e.arrow.xa = xa;
e.arrow.ya = ya;
e.x = parent->x;
e.y = parent->y;
e.xr = 2;
e.yr = 2;
e.canPass = false;
e.canSwim = true;
return e;
}

Entity newGlowwormEntity(int x, int y, int level){
Entity e;
e.type = ENTITY_GLOWWORM;
e.level = level;
e.glowworm.xa = 0;
e.glowworm.ya = 0;
e.glowworm.randWalkTime = 0;
e.glowworm.waitTime = 0;
e.x = x;
e.y = y;
e.canPass = true;
return e;
}

void addEntityToList(Entity e, EntityManager* em){
e.slotNum = em->lastSlot[e.level];
em->entities[e.level][em->lastSlot[e.level]] = e;
++em->lastSlot[e.level];
}

Entity nullEntity;
void removeEntityFromList(Entity * e,int level,EntityManager* em){
int i;
if(em->entities[level][e->slotNum].type == ENTITY_TEXTPARTICLE) free(em->entities[level][e->slotNum].textParticle.text);
Expand Down
Loading

0 comments on commit 7d08458

Please sign in to comment.