//Here's the custom functions to operate Item and Weapon made by Bee-Ant
const int MAX_SLOT=99; //is the max slot
char stuff_name[MAX_SLOT+1][32];
int stuff_atr[MAX_SLOT+1][2]; //[index][0] is the type, while [index][1] is the amount
//The type as follow :
int item=0;
int weapon=1;
void delete_stuff(char*A,int type) //A is the stuff name
{
int i,index;
for(i=0;i<MAX_SLOT;i++) //search the stuff index
{
if(!strcmp(stuff_name[i],A)&&stuff_atr[i][0]==type)
{
index=i;i=MAX_SLOT; //gotcha
}
}
strcpy(stuff_name[index],"");stuff_atr[index][0]=0;stuff_atr[index][1]=0; //delete the stuff
for(i=index;i<MAX_SLOT;i++) //re-sort the stuff list
{
strcpy(stuff_name[i],stuff_name[i+1]);
stuff_atr[i][0]=stuff_atr[i+1][0];
stuff_atr[i][1]=stuff_atr[i+1][1];
}
}
void use_stuff(char*A,int type,int amount) //A is the stuff name
{
int i,index;
for(i=0;i<MAX_SLOT;i++) //search the stuff index
{
if(!strcmp(stuff_name[i],A)&&stuff_atr[i][0]==type)
{
index=i;i=MAX_SLOT; //gotcha
}
}
if(stuff_atr[index][1]>amount)
{
stuff_atr[index][1]-=amount; //use if current amount higher than the requested amount
}
if(stuff_atr[index][1]==amount)
{
delete_stuff(A,type); //delete if the current amount equal with the requested amount
}
if(stuff_atr[index][1]<amount)
{
//you can add some alert that the requested amount higher than the current amount here
}
}
void add_stuff(char*A,int type,int amount) //A is the stuff name
{
int i,index=MAX_SLOT+1;
for(i=0;i<MAX_SLOT;i++) //search the last/empty stuff index
{
if(!strcmp(stuff_name[i],""))
{
index=i;i=MAX_SLOT; //gotcha
}
}
if(index<MAX_SLOT+1) //if the slot isn't full yet, add the item
{
strcpy(stuff_name[index],A);
stuff_atr[index][0]=type;
stuff_atr[index][1]=amount;
}
if(index==MAX_SLOT+1) //if the slot is already full
{
//you can add some alert here
}
}
//function("stuff name",stuff type, stuff amount);
add_stuff("antidote",item,1); //1 is the amount you want to add
use_stuff("antidote",item,1); //1 is the amount you want to use
delete_stuff("antidote",item);
add_stuff("sword",weapon,2); //2 is the amount you want to add
use_stuff("sword",weapon,2); //2 is the amount you want to use
delete_stuff("sword",weapon);
add_stuff(ToLower("AnTiDote"),item,1);
zxcvbnm wrote:There is no need because you can just change the value of " mjump" to 2 or 3 for the specific platform you want the player to be able to double or triple jump. This saves you precious memory which could be used in another part of your game.
Fuzzy wrote:Bee says that sun java 6 with Ubuntu prevents posting on GE. I dont know how hes controlling his data, but it works for me.
needaname wrote:a string is an array of char so characters
char str[32]="needaname";
int str[32]={110,101,101,100,97,110,97,109,101};
intvar=(int)str[index];
sprintf(str,"%s",&intvar);
Users browsing this forum: No registered users and 1 guest