Skip to content

Commit

Permalink
Version 1.5.0
Browse files Browse the repository at this point in the history
Big Refactor
  • Loading branch information
andre111 committed Feb 4, 2018
1 parent 3b2a0f4 commit d2f7796
Show file tree
Hide file tree
Showing 49 changed files with 5,289 additions and 3,573 deletions.
Binary file modified Minicraft3DS.zip
Binary file not shown.
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 data/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions source/Crafting.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#include "Crafting.h"

void cloneRecipeManager(RecipeManager *from, RecipeManager *to) {
//free old manager recipes
free(to->recipes);

//copy over recipes
to->size = from->size;
to->recipes = (Recipe*)malloc(sizeof(Recipe) * to->size);
memcpy(to->recipes, from->recipes, sizeof(Recipe) * to->size);
}

void checkCanCraftRecipes(RecipeManager * rm, Inventory * inv){
int i, j;
for(i = 0; i < rm->size; i++){
Expand Down
7 changes: 4 additions & 3 deletions source/Crafting.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#include <stdarg.h>
#include "Item.h"

typedef struct {
typedef struct _recipecost {
int costItem;
int costAmount;
} Cost;

typedef struct {
typedef struct _recipe {
bool canCraft;
int itemResult;
int itemAmountLevel;
Expand All @@ -16,7 +16,7 @@ typedef struct {
u8 order; // Used for stable sorting.
} Recipe;

typedef struct {
typedef struct _recipeManager {
int size;
Recipe * recipes;
} RecipeManager;
Expand All @@ -31,6 +31,7 @@ RecipeManager enchanterRecipes;

Recipe defineRecipe(int item, int amountOrLevel, int numArgs, ...);

void cloneRecipeManager(RecipeManager *from, RecipeManager *to);
void checkCanCraftRecipes(RecipeManager * rm, Inventory * inv);
void sortRecipes(RecipeManager * rm);
bool craftItem(RecipeManager * rm, Recipe* r, Inventory* inv);
Expand Down
29 changes: 6 additions & 23 deletions source/Entity.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
#include "Entity.h"

#define PI 3.141592654
double gaussrand()
{
static double U, V;
static int phase = 0;
double Z;

if(phase == 0) {
U = (rand() + 1.) / (RAND_MAX + 2.);
V = rand() / (RAND_MAX + 1.);
Z = sqrt(-2 * log(U)) * sin(2 * PI * V);
} else
Z = sqrt(-2 * log(U)) * cos(2 * PI * V);

phase = 1 - phase;

return Z;
}
#include "Synchronizer.h"

Entity newItemEntity(Item item, int x, int y, int level){
Entity e;
Expand All @@ -34,8 +17,8 @@ Entity newItemEntity(Item item, int x, int y, int level){
e.entityItem.xx = x;
e.entityItem.yy = y;
e.entityItem.zz = 2;
e.entityItem.xa = gaussrand() * 0.1;
e.entityItem.ya = gaussrand() * 0.1;
e.entityItem.xa = gaussrand(false) * 0.1;
e.entityItem.ya = gaussrand(false) * 0.1;
e.entityItem.za = ((float)rand() / RAND_MAX) * 0.45 + 1;

return e;
Expand Down Expand Up @@ -296,8 +279,8 @@ Entity newTextParticleEntity(char * str, u32 color, int x, int y, int level){
e.textParticle.xx = x;
e.textParticle.yy = y;
e.textParticle.zz = 2;
e.textParticle.xa = gaussrand() * 0.3;
e.textParticle.ya = gaussrand() * 0.2;
e.textParticle.xa = gaussrand(false) * 0.3;
e.textParticle.ya = gaussrand(false) * 0.2;
e.textParticle.za = ((float)rand() / RAND_MAX) * 0.7 + 2;

return e;
Expand All @@ -310,7 +293,7 @@ Entity newSmashParticleEntity(int x, int y, int level){
e.x = x;
e.y = y;
e.canPass = true;
playSound(snd_monsterHurt);
playSoundPositioned(snd_monsterHurt, e.level, e.x, e.y); //TODO: This is a wierd location for the effect
return e;
}

Expand Down
16 changes: 7 additions & 9 deletions source/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

typedef struct Entity Entity;

typedef struct _plrd PlayerData; //in order to not include Player.h and cause all sorts of problems

typedef struct {
s8 ax;
s8 ay;
Expand All @@ -45,9 +47,8 @@ typedef struct {
bool isCarrying;
bool isSwimming;
int swimTimer;
int score;
Inventory* inv;
Item* activeItem;

PlayerData *data;
} Player;


Expand All @@ -65,9 +66,8 @@ typedef struct {
typedef struct {
s16 itemID;
bool active;
s8 r; // light radius for lantern. window select for chests.
s8 r; // light radius for lantern.
Inventory* inv; // Points to chest inventory.
s16 oSel; // other selection inside the chest inv.
} EntityFurniture;

typedef struct {
Expand Down Expand Up @@ -215,18 +215,16 @@ struct Entity {
typedef struct {
Entity entities[6][1000];
s16 lastSlot[6];
Inventory invs[301];//1 for the player, 300 for chests.
Inventory invs[300];
s16 nextInv;
} EntityManager;

EntityManager eManager;
Entity nullEntity;
s8 currentLevel;


double gaussrand();
Entity newItemEntity(Item item, int x, int y, int level);
Entity newFurnitureEntity(int itemID,Inventory * invPtr, int x, int y, int level);
Entity newFurnitureEntity(int itemID, Inventory * invPtr, int x, int y, int level);
Entity newPassiveEntity(int type, int x, int y, int level);
Entity newZombieEntity(int lvl, int x, int y, int level);
Entity newSkeletonEntity(int lvl, int x, int y, int level);
Expand Down
Loading

0 comments on commit d2f7796

Please sign in to comment.