xxxxxxxxxx
angleMode = 'degrees';
void setup() {
size(600,600,1);
noStroke();
rectMode(CENTER);
textAlign(CENTER,CENTER);
textSize(20);
};
var rotate1=function(a){
rotate(a*(PI/180));
};
var atan3=function(a,b){
return atan2(a,b)/PI*180;
};
var cos1=function(a){
return Math.cos(a/180*Math.PI);
};
var sin1=function(a){
return Math.sin(a/180*Math.PI);
};
var tan1=function(a){
return Math.tab(a/180*Math.PI);
};
// choose the color of the player
var sightColor = color(0, 0, 0),
sightColor2 = color(255, 255, 255);
var playerColor = color(255, 255, 255);
var HaveSound=false;
var GSAVE={
gunG:'1r;24;u;k;2e;24;1h;u;24;24;17;2e;u;17;24;2e;u;24;17;u;2e;17;u;17;24;1r;1r;1r;k;1h;24;17;1r;u;24;17;u;17;u;1h;17;u;2e;1h;24;1h;24;2e;1h;24;k;1r;',
wave:17,
upG:[0,0,0,0,0,0],
s:'a'
};
// put save code here /\
{
var shake=0;
var PowerEquip=3;
var gunbou=0;//guns biy
var waveSpeed=1;
var FIX_SHOP_BUG=false; //set this to true ifshop crashes game
var splat_Spawn=8; //set to 0 to turn of splat (BLOOD)marks
var REMOVELAG=false; //set true to decrease lag
var Max_effects=250; //max number of effect
var itemLife=10000; //how long dropped item last
//*********************************************
// SETTINGS
//*********************************************
var scene=-201; //set to 1 to skip menu
var waveTimer=100; //time between waves
var damageMULT=1.00; //how much more damage you do (1.00=base)
var damageMULTbase=1;
var HpRegen=0.00; // how fast your HP regens
var Zombie_Dect_timer=9; //how often the game test s the zombies
var Zombie_Spawn_thes=5; //# zombies needed for next wave
var MAP_W=800;
var MAP_H=800;
/**pick class here*/
var player_model_E=0; //what class you choose 0-13
var AREA_MAP=2;
var Game_mode=1;
var Zombie_di_mult=1.2;
var DiedHow="none";
var shooting=false; //is player shooting
var IsReloading=false; // are you reloading
var ReloadTimer=0; //reload timer
var pause=false; // ifgame is paused
var angle=0; //players angle angle
var time=0;
var shotFired=0; // how many rounds you have fired
var wave=0; //what wave your on
var zombiespawnT=0; // zombie spawn timer
var Zkills=0; // number of zombies killed
var Pspeed=4; //player speed
var money=0; //money the player starts with
var Parmor=0;
var ParmorMax=50;
var Gems=0;
var AnC;
var PowerTimer=0; //Timer for powerUp
var PowerDelay=120;//powerUp delay
var PowerCount=3;//powerup count
//past mouse X and Y
var PmouseX=0,
PmouseY=0;
// player sprintmax player sprint
var PS=100,
PSmax=100;
// player health points and max player health points
var Php=100,
PhpMax=100;
//player X and Y cord
var PX=300,
PY=100;
//cam X and Y
var CamX=0,
CamY=0;
var GunSGOT=0;
var GunSGOTE=0;
var Time=0;
var Pnoise=100; //player noise
var stor=[]; //stores effects
var gameTime=0; //
var FPStimer=millis(); //
var FPSCount=0; //
var FPSCountT=0; //
var handColor=color(255,255,255);
var RTx=0;
var RTy=0;
var BAcc=0,// gun acc
BAccM=0,
BAccAdd=0,
BAccR=0;
var BperS=0; // bullets per shot
var BSpeed=0; // bullet speed
var BDelay=0; // shot delay
var Bdam=0; // bullet damage
var ammo=0; // gun ammo
var ammoMax=0; // gun ammo max
//var ammoR=GUN[GUNE].ammoBank; // ammo res
var Reload=0; // how fast is the reload
var gunT=0; // the type
var BhpL=0; // the bullets live
//**********************************************************
// Item assests
//**********************************************************
var ITEMS=[{
//food
onPickupText: "+15 HP",
SHOW: function(){
noStroke();
fill(255,0,0);
rect(0,0,8,8);
fill(255,255,255);
rect(0,0,4,2);
rect(0,0,2,4);
},
onPickUp: function(){
Php+=15;
}
},{
onPickupText: "",
SHOW: function(){
noStroke();
fill(26,153,20);
rect(0,0,5,8);
fill(161,255,156);
rect(0,0,5,4);
},
onPickUp: function(){
money+=10;
}
},{
onPickupText: "+100 mec gun ammo",
SHOW: function(){
fill(255,166,0);
rect(0,0,8,8);
fill(153,143,8);
rect(0,0-2,4,1);
rect(0,0+2,4,1);
rect(0,0,4,1);
},
onPickUp: function(){
AmmoBANK[0]+=100;
}
},{
onPickupText: "+12 pistol ammo",
SHOW: function(){
fill(255,255,255);
rect(0,0,8,8);
fill(255,245,61);
rect(0,0-2,4,1);
rect(0,0+2,4,1);
rect(0,0,4,1);
},
onPickUp: function(){
AmmoBANK[1]+=12;
}
},{
onPickupText: "+5 sniper ammo",
SHOW: function(){
fill(173,129,75);
rect(0,0,8,8);
fill(255,245,61);
rect(0,0-2,4,1);
rect(0,0+2,4,1);
rect(0,0,4,1);
},
onPickUp: function(){
AmmoBANK[2]+=5;
}
},{
onPickupText: "+4 shot gun ammo",
SHOW: function(){
fill(255,255,255);
rect(0,0,8,8);
fill(255,61,61);
rect(0,0-2,4,1);
rect(0,0+2,4,1);
rect(0,0,4,1);
},
onPickUp: function(){
AmmoBANK[3]+=4;
}
},{
onPickupText: "+30 rifle ammo",
SHOW: function(){
fill(15,130,9);
rect(0,0,8,8);
fill(217,201,26);
rect(0,0-2,4,1);
rect(0,0+2,4,1);
rect(0,0,4,1);
},
onPickUp: function(){
AmmoBANK[4]+=30;
}
},{
onPickupText: "+50 smg ammo",
SHOW: function(){
fill(0,0,0);
rect(0,0,8,8);
fill(217,201,26);
rect(0,0-2,4,1);
rect(0,0+2,4,1);
rect(0,0,4,1);
},
onPickUp: function(){
AmmoBANK[5]+=50;
}
},{
onPickupText: "+15 armor",
SHOW: function(){
fill(0,0,0);
beginShape();
vertex(-7,4);
vertex(-7,-7);
vertex(7,-7);
vertex(7,4);
vertex(0,9);
endShape();
fill(69,69,69);
beginShape();
vertex(-5,2);
vertex(-5,-5);
vertex(5,-5);
vertex(5,2);
vertex(0,6);
endShape();
},
onPickUp: function(){
Parmor+=15;
if(HaveSound){playSound(getSound("rpg/step-heavy"));}
}
},{
onPickupText: "+1 GEM",
SHOW: function(){
fill(54, 135, 130);
beginShape();
vertex(-8,0);
vertex(-3,-4);
vertex(3,-4);
vertex(8,0);
vertex(0,8);
endShape();
fill(16, 227, 213);
beginShape();
vertex(-6,0);
vertex(-2,-3);
vertex(2,-3);
vertex(6,0);
vertex(0,6);
endShape();
},
onPickUp: function(){
Gems+=100;
}
},{
onPickupText: "+20 sprint",
SHOW: function(){
fill(129, 255, 110);
rect(0,0,8,8);
fill(255,255,255);
rect(0,0,4,2);
rect(0,0,2,4);
},
onPickUp: function(){
PS+=20;
}
},{
onPickupText: "+1 grenade",
SHOW: function(){
fill(9, 38, 4);
rect(0,-7,5,7);
fill(15, 69, 20);
ellipse(0,0,12,12);
},
onPickUp: function(){
PowerCount+=1;
}
},];
//**********************************************************
// fade effects for the menu
//**********************************************************
var FADE=function(position,t){
this.LiveT=250.0;
FADE.prototype.run=function(){
noStroke();
if(scene===1){
this.LiveT-=1;
}
else {
this.LiveT-=5;
}
fill(255,255,255,this.LiveT);
rect(width/2,height/2,width,height);
if(scene===1){
this.LiveT=0;
}
};
FADE.prototype.isDead=function(){
if(this.LiveT<0){
return true;
}
else {
return false;
}
};
};
//**********************************************************
// draw key
//**********************************************************
var keyDraw=function(x,y,K){
noFill();
stroke(8,8,8);
strokeWeight(3);
rect(x,y,50,50,10);
fill(3,3,3);
textSize(31);
text(K,x,y+3);
fill(255,255,255);
textSize(30);
text(K,x,y);
};
//**********************************************************
// menu buttons function
//**********************************************************
var button=function(x,y,w,h,txt,txtS,goto){
fill(219,219,219,50);
strokeWeight(5);
stroke(0,0,0);
if(mouseX>x-(w/2)&& mouseX<x+(w/2)&& mouseY>y-(h/2)&&
mouseY<y+(h/2)){
fill(173,173,173,200);
cursor("pointer");
if(CLICKED){
// if(mouseClicked){
stor2.push(new FADE(0,0,3));
scene=goto;
if(HaveSound){playSound(getSound("rpg/metal-clink"));}
//println(goto);
// }
} //}
}
rect(x,y,w,h);
strokeWeight(2);
stroke(140,140,140);
noFill();
rect(x,y,w-5,h-5);
fill(0,0,0);
textSize(txtS);
if(mouseX>x-(w/2)&& mouseX<x+(w/2)&& mouseY>y-(h/2)&&
mouseY<y+(h/2)){
noFill();
fill(0,0,0);
text(txt,x,(y+txtS/8)+ (h/25));
fill(255,255,255);
textSize(txtS);
text(txt,x,y+(h/25));
}
else {
fill(0,0,0);
text(txt,x,y+txtS/8);
fill(255,255,255);
textSize(txtS);
text(txt,x,y);
}
noStroke();
};
//**********************************************************
// sdsd
//**********************************************************
var Zshot2=function(position,pos2x,pos2y,rot){
this.acceleration=new PVector(0.00,0.00);
this.position=position.get();
this.LiveT=255.0;
this.OldX=this.position.x+random(-10,10);
this.OldY=this.position.y+random(-10,10);
this.NewX=0;
this.NewY=0;
this.Heading=rot;
if(splat_Spawn===1){this.LiveT=-1;}
Zshot2.prototype.run=function(){
this.NewX=this.OldX+(1.5*cos1(this.Heading)); //
this.NewY=this.OldY+(1.5*sin1(this.Heading));
this.OldX=this.NewX;
this.OldY=this.NewY;
pushMatrix();
translate(300-CamX,300-CamY);
translate(this.OldX,this.OldY);
noStroke();
fill(74,204,51,this.LiveT);
ellipse(0,0,5,5);
this.LiveT-=8;
popMatrix();
};
Zshot2.prototype.isDead=function(){
if(this.LiveT<0){
return true;
}
else {
return false;
}
};
};
//**********************************************************
// splat marks
//**********************************************************
var spt=function(position){
this.position=position.get();
this.LiveT=355.0;
this.size=random(5,10);
if(REMOVELAG){
this.LiveT=155.0;
}
if(FIX_SHOP_BUG){this.LiveT=100;}
if(stor.length>Max_effects){
this.LiveT=50;
}
};
spt.prototype.run=function(){
this.LiveT-=1;
//pushMatrix();
fill(103,355,0,this.LiveT);
//translate(this.position.x,this.position.y);
ellipse(this.position.x,this.position.y,this.size,this.size);
//popMatrix();
};
spt.prototype.isDead=function(){
if(this.LiveT<0){
return true;
}
else {
return false;
}
};
//**********************************************************
// expolsion particle
//**********************************************************
var BOOM=function(position){
this.position=position.get();
this.LiveT=250;
this.starCenterX=0; //this.position.x+(300-CamX);
this.starCenterY=0; //this.position.y+(300-CamY);
this.starRad=150;
this.pointX=0;
this.pointY=0;
this.angle=random(0,180);
noStroke();
BOOM.prototype.run=function(){
this.LiveT-=20;
pushMatrix();
translate(this.position.x,this.position.y);
beginShape();
fill(255,234,0,this.LiveT);
for (var count=0; count<7; count++){
this.pointX=this.starCenterX+this.starRad*sin1(this.angle);
this.pointY=this.starCenterY+this.starRad*cos1(this.angle);
vertex(this.pointX,this.pointY);
this.angle+=360/7*4;
}
endShape(CLOSE);
fill(355-this.LiveT,0,21,this.LiveT);
beginShape();
for (var count=0; count<7; count++){
this.pointX=this.starCenterX+60*sin1(this.angle);
this.pointY=this.starCenterY+60*cos1(this.angle);
vertex(this.pointX,this.pointY);
this.angle+=360/7*4;
}
endShape(CLOSE);
if(dist(this.position.x,this.position.y,PX,PY)< 100){
if(Parmor <=0){
DiedHow="blown up";
Php-=2;
}
else {
DiedHow="blown up";
Parmor-=1;
}
}
popMatrix();
};
BOOM.prototype.isDead=function(){
if(this.LiveT<0){
return true;
}
else {
return false;
}
};
};
var Gnad = function(position) {
this.LiveT = 255.0;
this.TX = mouseX-(300-CamX);
this.TY = mouseY-(300-CamY);
this.X = position.x;
this.Y = position.y;
this.Rot=random(0,360);
Gnad.prototype.run = function() {
this.X += (this.TX - this.X) * 0.03;
this.Y += (this.TY - this.Y) * 0.03;
pushMatrix();
translate(this.X,this.Y);
rotate1(this.Rot);
fill(9, 38, 4);
rect(0,-7,5,7);
fill(15, 69, 20);
ellipse(0,0,12,12);
this.LiveT-=5;
popMatrix();
};
Gnad.prototype.isDead = function() {
if (this.LiveT < 0) {
Pnoise+=300;
if(HaveSound){playSound(getSound("retro/rumble"));}
for (var j=0; j<ZOldX.length; j++){
if(dist(ZOldX[j],ZOldY[j],this.X,this.Y)<
100){
Zhp[j]-=150-dist(ZOldX[j],ZOldY[j],this.X,
this.Y);
for (var w=0; w <=splat_Spawn*4; w++){
stor.push(new spt(new PVector(ZOldX[j]+random(-20,20),
ZOldY[j]+random(-20,20))));
}
}
}
stor.push(new BOOM(new PVector(this.X,this.Y)));return true;} else {return false;}
};};
var AirStk = function(position) {
this.LiveT = 300.0;
this.TX = mouseX-(300-CamX);
this.TY = mouseY-(300-CamY);
this.X = position.x;
this.Y = position.y;
this.RX=0;
this.RY=0;
this.Rot=random(0,360);
AirStk.prototype.run = function() {
this.X = this.TX;
this.Y = this.TY;
pushMatrix();
translate(this.X,this.Y);
rotate1(this.Rot);
fill(217, 44, 35,150);
ellipse(0,0,20,20);
this.LiveT-=1;
popMatrix();
if(this.LiveT<=100){
if(this.LiveT%10===0){
this.RX=this.X+random(-150,150);
this.RY=this.Y+random(-150,150);
for (var j=0; j<ZOldX.length; j++){
if(dist(ZOldX[j],ZOldY[j],this.RX,this.RY)<100){
Zhp[j]-=150;
for (var w=0; w <=splat_Spawn*4; w++){
stor.push(new spt(new PVector(ZOldX[j]+random(-20,20),
ZOldY[j]+random(-20,20))));
}
}
}
stor.push(new BOOM(new PVector(this.RX,this.RY)));
}}
};
AirStk.prototype.isDead = function() {
if (this.LiveT < 0) {
Pnoise+=300;
return true;} else {return false;}
};};
var Adrine=function(){
// this.position=position.get();
this.LiveT=255.0;
Adrine.prototype.run=function(){
this.LiveT-=0.5;
Php+=Php/100;
PS+=PS/100;
damageMULTbase=3;
fill(117, 9, 9,this.LiveT);
rect(300,300,700,700);
};
Adrine.prototype.isDead=function(){
if(this.LiveT<0){
damageMULTbase=1;
return true;
}
else {
return false;
}
};
};
//**********************************************************
// Splat marks that cover the screen
//**********************************************************
var BigSplat=function(position){
this.position=position.get();
this.LiveT=555.0;
this.A=0;
this.size=random(50,150);
BigSplat.prototype.run=function(){
if(scene===1){this.LiveT-=0.5;}
this.A+=0.2;
noStroke();
fill(0,255,0,this.LiveT);
ellipse(this.position.x,this.position.y+this.A,this.size,this.size +
this.A);
if(scene===0){this.LiveT=0;}
};
BigSplat.prototype.isDead=function(){
if(this.LiveT<0){
return true;
}
else {
return false;
}
};
};
//**********************************************************
// spitter zombies spit
//**********************************************************
var Zshot=function(position,rot){
this.acceleration=new PVector(0.00,0.00);
this.position=position.get();
this.LiveT=255.0;
this.OldX=this.position.x;
this.OldY=this.position.y;
this.NewX=0;
this.NewY=0;
// println(rot);
this.Heading=rot; //atan3(PY-this.OldY,PX-this.OldX);
};
Zshot.prototype.run=function(){
this.NewX=this.OldX+(4*cos1(this.Heading)); //
this.NewY=this.OldY+(4*sin1(this.Heading));
this.OldX=this.NewX;
this.OldY=this.NewY;
pushMatrix();
translate(this.OldX,this.OldY);
noStroke();
fill(51,237,19,200);
ellipse(0,0,12,12);
fill(38,179,16,200);
ellipse(0,0,10,10);
if(dist(this.OldX,this.OldY,PX,PY)< 20){
if(Parmor <=0){
DiedHow="hit by\n a goo ball";
Php-=20+Zombie_di_mult;
}
else {
DiedHow="hit by\n a goo ball";
Parmor-=20+Zombie_di_mult;
}
this.LiveT=-1;
for (var w=0; w <=splat_Spawn*4; w++){
stor.push(new spt(new PVector(PX+random(-20,20),
PY+random(-20,20))));
}
for (var t=0; t<2; t++){
stor2.push(new BigSplat(new PVector(random(0,width),random(
0,width))));
}
}
this.LiveT-=1;
popMatrix();
//if(frameCount%2=e==1){stor2.push(new Zshot2(new PVector(this.OldX,this.OldY),0,0,this.Heading));}
};
Zshot.prototype.isDead=function(){
if(this.LiveT<0){
return true;
}
else {
return false;
}
};