One of my first programming projects. I tried to learn C and use curses...it is quite embarrassing looking back at it now :D
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
768 B

#include <events.h>
#include <structs.h>
#include <world.h>
#include <getPos.h>
#include <time.h>
#include <stdlib.h>
#include <zombies.h>
void addItem(char *type, int yPos, int xPos){
if(!strcmp(type,"Pistol Magazine")){
struct Item pistolMag = {.type="Pistol Magazine", .symbol='=', .isAlive=1, .curXpos=xPos, .curYpos=yPos};
int i;
for (i=0;i<MAX_ITEMS;i++){
if(!allItems[i].isAlive){
allItems[i]=pistolMag;
break;
}
}
}
}
void tryRandomEvent(){
int eventTrigger = (rand()%100)+1;
if (eventTrigger < 10+itemModifier){
struct OpenPos openPos = getOpenPos();
addItem("Pistol Magazine", openPos.y, openPos.x);
}
if (eventTrigger < 1+zombieModifier){
struct OpenPos openPos = getOpenPos();
addZombie(openPos.y, openPos.x);
}
}