Hello Forum,
One day I remembered an old zombie game I played I high school computer class. I found the source code for it. Turns out it was written for Processing 1.0.
Ive coded with java and python before, but not in processing or for making video games.
There is a function called look() that takes four arguments and that is not recognized. I think its all old Processing thing, but I cant find any information about it.
Can any of you help me?
here the script.
// Zombie Infection Simulation // Kevan Davis, 16/8/03 // Modified by John Gilbertson 25/09/03 // just making zombies more dangerous, edited level creation code, increased max zombies, made zombies less likely to group etc...
int freeze;
int num=4000;
int speed=1;
int panic=5;
int human;
int panichuman;
int zombie;
int dead;
int wall;
int empty;
int clock=0;
int hit;
int ishuman=2;
int ispanichuman=4;
int iszombie=1;
int isdead=5;
Being[] beings;
void setup() {
PFont f=loadFont("Impact-48.vlw");
frameRate(45);
textFont(f,19);
int x,y;
size(1200,800);
human=color(200,0,200);
panichuman=color(255,120,255);
zombie=color(0,255,0);
wall=color(50,50,60);
empty=color(0,0,0);
dead=color(128,30,30);
hit=color(128,128,0);
clock=0;
// noBackground();
fill(wall);
rect(0,0,width,height);
fill(wall);
stroke(empty);
for (int i=0; i<100; i++) {
rect((int)random(width)-(width/8), (int)random(height)-(height/8),(int)random(width/4), (int)random(height/4));
}
fill(empty);
stroke(empty);
for (int i=0; i<45; i++) {
rect((int)random(width-1)+1, (int)random(height-1)+1, (int)random(40)+10,(int)random(40)+10);
x=(int)random(width-1)+1; y=(int)random(height-1)+1;
}
/* fill(wall); stroke(wall); rect(190,0,20,200); rect(0,90,400,20);*/
fill(wall);
noStroke();
rect(0,height-30,width,height);
fill(empty);
stroke(wall);
rect(0,height-30,width-2,height-2);
beings = new Being[8000];
}
void keyPressed() {
if(key == ' ') {
key='z';
}
if(key == '+' && num < 8000) {
num += 100;
key='z';
} if(key == '-' && num > 4000) {
num -= 100;
key='z';
}
if(key == 'z' || key == 'Z') {
freeze=1;
setup();
}
}
class Being {
int xpos, ypos, dir;
int type, active;
int belief, maxBelief;
int zombielife;
int rest;
Being() {
dir = (int)random(4)+1;
type = ishuman;
active = 0;
belief=500;
maxBelief=500;
zombielife=1300;
rest=40;
}
void die() {
type=5;
}
void position() {
for (int ok=0; ok<100; ok++) {
xpos = (int)random(width-1)+1;
ypos = (int)random(height-30)+1;
if (get(xpos,ypos)==color(0,0,0)) {
ok = 100;
}
}
}
void infect(int x, int y) {
if (x==xpos && y==ypos) {
type = 1;
}
}
void infect() {
type = 1;
set(xpos, ypos, zombie);
}
void uninfect() {
type = ishuman;
active = 0;
zombielife=1000;
belief=500;
}
void move() {
if(type==5){
set(xpos,ypos,dead);
} else {
int r = (int)random(3);
if ((type==ishuman && active>0) || r==1) {
set(xpos, ypos, color(0,0,0));
if(belief<=0) {
active=0;
maxBelief-=100;
belief=0;
rest=0;
}
if (look(xpos,ypos,dir,1)==0) { */LOOK DONT WORK*/
if (dir==1) {
ypos--;
} else if (dir==2) {
xpos++;
} else if (dir==3) {
ypos++;
} else if (dir==4) {
xpos--;
}
/* if(belief>0) { belief--; }*/
} else {
dir = (int)random(4)+1;
}
if (type == 1) {
set(xpos, ypos, zombie);
} else if (active > 0) {
set(xpos, ypos, panichuman);
} else {
set(xpos, ypos, human);
} if (active>0) {
active--;
}
}
int target = look(xpos,ypos,dir,10) /*LOOK DONT WORK*/
if (type==1) {
zombielife--;
if (target==2 || target==4) {
active = 10;
} else if (target==3) {
if((int)random(8)==1) {
if (dir==1) {
set(xpos,ypos-1,empty);
} else if (dir==2) {
set(xpos+1,ypos,empty);
} else if (dir==3) {
set(xpos,ypos+1,empty);
} else if (dir==4) {
set(xpos-1,ypos,empty);
}
}
if(0==iszombie) {
dir=dir+1;
if(dir>4) dir=1;
}
} else if (active==0 && target!=1) {
if((int)random(6)>4) {
if((int)random(2)==0) dir = dir+1;
else dir = dir-1;
if(dir==5) dir=1;
if(dir==0) dir=4;
} else {
dir=dir;
}
}
int victim = 0;
if (victim == 2 || victim==4) {
int ix = xpos;
int iy = ypos;
if (dir==1) {
iy--;
}
if (dir==2) {
ix++;
}
if (dir==3){
iy++;
}
if (dir==4) {
ix--;
}
/* for(int i=0; i=0;i++) {
belief--;
}*/
if(belief==0 && maxBelief!=0 && rest>=40) {
belief=maxBelief;
rest=0;
}else if(belief==0 && rest<40) {
rest++;
}
} else if(target!=1 && target!=4 && active==0) {
rest++;
} else if (target==1) {
dir = dir + 2;
if (dir>4) {
dir = dir - 4;
}
}
if ((int)random(2)==1) {
dir = (int)random(4)+1;
}
}
}
}
}