rendered paste body#include <iostream> // <
#include <allegro.h>
#include <math.h>
#include <string.h>
#include <string> // < Includin'
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <time.h>
using namespace std; // <
// stub out the sound stuff
//#include <dos.h>
void nosound()
{}
void sound (int freq)
{}
//Global Stuff Start
int Mouse(int),Bonus(),Sparkle();
int moux, mouy,mspeed=50;
int level=2,AllClear=0;
int MMX2=200,MMY2=-100; //setup co-ordinates
int Intro();
int PC=level,SB=0,BIP=0,pickup=100;
double RFI=1,CBPT,EAST,PIDT,scrollx=290,scrolly=200,mcharge=.01;
int rot1=0;
double bluecolor=1;
double CloseEx=0,CloseEy=551,Mana=20,ManaMax=20,ManaPB=0,Life=10;
int rot2=256;
int Blood();
int Start();
ofstream fout;
ifstream fin;
int MiniBosses();
int SFusion();
int Waves();
int BossKilled();
int Highscorelist();
int Boss();
int Dead();
int Help();
int Leveling();
double PlayerXY[2] = {0};
int MouseXY[2] = {0};
int Enemy();
int Color1,killedl,EAmount;
int Player(double [],int);
int BA=0,balla=0,B;
double BossEx,BossEy,Aballx,Abally;
int BallBlast(int,double [],int []);
int BossColor;
string BallType,F1,F2,Fused;
int Highscores[110];
string Names[110];
double slope;
double slope2;
bool PlayerIsFrozen=false,NewWave=false;
int killed=0,x,MX,MY;
double FreezeD;
int size;
int hit=0,Validity,stop;
int Killed=0,waittime=0,WT=60;
double slopeH,slopeEH,sSQRX,sSQRY,sSQREX,sSQREY,killedE;
int soundm,wave=1,Freezies=0;
int color,n,mode=0;
int w=0,LifeM=10,BossL=0;
double by,bx,charge;
double BossLife;
int Sc=7,Diff=1,BOG=0;
double PBS=5,ESS=1;
int R4=1,R5=13,MBSTL1=100,MBSTL2=130,MBSTL3=160,MBSTL4=190,MBSTL5=320,covw=402,covh=32;
bool charging=false,boosting=false,sloth=false,PiD=false,AIG=false,is_holding_down_mouse=false,L1Lives=false,L2Lives=false,WeaponTest=false,fusion=false,Shield=false,ShieldNotActive=true,PB,death=false,PowerBall=false,Swarm=false,Freeze=false,BossMode=false,BossExist=false,DoneEx=false,SyncT=true,BossIsFrozen=false,L1Dead=false,L2Dead=false,L3Dead=false,L4Dead=false,L5Dead=false;
int soundoff=1;
string lastpickup="";
struct Enemies
{
double Ex,bey,bex;
double Ey;
int Ec;
double slopex;
double slopey;
double hit;
double ELife;
int Size;
int FT;
int WR;
int Wait;
string Type,Status;
bool Valid;
bool Freeze;
bool isBoss,returning;
double facing;
double Sx,Sy,Ptime,Speed,NN;
double spin;
int Wizzait;
};
struct Balls
{
double Ballx,bbx,bby;
double Bally;
double Bslopex;
double Bslopey;
int Size;
int WR;
int Wait;
bool Valid;
string Type;
double ExR;
bool DoneEx;
int Hits;
bool Cleared;
};
struct Bloods
{
double bx;
double by;
double bslopex;
double bslopey;
int size;
int timer;
string Type;
bool Valid;
bool Grounded;
};
struct Specials
{
double Sx,Sy,bsy,bsx;
double Cx,Cy;
int Sc;
double slopex;
double slopey;
double Ssize,Scolor;
double hit;
double SLife;
int Size;
string Type;
bool Valid;
};
struct Sparkles
{
double Sx;
double Sy;
double Sslopex;
double Sslopey;
int size;
int timer;
string type;
bool Valid;
bool dead;
};
Enemies Enemeny[100000];
Balls Ballemeny[100000];
Bloods bloodspray[100000];
Specials Spec[100000];
Sparkles Sparky[100000];
//end global varibles...start global bitmaps
BITMAP* loadS;
BITMAP* healthS;
BITMAP* speedS;
BITMAP* slothS;
BITMAP* deathS;
BITMAP* manaS;
BITMAP* StartS;
BITMAP* MageDotS;
BITMAP* optionsS;
BITMAP* continueS;
BITMAP* beginS;
BITMAP* mouseS;
BITMAP* WBGS;
BITMAP* LoadGameS;
BITMAP* SaveGameS;
BITMAP* lvl1S;
BITMAP* lvl2S;
BITMAP* lvl2sS;
BITMAP* lvl3S;
BITMAP* lvl3sS;
BITMAP* crossS;
BITMAP* buffer;
BITMAP* blood;
BITMAP* DE1;
BITMAP* DE2;
BITMAP* healthBS;
BITMAP* RFIncS;
BITMAP* speedboostS;
BITMAP* levelupS;
BITMAP* HaqTekS;
BITMAP* coverS;
BITMAP* LM;
BITMAP* MM;
BITMAP* PaletteS;
BITMAP* ItemM;
BITMAP* Wave1;
BITMAP* Wave2;
BITMAP* AntarctiDot;
BITMAP* SwarmDot;
BITMAP* ShieldDot;
BITMAP* ShifterDot;
BITMAP* GigantoDot;
RGB sprite_palette[256];
// End global bitmaps... a few more globals then main
int ListSize;
string Name;
int main(int argc, char *argv[])
{
cout<<"What is the name of your Mage?: ";
cin>>Name;
cout<<"MageDot Intializing...";
allegro_init();
install_keyboard();
install_mouse();
set_mouse_speed(100,100);
install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
//Set GFX
// set_gfx_mode(GFX_SAFE,320,200,0,0);
set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0);
//Load Bitmaps
buffer = create_bitmap(800,600);
blood = create_bitmap(800,600);
Wave1 = load_bmp("Wave1.bmp",sprite_palette);
Wave2 = load_bmp("Wave2.bmp",sprite_palette);
AntarctiDot = load_bmp("Antarctidot.bmp",sprite_palette);
SwarmDot = load_bmp("DotSwarm.bmp",sprite_palette);
ShieldDot = load_bmp("ShieldDot.bmp",sprite_palette);
ShifterDot = load_bmp("Shifter.bmp",sprite_palette);
GigantoDot = load_bmp("Gigantodot.bmp",sprite_palette);
HaqTekS = load_bmp("haqtek.bmp",sprite_palette);
LM = load_bmp("LifeM.bmp",sprite_palette);
MM = load_bmp("ManaM.bmp",sprite_palette);
ItemM = load_bmp("ItemM.bmp",sprite_palette);
lvl1S = load_bmp("lvl1.bmp",sprite_palette);
lvl2S = load_bmp("lvl2.bmp",sprite_palette);
lvl2sS = load_bmp("lvl2s.bmp",sprite_palette);
lvl3S = load_bmp("lvl3.bmp",sprite_palette);
lvl3sS = load_bmp("lvl3s.bmp",sprite_palette);
healthS = load_bmp("health.bmp",sprite_palette);
LoadGameS = load_bmp("LoadGame.bmp",sprite_palette);
SaveGameS = load_bmp("SaveGame.bmp",sprite_palette);
speedS = load_bmp("speed.bmp",sprite_palette);
slothS = load_bmp("sloth.bmp",sprite_palette);
manaS=load_bmp("mana.bmp",sprite_palette);
deathS = load_bmp("death.bmp",sprite_palette);
healthBS = load_bmp("hboost.bmp",sprite_palette);
coverS = load_bmp("cover.bmp",sprite_palette);
speedboostS = load_bmp("SB.bmp",sprite_palette);
RFIncS = load_bmp("RFinc.bmp",sprite_palette);
levelupS = load_bmp("LevelUp.bmp",sprite_palette);
beginS = load_bmp("begin.bmp",sprite_palette);
crossS = load_bmp("cross.bmp",sprite_palette);
DE1= load_bmp("DotEnemyA.bmp",sprite_palette);
continueS = load_bmp("continue.bmp",sprite_palette);
optionsS = load_bmp("options.bmp",sprite_palette);
MageDotS = load_bmp("MageDot.bmp",sprite_palette);
StartS = load_bmp("open.bmp",sprite_palette);
clear_to_color(screen, makecol(0,0,0));
srand(time(NULL));
Life=10000;
set_palette(sprite_palette);
for (int i=0;i<100000;i++)bloodspray[i].Valid=false; //make em false
//all the next stuff pilots my intro...not much here to help...basically uses my premade functions
//to make the enemies follow a dot i move...when he reaches a certain point... start moving
//my cover bitmap....
for(int introEx=830,introES=0;!key[KEY_ENTER];introES++)
{
draw_sprite(buffer,HaqTekS,0,0);
stretch_sprite(buffer, coverS,254,551, covw, covh);
circlefill(buffer,introEx,555, 10,makecol(0,255-(PC*30),PC*30));
if(introEx>100)introEx--;
if(introEx<covw+250)covw--;
PlayerXY[0]=introEx;
PlayerXY[1]=555;
killedE=100;
int i;
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false)&&(i<3))
{
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=3;
Ballemeny[i].Hits=(int)RFI;
sSQRX=(CloseEx-PlayerXY[0])*(CloseEx-PlayerXY[0]);
sSQRY=(CloseEy-PlayerXY[1])*(CloseEy-PlayerXY[1]);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(CloseEx-PlayerXY[0])/slopeH;
Ballemeny[i].Bslopey=(CloseEy-PlayerXY[1])/slopeH;
is_holding_down_mouse=true; Ballemeny[i].Valid=true;
Ballemeny[i].Type="Rapid";
Ballemeny[i].DoneEx=false;
}
Enemy();
Blood();
Bonus();
Sparkle();
BallBlast(level,PlayerXY,MouseXY);
blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(0,0,0));
}
//End Intro and Re-Init a few variables
Life=10;
killedE=0;
BIP=0;
int i=0;
for(i=0;i<100000;i++)bloodspray[i].Valid=false;
for(i=0;i<100000;i++)Enemeny[i].Valid=false;
for(i=0;i<100000;i++)Ballemeny[i].Valid=false;
for(i=0;i<100000;i++)Spec[i].Valid=false;
for(i=0;i<100000;i++)Spec[i].Ssize=0;
i=0;
int tempytronic;//mitchell code
fin.open("MageDot.Dat");
while(true)//more of the same
{
fin>>tempytronic;//same as above and below
if(fin.eof()) //mitchell code
break; //mitchell code
Highscores[i]=tempytronic;//my variable...his idea
fin>>Names[i++];//hehehe i increment and look at it :)
ListSize++;
}
fin.close();
/*
I don't need to display high scores or "ran with" at end anymore
fout.open("magedot.cpp");
fout<<Highscores[i];
fout<<endl;
fout<<Names[i];
fout<<endl;
cout<<"I was ran with: ";
for(i=1;i<argc;i++)
{
cout<<argv[i]<<" ";
}
*/
Intro(); //lets ditch this crazy popsicle stand
nosound();
allegro_exit();
return 0;
}
END_OF_MAIN();
int Intro()
{
soundm=2000;
text_mode(-1); // transparency
int Switchee=(1+rand()%14); //pick a random number
int MMX=200,MMY=(-100); //setup co-ordinates
while(!key[KEY_ESC]) //Looping action
{
masked_blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(255,0,255));
color++; //I used to use color alot...not sure where I use it now...just basically a remnant of the old
//magedot that i still use, one of my many incrementers
draw_sprite(buffer,StartS,0,0); //Background sprite
if(MMY<300)MMY++; //Move MageDot
draw_sprite(buffer,MageDotS,MMX,MMY); //MageDot
if((Switchee)==1) //random slogans...
{
textout(buffer,font, "MageDot", 10, 10,52);
textout(buffer,font, "is", 15, 20, 52);
textout(buffer,font, "NOW", 15, 30,52);
textout(buffer,font, "your mom's", 10,40, 52);
textout(buffer,font, "le", 10, 50, 52);
textout(buffer,font, "f", 26, 50, makecol(255,0,0));
textout(buffer,font, "t uncle!", 33, 50, 52);
}
if((Switchee)==2)textout(buffer,font, " You will fire in different directions!!! ", 2, 10, 52);
else if((Switchee)==3)textout(buffer,font, "Sea Creatures devised the weaponry!!!", 2, 10, 52);
else if((Switchee)==4)textout(buffer,font, " Frenchmen!!! ", 2, 10, 52);
else if((Switchee)==5)textout(buffer,font, "You'll wake up screaming in the night!!", 2, 10, 52);
else if((Switchee)==6)textout(buffer,font, " I always feel like eating!!! ", 2, 10, 52);
else if((Switchee)==7)textout(buffer,font, " Now Serving Number 3.1!!! ", 2, 10, 52);
else if((Switchee)==8)textout(buffer,font, " Currently not owned by M$!!!! ", 2, 10, 52);
else if((Switchee)==9)textout(buffer,font, " I'm an Ad Slogan!!!! ", 2, 10, 52);
else if((Switchee)==10)textout(buffer,font, " Repent your Sins!!!! ", 2, 10, 52);
else if((Switchee)==11)textout(buffer,font, " Yatta!!!! ", 2, 10, 52);
else if((Switchee)==12)textout(buffer,font, " I'm Scared of Heights!!!!!!!!! ", 2, 10, 52);
else if((Switchee)==13)textout(buffer,font, " Praise Satin!!!!!! ", 2, 10, 52);
else if((Switchee)==14)textout(buffer,font, " Everbody Dance!!!!!! ", 2, 10, 52);
if(death)draw_sprite(buffer,continueS,140,475); //wether or not to put continue or begn
if(!death)draw_sprite(buffer,beginS,140,475);
draw_sprite(buffer,optionsS,395,0); //HELP!!!!! screen
draw_sprite(buffer,LoadGameS,0,275);
draw_sprite(buffer,SaveGameS,0,475);
if((mouse_x>395&&mouse_x<800&&mouse_y>0&&mouse_y<105)&&(mouse_b & 1))Help();
if(((mouse_x>200&&mouse_x<604&&mouse_y>475&&mouse_y<580)&&(mouse_b & 1)))Start();
int encrypt; //self explanatory
if(((mouse_x>0&&mouse_x<213&&mouse_y>275&&mouse_y<317)&&(mouse_b & 1)))
{ //Read em in and unencrypt and label us AIG, Already In Game
fin.open("MageDot.Sav");
fin>>Life;
fin>>LifeM;
fin>>Mana;
fin>>ManaMax;
fin>>mcharge;
fin>>killedE;
fin>>level;
fin>>wave;
fin>>killedl;
fin>>PowerBall;
fin>>Freeze;
fin>>Swarm;
fin>>Shield;
fin>>fusion;
fin>>RFI;
fin>>PBS;
fin>>L1Dead;
fin>>L2Dead;
fin>>L3Dead;
fin>>L4Dead;
fin>>L5Dead;
fin>>encrypt;
Life=Life+encrypt;
LifeM=LifeM+encrypt;
Mana=Mana+encrypt;
RFI=RFI+encrypt;
PBS=PBS+encrypt;
ManaMax=ManaMax+encrypt;
mcharge=mcharge+encrypt;
killedE=killedE+encrypt;
level=level+encrypt;
wave=wave+encrypt;
killedl=killedl+encrypt;
PlayerXY[0]=400;
PlayerXY[1]=300;
/*
PowerBall=PowerBall+encrypt;
Freeze=Freeze+encrypt;
Swarm=Swarm+encrypt;
Shield=Shield+encrypt;
fusion=fusion+encrypt;
*/
fin.close();
AIG=true;
death=false;
}
if(((mouse_x>0&&mouse_x<213&&mouse_y>475&&mouse_y<517)&&(mouse_b & 1)))
{//spit out encrypted values
fout.open("MageDot.Sav");
int timmytime=(rand()%time(NULL)/10000000);
fout<<Life-timmytime;
fout<<endl;
fout<<LifeM-timmytime;
fout<<endl;
fout<<Mana-timmytime;
fout<<endl;
fout<<ManaMax-timmytime;
fout<<endl;
fout<<mcharge-timmytime;
fout<<endl;
fout<<killedE-timmytime;
fout<<endl;
fout<<level-timmytime;
fout<<endl;
fout<<wave-timmytime;
fout<<endl;
fout<<killedl-timmytime;
fout<<endl;
fout<<PowerBall;//-timmytime;
fout<<endl;
fout<<Freeze;//-timmytime;
fout<<endl;
fout<<Swarm;//-timmytime;
fout<<endl;
fout<<Shield;//-timmytime;
fout<<endl;
fout<<fusion;//-timmytime;
fout<<endl;
fout<<RFI-timmytime;
fout<<endl;
fout<<PBS-timmytime;
fout<<endl;
fout<<L1Dead;
fout<<endl;
fout<<L2Dead;
fout<<endl;
fout<<L3Dead;
fout<<endl;
fout<<L4Dead;
fout<<endl;
fout<<L5Dead;
fout<<endl;
fout<<timmytime;
fout.close();
}
Mouse(level);
//vsync(); //thats odd...I swear I removed all the vsyncs....must be in there for some reason
}
return 0;
}
int Start()
{
//Re init gfx to prevent fullscreen errors set pallete and go into my little dance
set_gfx_mode(GFX_AUTODETECT,800,600,0,0);
set_palette(sprite_palette);
draw_sprite(buffer,loadS,0,0);
textout(buffer,font, "Loading", SCREEN_W/2-20, SCREEN_H/2, color);
clear_to_color(buffer, makecol(0,0,0));
if(!AIG) //if we aren't Already In Game
{
PlayerXY[0]=400;
PlayerXY[1]=300;
killedl=0;
nosound();
textout(buffer,font, "Loading.", SCREEN_W/2-20, SCREEN_H/2, color);
if(WT==0) //Reserved for hardcore mode
{
PowerBall=true;
Swarm=true;
Freeze=true;
Shield=true;
fusion=true;
}
//Is the Level x Boss dead, if so, give us a spell
if(L1Dead)PowerBall=true;
if(L2Dead)Freeze=true;
if(L3Dead)Swarm=true;
if(L4Dead)Shield=true;
if(L5Dead)fusion=true;
if(WeaponTest)level=21; //old cheat
if(death) //if we are coming back from the dead
{
killedE=1;
Life=wave+level;
level-=2;
if(level<2)level=2;
wave-=2;
int i;
for(i=0;i<=10000;i++) //fix the enemies
{
Enemeny[i].ELife=0;
Enemeny[i].hit=0;
Enemeny[i].Wait=0;
Enemeny[i].WR=0;
Enemeny[i].Size=0;
Enemeny[i].Valid=false;
Enemeny[i].Type="Normal";
Enemeny[i].isBoss=false;
BossExist=false;
BossMode=false;
}
textout(buffer,font, "Loading..", SCREEN_W/2-20, SCREEN_H/2, color);
for(i=0;i<10000;i++)
{//reset enemy pos's
int randomnumbermodulusedfrom4=(1+rand()%4);
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%SCREEN_W);
Enemeny[i].Ey=SCREEN_H+40;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%SCREEN_W);
Enemeny[i].Ey=-40;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=-40;
Enemeny[i].Ey=(rand()%SCREEN_H);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=SCREEN_W+40;
Enemeny[i].Ey=(rand()%SCREEN_H);
}
}
}
Killed=0;
death=false;
}
int i;
for(i=0;i<100000;i++)bloodspray[i].Valid=false;
for(i=0;i<100000;i++)Enemeny[i].Valid=false;
for(i=0;i<100000;i++)Ballemeny[i].Valid=false;
for(i=0;i<100000;i++)Spec[i].Valid=false;
for(i=0;i<100000;i++)Sparky[i].Valid=false;
textout(buffer,font, "Loading....", SCREEN_W/2-20, SCREEN_H/2, color);
AIG=true;
textout(screen,font, "Ready....Go!!!!", SCREEN_W/2-20, SCREEN_H/2, color);
clear_to_color(buffer, makecol(255,0,255)); //clear the buffers
clear_to_color(blood, 0); //Clear Bloods
NewWave=true;
while((!key[KEY_ESC])&&(death==false)) //hehehe while you being dead equals false do the game loop
{
//if(!SyncT)for(stop=0; stop<1000000; stop++); //outdated syncing method...I don't even think it does anything so lets comment it out
masked_blit(buffer,screen,0,0,0,0,800,600); //inviso blit
clear_to_color(buffer, makecol(0,0,0)); //Buffer == inviso
//What wave are we in...cool cool, draw that world
if(wave<4||wave>9)draw_sprite(buffer,lvl1S,0,0);
else if(wave>3&&wave<6)draw_sprite(buffer,lvl2sS,0,0);
else if(wave==6)draw_sprite(buffer,lvl2S,0,0);
else if(wave>6&&wave<9)draw_sprite(buffer,lvl3sS,0,0);
else if(wave==9)draw_sprite(buffer,lvl3S,0,0);
Blood(); //run blood function first, so that blood is drawn to buffer before other crap
masked_blit(blood,buffer,0,0,0,0,800,600); //then draw the dried blood to the buffer
Player(PlayerXY,level); //next is the player function
/*
I don't display this on the screen anymore...but good to keep around
if(fusion)
{
textout(buffer,font, "Fused: ", 174, 8, 2);
textout(buffer,font,Fused.c_str(), 224, 8, 2);
}
*/
if(!BossMode)textprintf(buffer, font, 4, 30, makecol(0,255,0), "Kills Left: %i ", (wave*15)-(int)killedE+1); //Display Kiss if not fighting boss
if(BossMode) //but if we're fighting a boss...which one
{
if(BossL==1)textout(buffer,font, "Boss: GigantoDot", 4, 39, makecol(0,255,0));
if(BossL==2)textout(buffer,font, "Boss: AntarctiDot", 4, 39, makecol(0,255,0));
if(BossL==3)textout(buffer,font, "Boss: Dot Swarm", 4, 39, makecol(0,255,0));
if(BossL==4)textout(buffer,font, "Boss: SheildDot", 4, 39, makecol(0,255,0));
if(BossL==5)textout(buffer,font, "Boss: ShifterDot", 4, 39, makecol(0,255,0));
textprintf(buffer, font, 4, 30, makecol(0,255,0), "Boss Life: %i ", (int)BossLife);
}
if(!BossExist)MiniBosses(); //then if there isn't an existing boss, cue up minibosses
Waves(); //next run the waves and see where we stand there
Bonus(); //and go through the bonuses
if(!BossExist)Enemy(); //no boss...then make us some enemies
if(BossExist)Boss(); //if a boss exist then run Boss() function
BallBlast(level,PlayerXY,MouseXY); //projectiles go ontop of enemies
Leveling(); //then i calculate leveling stuff
int i;
if(boosting) //self explanatory
{
CBPT++; //Current Boosting Player Time
if(CBPT==250)
{
boosting=false;
PBS/=2; //PBS is how often my game asks you for money, or it stands for Player Boost Speed,
// where Player Boost Speed is how fast the player can potentially move
CBPT=0;
}
}
if(PiD) //Vampire Mode
{
Mana=0; //No mana for the vampires
PIDT++; //Player Is Death Time
if(PIDT==250)
{
Mana=ManaMax*.75; //if we are done blood sucking give us back some mana
PiD=false;
PIDT=0;
}
}
if(sloth) //Enemy slowdown
{
EAST++; //Enemies Actively Sloth Time
if(EAST==250)
{
sloth=false;
ESS=1; //ESS is Enemy Sloth Speed, being the potential speed of the enemy
EAST=0;
}
}
if(key[KEY_B])
{
int bsa;
int randn10=-1+rand()%16;
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=(PlayerXY[0]+randn10-MouseXY[0]+randn10)*(PlayerXY[0]+randn10-MouseXY[0]+randn10);
sSQREY=(PlayerXY[1]+randn10-MouseXY[1]+randn10)*(PlayerXY[1]+randn10-MouseXY[1]+randn10);
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=PlayerXY[0];
bloodspray[bsa].by=PlayerXY[1];
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].bslopex=(PlayerXY[0]+randn10-MouseXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(PlayerXY[1]+randn10-MouseXY[1]+randn10)/slopeEH;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
//Begin Weapons Coding
if((mouse_b & 1)&&(is_holding_down_mouse==false)&&((MouseXY[0]!=PlayerXY[0])&&(MouseXY[1]!=PlayerXY[1])))
{
for(i=0;Ballemeny[i].Valid==true;i++);//find a false one
if((Ballemeny[i].Valid==false)&&(Mana>2))
{
Mana-=3;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Size=3;
Ballemeny[i].Hits=(int)RFI;
sSQRX=(MouseXY[0]-PlayerXY[0])*(MouseXY[0]-PlayerXY[0]);
sSQRY=(MouseXY[1]-PlayerXY[1])*(MouseXY[1]-PlayerXY[1]);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(MouseXY[0]-PlayerXY[0])/slopeH;
Ballemeny[i].Bslopey=(MouseXY[1]-PlayerXY[1])/slopeH;
is_holding_down_mouse=true; Ballemeny[i].Valid=true;
Ballemeny[i].Type="Rapid"; Ballemeny[i].DoneEx=false;
}
}
if(((key[KEY_SPACE])||(charging))&&(PowerBall)&&(Mana>(level)*4))
{
for(i=0;Ballemeny[i].Valid==true;i++);
if(key[KEY_SPACE]&&charge<level*4)
{
charge++;
Mana-=4;
charging=true;
}
if((Ballemeny[i].Valid==false)&&(!key[KEY_SPACE]))
{
charging=false;
ManaPB=Mana;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=(int)charge;
Ballemeny[i].Hits=(int)charge;
sSQRX=(MouseXY[0]-PlayerXY[0])*(MouseXY[0]-PlayerXY[0]);
sSQRY=(MouseXY[1]-PlayerXY[1])*(MouseXY[1]-PlayerXY[1]);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(MouseXY[0]-PlayerXY[0])/slopeH;
Ballemeny[i].Bslopey=(MouseXY[1]-PlayerXY[1])/slopeH;
Ballemeny[i].Type="Powerball"; Ballemeny[i].DoneEx=false;
charge=0;
}
}
if((mouse_b & 2)&&(Freeze))
{
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false)&&(Mana>3))
{
Mana-=4;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=rand()%5;
Ballemeny[i].Hits=level-1;
if(R4==13)
{
MX=MouseXY[0]+50;
MY=MouseXY[1]+50;
}
if(R4==12)
{
MX=MouseXY[0]+40;
MY=MouseXY[1]+40;
}
if(R4==11)
{
MX=MouseXY[0]+30;
MY=MouseXY[1]+30;
}
if(R4==10)
{
MX=MouseXY[0]+20;
MY=MouseXY[1]+20;
}
if(R4==9)
{
MX=MouseXY[0]+10;
MY=MouseXY[1]+10;
}
if(R4==8)
{
MX=MouseXY[0]+5;
MY=MouseXY[1]+5;
}
if(R4==7)
{
MX=MouseXY[0];
MY=MouseXY[1];
}
if(R4==6)
{
MX=MouseXY[0]-5;
MY=MouseXY[1]-5;
}
if(R4==5)
{
MX=MouseXY[0]-10;
MY=MouseXY[1]-10;
}
if(R4==4)
{
MX=MouseXY[0]-20;
MY=MouseXY[1]-20;
}
if(R4==3)
{
MX=MouseXY[0]-30;
MY=MouseXY[1]-30;
}
if(R4==2)
{
MX=MouseXY[0]-40;
MY=MouseXY[1]-40;
}
if(R4==1)
{
MX=MouseXY[0]-50;
MY=MouseXY[1]-50;
}
if(R4>12)R4=1;
R4++;
sSQRX=(MX-Ballemeny[i].Ballx)*(MX-Ballemeny[i].Ballx);
sSQRY=(MY-Ballemeny[i].Bally)*(MY-Ballemeny[i].Bally);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(MX-Ballemeny[i].Ballx)/slopeH;
Ballemeny[i].Bslopey=(MY-Ballemeny[i].Bally)/slopeH;
Ballemeny[i].Type="Frost";
Ballemeny[i].DoneEx=false;
}
for(i=0;Ballemeny[i].Valid==true;i++);
if(Ballemeny[i].Valid==false)
{
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=rand()%5;
Ballemeny[i].Hits=level-1;
if(R5==13)
{
MX=MouseXY[0]+50;
MY=MouseXY[1]+50;
}
if(R5==12)
{
MX=MouseXY[0]+40;
MY=MouseXY[1]+40;
}
if(R5==11)
{
MX=MouseXY[0]+30;
MY=MouseXY[1]+30;
}
if(R5==10)
{
MX=MouseXY[0]+20;
MY=MouseXY[1]+20;
}
if(R5==9)
{
MX=MouseXY[0]+10;
MY=MouseXY[1]+10;
}
if(R5==8)
{
MX=MouseXY[0]+5;
MY=MouseXY[1]+5;
}
if(R5==7)
{
MX=MouseXY[0];
MY=MouseXY[1];
}
if(R5==6)
{
MX=MouseXY[0]-5;
MY=MouseXY[1]-5;
}
if(R5==5)
{
MX=MouseXY[0]-10;
MY=MouseXY[1]-10;
}
if(R5==4)
{
MX=MouseXY[0]-20;
MY=MouseXY[1]-20;
}
if(R5==3)
{
MX=MouseXY[0]-30;
MY=MouseXY[1]-30;
}
if(R5==2)
{
MX=MouseXY[0]-40;
MY=MouseXY[1]-40;
}
if(R5==1)
{
MX=MouseXY[0]-50;
MY=MouseXY[1]-50;
}
if(R5<2)R5=14;
R5--;
sSQRX=(MX-Ballemeny[i].Ballx)*(MX-Ballemeny[i].Ballx);
sSQRY=(MY-Ballemeny[i].Bally)*(MY-Ballemeny[i].Bally);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(MX-Ballemeny[i].Ballx)/slopeH;
Ballemeny[i].Bslopey=(MY-Ballemeny[i].Bally)/slopeH;
Ballemeny[i].Type="Frost";
Ballemeny[i].DoneEx=false;
}
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false))
{
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=3;
Ballemeny[i].Hits=level-1;
MX=MouseXY[0];
MY=MouseXY[1];
sSQRX=(MX-Ballemeny[i].Ballx)*(MX-Ballemeny[i].Ballx);
sSQRY=(MY-Ballemeny[i].Bally)*(MY-Ballemeny[i].Bally);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(MX-Ballemeny[i].Ballx)/slopeH;
Ballemeny[i].Bslopey=(MY-Ballemeny[i].Bally)/slopeH;
Ballemeny[i].Type="Frost";
Ballemeny[i].DoneEx=false;
}
}
if((key[KEY_TAB])&&(Swarm)&&(Mana>5))
{
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false))
{
Mana-=6+rand()%6;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0]+(-15+rand()%30);
Ballemeny[i].Bally=PlayerXY[1]+(-15+rand()%30);
Ballemeny[i].Valid=true;
Ballemeny[i].Size=0+rand()%2;
Ballemeny[i].Hits=2;
Ballemeny[i].Type="Swarm";
Ballemeny[i].DoneEx=false;
}
}
if((key[KEY_X])&&(Shield)&&(ShieldNotActive))
{
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false)&&(Mana>14))
{
Mana-=35;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=level+4;
Ballemeny[i].Hits=level;
Ballemeny[i].Type="Shield";
Ballemeny[i].DoneEx=false;
ShieldNotActive=false;
}
}
if((key[KEY_V])&&(fusion))
{
if(Fused=="Blizzard")
{
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false)&&(Mana>4))
{
Mana-=5;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=1;
Ballemeny[i].Hits=level-1;
if(R4==4)
{
MX=MouseXY[0]-(20+rand()%30);
MY=MouseXY[1]+(20+rand()%30);
R4=1;
}
if(R4==3)
{
MX=MouseXY[0]-(20+rand()%30);
MY=MouseXY[1]-(20+rand()%30);
R4=4;
}
if(R4==2)
{
MX=MouseXY[0]+(20+rand()%30);
MY=MouseXY[1]-(20+rand()%30);
R4=3;
}
if(R4==1)
{
MX=MouseXY[0]+(20+rand()%30);
MY=MouseXY[1]+(20+rand()%30);
R4=2;
}
sSQRX=(MX-Ballemeny[i].Ballx)*(MX-Ballemeny[i].Ballx);
sSQRY=(MY-Ballemeny[i].Bally)*(MY-Ballemeny[i].Bally);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(MX-Ballemeny[i].Ballx)/slopeH;
Ballemeny[i].Bslopey=(MY-Ballemeny[i].Bally)/slopeH;
Ballemeny[i].Type="Blizzard";
Ballemeny[i].DoneEx=false;
}
}
if(Fused=="DeepFreeze")
{
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false)&&(Mana>59))
{
Mana-=60;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=0;
Ballemeny[i].Hits=level*level;
Ballemeny[i].Type="DeepFreeze";
Ballemeny[i].DoneEx=false;
}
}
if(Fused=="IceShield")
{
for(i=0;Ballemeny[i].Valid==true;i++);
if((Ballemeny[i].Valid==false)&&(Mana>39))
{
Mana-=40;
Ballemeny[i].Cleared=false;
Ballemeny[i].ExR=0;
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
Ballemeny[i].Valid=true;
Ballemeny[i].Size=12;
Ballemeny[i].Hits=(level*4);
Ballemeny[i].Type="IceShield";
Ballemeny[i].DoneEx=false;
ShieldNotActive=false;
}
}
}
//End Weapons Coding
if((key[KEY_ALT])&&(fusion))SFusion(); //fusion mode
/*&&(WeaponTest)
if((key[KEY_M]))
{
level=20;
killedE++;
ManaMax++;
Mana++;
LifeM++;
Life++;
Life++;
fusion=true;
Shield=true;
PowerBall=true;
Freeze=true;
Swarm=true;
}
*/
if(!(mouse_b & 1))is_holding_down_mouse=false;
Sparkle();
Mouse(level);
}
while(key[KEY_ESC]);
Intro();
return 0;
}
int Player(double PlayerXY[], int level)
{
if(((PlayerXY[0]>1)&&(PlayerXY[1]>1)&&(PlayerXY[0]<SCREEN_W+2)&&(PlayerXY[1]<SCREEN_H+2))) //are we on screen???
{
if(Mana<ManaMax)Mana+=mcharge; //recharge mana
if(Mana>ManaMax)Mana=ManaMax; //but not above max...fix's glitch
if(PlayerIsFrozen==false)
{
if(Life<LifeM)Life+=mcharge/2; //now charge life
if(Life>LifeM)Life=LifeM;
if(key[KEY_W]&&!key[KEY_S])
{
PlayerXY[1]-=(int)PBS;
if(Mana<ManaMax)Mana+=mcharge-.01;
}
if(key[KEY_S]&&!key[KEY_W])
{
PlayerXY[1]+=(int)PBS;
if(Mana<ManaMax)Mana+=mcharge-.01;
}
if(key[KEY_A]&&!key[KEY_D])
{
PlayerXY[0]-=(int)PBS;
if(Mana<ManaMax)Mana+=mcharge-.01;
}
if(key[KEY_D]&&!key[KEY_A])
{
PlayerXY[0]+=(int)PBS;
if(Mana<ManaMax)Mana+=mcharge-.01;
}
PC=level;
}
else //your frozen
{
FreezeD-=.1;
if(key[KEY_W])PlayerXY[1]-=(int)(PBS-(FreezeD*.3));
if(key[KEY_S])PlayerXY[1]+=(int)(PBS-(FreezeD*.3));
if(key[KEY_A])PlayerXY[0]-=(int)(PBS-(FreezeD*.3));
if(key[KEY_D])PlayerXY[0]+=(int)(PBS-(FreezeD*.3));
PC=(int)FreezeD+level;
if(FreezeD<1)PlayerIsFrozen=false;
}
}
//no leaving the battlefield
if(PlayerXY[0]<2)PlayerXY[0]+=8;
if(PlayerXY[0]>SCREEN_W)PlayerXY[0]-=8;
if(PlayerXY[1]<2)PlayerXY[1]+=8;
if(PlayerXY[1]>SCREEN_H)PlayerXY[1]-=8;
if(PiD)PC=(rand()%PC)*30; //we have vampire, we need a color changing
circlefill(buffer,(int)PlayerXY[0], (int)PlayerXY[1], 10,makecol(0,255-(PC*30),PC*30)); //and our character is born
draw_sprite(buffer,LM,0,200); //life meter
draw_sprite(buffer,ItemM,760,0); //Item Meter
pickup--; //how long we have had our last powerup
if(pickup>0&&pickup!=15&&pickup!=12&&pickup!=9&&pickup!=6&&pickup!=4&&pickup!=2) //this gives me a cool fading out effect, that most people don't notice...
{
//drawem
if(lastpickup=="health")draw_sprite(buffer,healthS,765,10);
if(lastpickup=="mana")draw_sprite(buffer,manaS,765,10);
if(lastpickup=="sloth")draw_sprite(buffer,slothS,765,10);
if(lastpickup=="speed")draw_sprite(buffer,speedS,765,10);
if(lastpickup=="death")draw_sprite(buffer,deathS,765,10);
if(lastpickup=="healthboost")draw_sprite(buffer,healthBS,765,10);
if(lastpickup=="RFInc")draw_sprite(buffer,RFIncS,765,10);
if(lastpickup=="speedboost")draw_sprite(buffer,speedboostS,765,10);
if(lastpickup=="levelup")draw_sprite(buffer,levelupS,765,10);
}
draw_sprite(buffer,MM,760,200);//Mana Meter
double LiCal,CiCu=Life*315/LifeM,MiCal,MiCu=Mana*315/ManaMax; //Doubles for calculating Life and Mana
for(LiCal=560;LiCal>560-CiCu;LiCal--)line(buffer,5, (int)LiCal, 34,(int)LiCal,makecol(255,0,0)); //Life Bar
if (bluecolor>254)bluecolor=0;
bluecolor++;
for(MiCal=560;MiCal>560-MiCu;MiCal--)
{
line(buffer,763, (int)MiCal, 792,(int)MiCal,makecol(0,0,250)); //Mana Bars
if (bluecolor>254)bluecolor=0;
}
if(NewWave)
{
BITMAP* whatitis;
if(wave==1)whatitis=Wave1;
else if(wave==1)whatitis=Wave1;
else if(wave==2)whatitis=Wave2;
else if(wave==3)whatitis=GigantoDot;
//else if(wave==4)whatitis=Wave4;
//else if(wave==5)whatitis=Wave5;
else if(wave==6)whatitis=AntarctiDot;
//else if(wave==7)whatitis=Wave7;
//else if(wave==8)whatitis=Wave8;
else if(wave==9)whatitis=SwarmDot;
//else if(wave==10)whatitis=Wave10;
//else if(wave==11)whatitis=Wave11;
else if(wave==12)whatitis=ShieldDot;
//else if(wave==13)whatitis=Wave13;
//else if(wave==14)whatitis=Wave14;
else if(wave==15)whatitis=ShifterDot;
if(MMY2<700)
{
MMY2+=2;
draw_sprite(buffer,whatitis,100,MMY2);
}
else NewWave=0;
}
return 0;
}
int Mouse(int level)
{
rot1++;
rot2--;
if(rot1==256)rot1=0;
if(rot2==0)rot2=256;
//---Enter Mitchell Code----
int dmoux, dmouy;
// find out how far mouse has moved since last check
get_mouse_mickeys(&dmoux,&dmouy);
// clamp down values if they've moved too far since last check
if ( dmoux > mspeed ) dmoux = mspeed;
else if ( dmoux < -mspeed ) dmoux = -mspeed;
if ( dmouy > mspeed ) dmouy = mspeed;
else if ( dmouy < -mspeed ) dmouy = -mspeed;
// update mouse location
moux += dmoux;
mouy += dmouy;
// but don't leave the edges of the screen
if ( moux >= SCREEN_W ) moux = SCREEN_W-1;
if ( mouy >= SCREEN_H ) mouy = SCREEN_H-1;
if ( moux < 0 ) moux = 0;
if ( mouy < 0 ) mouy = 0;
position_mouse(moux,mouy);
MouseXY[0]=moux;
MouseXY[1]=mouy;
/*
asm (
"movw $5, %axnt"
"movw $0, %bxnt"
"int $0x33nt"
"movw %ax, _mouse_b"
);
*/
//----Exit Mitchell Code---
//Spin my mouse
rotate_sprite(buffer,crossS,MouseXY[0]-10,MouseXY[1]-10, itofix(rot1));
rotate_sprite(buffer,crossS,MouseXY[0]-10,MouseXY[1]-10,itofix(rot2));
return 0;
}
int BallBlast(int level, double PlayerXY[], int MouseXY[])
{
int i;
for(i=0;i<100;i++)
{
//is the ball about to explode
if(((Ballemeny[i].Ballx<=1)||(Ballemeny[i].Bally<=1)||(Ballemeny[i].Ballx>=SCREEN_W)||(Ballemeny[i].Bally>=SCREEN_H))&&(Ballemeny[i].Valid==true)&&(Ballemeny[i].Type!="Shield"))
{
if(Ballemeny[i].DoneEx==false)Ballemeny[i].ExR+=1;
if(Ballemeny[i].DoneEx==true)Ballemeny[i].ExR-=1;
if((((int)Ballemeny[i].ExR)>(Ballemeny[i].Size+6))&&(Ballemeny[i].DoneEx==false))
{
Ballemeny[i].ExR=Ballemeny[i].Size+6;
Ballemeny[i].DoneEx=true;
}
if(Ballemeny[i].DoneEx==false)circlefill(buffer,(int)Ballemeny[i].Ballx,(int)Ballemeny[i].Bally,(int)Ballemeny[i].ExR,makecol(rand()%255,rand()%255,rand()%255));
//certain things make exploding stop
if(Ballemeny[i].ExR<1||(RFI<2)||Ballemeny[i].Type=="Swarm"||Ballemeny[i].Type=="Shield"||(Ballemeny[i].Type=="Blizzard")||(Ballemeny[i].Type=="DeepFreeze")||(Ballemeny[i].Type=="IceShield"))
{
Ballemeny[i].Valid=false;
for(int counting=0;counting<(Ballemeny[i].Hits+10)*2;counting++)
{
int bsa;
int randn10=((rand()%-4)+rand()%8);
int randn11=((rand()%-4)+rand()%8);
for(bsa=0;Sparky[bsa].Valid&&bsa<301;bsa++);
Sparky[bsa].Sx=Ballemeny[i].Ballx+randn10;
Sparky[bsa].Sy=Ballemeny[i].Bally+randn11;
Sparky[bsa].size=rand()%2;
Sparky[bsa].Sslopex=((-Ballemeny[i].Bslopex)+(-1+rand()%2))*Ballemeny[i].Bslopex;
Sparky[bsa].Sslopey=((-Ballemeny[i].Bslopey)+(-1+rand()%2))*Ballemeny[i].Bslopey;
Sparky[bsa].Valid=1;
Sparky[bsa].timer=0;
Sparky[bsa].type=Ballemeny[i].Type;
Sparky[bsa].dead=1;
}
if(Ballemeny[i].Type=="Shield"||Ballemeny[i].Type=="IceShield")ShieldNotActive=true;
}
}
//if the ball is valid and on the screen
if(((Ballemeny[i].Ballx>1)&&(Ballemeny[i].Bally>1)&&(Ballemeny[i].Ballx<SCREEN_W)&&(Ballemeny[i].Bally<SCREEN_H))&&(Ballemeny[i].Valid==true))
{
color=makecol(1+rand()%255,1+rand()%255,1+rand()%255);
if((Ballemeny[i].Type=="Frost")||(Ballemeny[i].Type=="Blizzard")||(Ballemeny[i].Type=="DeepFreeze")||(Ballemeny[i].Type=="IceShield"))color=makecol(240,240,240+rand()%15);
if(Ballemeny[i].Type=="Swarm")
{
if((Ballemeny[i].Ballx>MouseXY[0]-5)&&(Ballemeny[i].Ballx<MouseXY[0]+5)&&(Ballemeny[i].Bally>MouseXY[1]-5)&&(Ballemeny[i].Bally<MouseXY[1]+5))
{
int SWRand=((int)level+rand()%((int)level*4));
int Threeve=1+rand()%4;
if(Threeve==1)
{
Ballemeny[i].Ballx=MouseXY[0]+rand()%SWRand;
Ballemeny[i].Bally=MouseXY[1]+rand()%SWRand;
}
if(Threeve==2)
{
Ballemeny[i].Ballx=MouseXY[0]-rand()%SWRand;
Ballemeny[i].Bally=MouseXY[1]-rand()%SWRand;
}
if(Threeve==3)
{
Ballemeny[i].Ballx=MouseXY[0]-rand()%SWRand;
Ballemeny[i].Bally=MouseXY[1]+rand()%SWRand;
}
if(Threeve==4)
{
Ballemeny[i].Ballx=MouseXY[0]+rand()%SWRand;
Ballemeny[i].Bally=MouseXY[1]-rand()%SWRand;
}
}
sSQRX=(MouseXY[0]-Ballemeny[i].Ballx)*(MouseXY[0]-Ballemeny[i].Ballx);
sSQRY=(MouseXY[1]-Ballemeny[i].Bally)*(MouseXY[1]-Ballemeny[i].Bally);
slopeH=sqrt(sSQRX+sSQRY);
Ballemeny[i].Bslopex=(MouseXY[0]-Ballemeny[i].Ballx)/slopeH;
Ballemeny[i].Bslopey=(MouseXY[1]-Ballemeny[i].Bally)/slopeH;
}
if(Ballemeny[i].Hits>0)
{
if(Ballemeny[i].Type!="Blizzard"&&Ballemeny[i].Type!="DeepFreeze"&&Ballemeny[i].Type!="Powerball"&&Ballemeny[i].Type!="Frost")
{
Ballemeny[i].Ballx+=(Ballemeny[i].Bslopex*5);
Ballemeny[i].Bally+=(Ballemeny[i].Bslopey*5);
}
if(Ballemeny[i].Type=="Blizzard")
{
Ballemeny[i].Ballx+=Ballemeny[i].Bslopex*9;
Ballemeny[i].Bally+=Ballemeny[i].Bslopey*9;
}
if(Ballemeny[i].Type=="Frost")
{
Ballemeny[i].Ballx+=Ballemeny[i].Bslopex*4;
Ballemeny[i].Bally+=Ballemeny[i].Bslopey*4;
}
if(Ballemeny[i].Type=="Powerball")
{
Ballemeny[i].Ballx+=Ballemeny[i].Bslopex*3;
Ballemeny[i].Bally+=Ballemeny[i].Bslopey*3;
}
if(Ballemeny[i].Type=="Shield"||(Ballemeny[i].Type=="IceShield"))
{
Ballemeny[i].Ballx=PlayerXY[0];
Ballemeny[i].Bally=PlayerXY[1];
circle(buffer,(int)Ballemeny[i].Ballx,(int)Ballemeny[i].Bally,Ballemeny[i].Size,makecol(255,255,255));
}
if(Ballemeny[i].Type=="DeepFreeze")
{
Ballemeny[i].Size++;
circle(buffer,(int)Ballemeny[i].Ballx,(int)Ballemeny[i].Bally,Ballemeny[i].Size,makecol(255,255,255));
}
if(Ballemeny[i].Type!="Shield"&&Ballemeny[i].Type!="DeepFreeze"&&Ballemeny[i].Type!="IceShield")circlefill(buffer,(int)Ballemeny[i].Ballx,(int)Ballemeny[i].Bally,Ballemeny[i].Size,color);
for(int counting=0;counting<(Ballemeny[i].Hits/2)+1;counting++)
{
int bsa;
int randn10=-5*2+rand()%10*2;
int randn11=-5*2+rand()%10*2;
for(bsa=0;Sparky[bsa].Valid&&bsa<301;bsa++);
Sparky[bsa].Sx=Ballemeny[i].Ballx+randn10;
Sparky[bsa].Sy=Ballemeny[i].Bally+randn11;
Sparky[bsa].size=rand()%2;
Sparky[bsa].Sslopex=(-Ballemeny[i].Bslopex);
Sparky[bsa].Sslopey=(-Ballemeny[i].Bslopey);
Sparky[bsa].Valid=true;
Sparky[bsa].timer=0;
Sparky[bsa].type=Ballemeny[i].Type;
}
}
if(Ballemeny[i].Hits<1&&Ballemeny[i].Valid)
{
if(!Ballemeny[i].Cleared)Ballemeny[i].Cleared=true;
nosound();
if(Ballemeny[i].DoneEx==false)Ballemeny[i].ExR+=1;
if(Ballemeny[i].DoneEx==true)Ballemeny[i].ExR-=1;
if((((int)Ballemeny[i].ExR)>(Ballemeny[i].Size+6))&&(Ballemeny[i].DoneEx==false))
{
Ballemeny[i].ExR=Ballemeny[i].Size+6;
Ballemeny[i].DoneEx=true;
}
if(Ballemeny[i].DoneEx==false)circlefill(buffer,(int)Ballemeny[i].Ballx,(int)Ballemeny[i].Bally,(int)Ballemeny[i].ExR,makecol(rand()%255,rand()%255,rand()%255));
if((Ballemeny[i].ExR<1)||Ballemeny[i].Type=="Swarm"||Ballemeny[i].Type=="Shield"||(Ballemeny[i].Type=="Blizzard")||(Ballemeny[i].Type=="DeepFreeze")||(Ballemeny[i].Type=="IceShield")||(RFI<2))
{
for(int counting=0;counting<(Ballemeny[i].Hits+10)*2;counting++)
{
int bsa;
int randn10=((rand()%-3)+rand()%6);
int randn11=((rand()%-3)+rand()%6);
for(bsa=0;Sparky[bsa].Valid&&bsa<301;bsa++);
Sparky[bsa].Sx=Ballemeny[i].Ballx+randn10;
Sparky[bsa].Sy=Ballemeny[i].Bally+randn11;
Sparky[bsa].size=rand()%2;
Sparky[bsa].Sslopex=((-Ballemeny[i].Bslopex)+(-1+rand()%2))*Ballemeny[i].Bslopex;
Sparky[bsa].Sslopey=((-Ballemeny[i].Bslopey)+(-1+rand()%2))*Ballemeny[i].Bslopey;
Sparky[bsa].Valid=1;
Sparky[bsa].timer=0;
Sparky[bsa].type=Ballemeny[i].Type;
Sparky[bsa].dead=1;
}
Ballemeny[i].Valid=false;
if(Ballemeny[i].Type=="Powerball")PB=false;
if(Ballemeny[i].Type=="Shield")ShieldNotActive=true;
if(Ballemeny[i].Type=="IceShield")ShieldNotActive=true;
}
}
}
int j=0;
for(j=0;j<100;j++)
{
if(((((Spec[j].Sx)+20>Ballemeny[i].Ballx-Ballemeny[i].Size)&&((Spec[j].Sx)-20<Ballemeny[i].Ballx+Ballemeny[i].Size)&&((Spec[j]).Sy+20>Ballemeny[i].Bally-Ballemeny[i].Size)&&((Spec[j].Sy)-20<Ballemeny[i].Bally+Ballemeny[i].Size))&&(Spec[j].Valid==true)&&(Ballemeny[i].Valid==true)))
{
if((Ballemeny[i].Type!="Frost")&&(Ballemeny[i].Type!="DeepFreeze"))
{
if(Ballemeny[i].Type!="Shield"&&Ballemeny[i].Type!="IceShield")Spec[j].hit++;
if(Ballemeny[i].Type=="Powerball")
{
Spec[j].hit+=10;
Ballemeny[i].Hits--;
}
for(int counting=0;counting<((Ballemeny[i].Hits+10)*2);counting++)
{
int bsa;
int randn10=((rand()%-3)+rand()%6);
int randn11=((rand()%-3)+rand()%6);
for(bsa=0;Sparky[bsa].Valid&&bsa<301;bsa++);
Sparky[bsa].Sx=Ballemeny[i].Ballx+randn10;
Sparky[bsa].Sy=Ballemeny[i].Bally+randn11;
Sparky[bsa].size=rand()%2;
Sparky[bsa].Sslopex=((-Ballemeny[i].Bslopex)+(-1+rand()%2))*Ballemeny[i].Bslopex;
Sparky[bsa].Sslopey=((-Ballemeny[i].Bslopey)+(-1+rand()%2))*Ballemeny[i].Bslopey;
Sparky[bsa].Valid=1;
Sparky[bsa].timer=0;
Sparky[bsa].type=Ballemeny[i].Type;
Sparky[bsa].dead=1;
}
if(Ballemeny[i].Type!="Powerball")Ballemeny[i].Valid=false;
}
}
if((Spec[j].hit>=Spec[j].SLife)&&(Spec[j].Valid))
{
nosound();
if(Spec[j].Ssize<20)
{
Spec[j].Ssize+=.004;
Spec[j].Scolor+=.018;
}
circlefill(buffer,(int)Spec[j].Sx+10,(int)Spec[j].Sy+10, (int)Spec[j].Ssize, (int)Spec[j].Scolor);
circle(buffer,(int)Spec[j].Sx+10,(int)Spec[j].Sy+10, (int)Spec[j].Scolor, (int)Spec[j].Ssize);
int spcE;
for(spcE=0;spcE<(wave*4);spcE++)
{
if((((Enemeny[spcE].Ex)-Enemeny[spcE].Size>=(int)Spec[j].Sx-Spec[j].Scolor)&&((Enemeny[spcE].Ex)+Enemeny[spcE].Size<=(int)Spec[spcE].Sx+Spec[j].Scolor)&&((Enemeny[spcE]).Ey-Enemeny[spcE].Size>=(int)Spec[j].Sy-Spec[j].Scolor)&&((Enemeny[spcE].Ey)+Enemeny[spcE].Size<=(int)Spec[j].Sx+Spec[j].Scolor))&&(Enemeny[spcE].Valid==true)&&(Spec[j].Valid==true))
{
Enemeny[spcE].hit++;
int bsa;
int randn10=-8+rand()%16; //1 instead of -8
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[i].Ex+randn10-(Spec[j].Sx+randn10))*(Enemeny[i].Ex+randn10-(Spec[j].Sx+randn10)));
sSQREY=((Enemeny[i].Ey+randn10-(Spec[j].Sy+randn10))*(Enemeny[i].Ey+randn10-(Spec[j].Sy+randn10)));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Enemeny[i].Ex;
bloodspray[bsa].by=Enemeny[i].Ey;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].bslopex=(Enemeny[j].Ex+randn10-Spec[j].Sx+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[j].Ey+randn10-Spec[j].Sy+randn10)/slopeEH;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
}
if(Spec[j].Ssize>20)
{
Spec[j].Valid=false;
Spec[j].Ssize=0;
Spec[j].Scolor=0;
}
}
}
for(j=0;j<(wave*4);j++)
{
if (Enemeny[j].hit!=0)
{
if((Enemeny[j].ELife/Enemeny[j].hit)>(Enemeny[j].ELife*.10))Enemeny[j].Ec=41;
if((Enemeny[j].ELife/Enemeny[j].hit)>(Enemeny[j].ELife*.20))Enemeny[j].Ec=42;
if((Enemeny[j].ELife/Enemeny[j].hit)>(Enemeny[j].ELife*.30))Enemeny[j].Ec=43;
if((Enemeny[j].ELife/Enemeny[j].hit)>(Enemeny[j].ELife*.40))Enemeny[j].Ec=44;
if((Enemeny[j].ELife/Enemeny[j].hit)>(Enemeny[j].ELife*.50))Enemeny[j].Ec=45;
if((Enemeny[j].ELife/Enemeny[j].hit)>(Enemeny[j].ELife*.65))Enemeny[j].Ec=46;
}
if(Enemeny[j].Freeze==true)Enemeny[j].Ec=makecol(240,240,255);
if((((Enemeny[j].Ex)+Enemeny[j].Size>Ballemeny[i].Ballx-Ballemeny[i].Size)&&((Enemeny[j].Ex)-Enemeny[j].Size<Ballemeny[i].Ballx+Ballemeny[i].Size)&&((Enemeny[j]).Ey+Enemeny[j].Size>Ballemeny[i].Bally-Ballemeny[i].Size)&&((Enemeny[j].Ey)-Enemeny[j].Size<Ballemeny[i].Bally+Ballemeny[i].Size))&&(Enemeny[j].Valid==true)&&(Ballemeny[i].Valid==true))
{
if((Ballemeny[i].Type!="Frost")&&(Ballemeny[i].Type!="DeepFreeze"))
{
int DiffEL=((int)(Ballemeny[i].Hits/4));
Enemeny[j].Ptime=DiffEL;
Enemeny[j].Speed=DiffEL;
while((1+rand()%18)!=(1+rand()%15))
{
int bsa;
int randn10=-8+rand()%16; //-1 instead of -8
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[i].Ex+randn10-(PlayerXY[0]+randn10))*(Enemeny[i].Ex+randn10-(PlayerXY[0]+randn10)));
sSQREY=((Enemeny[i].Ey+randn10-(PlayerXY[1]+randn10))*(Enemeny[i].Ey+randn10-(PlayerXY[1]+randn10)));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Ballemeny[i].Ballx;
bloodspray[bsa].by=Ballemeny[i].Bally;
bloodspray[bsa].Type=Enemeny[i].Type;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].bslopex=(Enemeny[j].Ex+randn10-PlayerXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[j].Ey+randn10-PlayerXY[1]+randn10)/slopeEH;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
if(Ballemeny[i].Type!="Shield"&&Ballemeny[i].Type!="IceShield")Enemeny[j].hit++;
if(Ballemeny[i].Type=="Shield"||Ballemeny[i].Type=="IceShield")
{
if(Ballemeny[i].Type=="Shield")
{
Enemeny[i].Ex-=(Enemeny[i].slopex*4)*ESS;
Enemeny[i].Ey-=(Enemeny[i].slopey*4)*ESS;
}
Enemeny[i].Ex-=(Enemeny[i].slopex*Ballemeny[i].Hits);
Enemeny[i].Ey-=(Enemeny[i].slopey*Ballemeny[i].Hits);
if(Ballemeny[i].Type=="IceShield")
{
Enemeny[j].Ex-=Enemeny[i].slopex;
Enemeny[j].Ey-=Enemeny[i].slopey;
}
Enemeny[i].Ex-=(Enemeny[i].slopex*4)*ESS;
Enemeny[i].Ey-=(Enemeny[i].slopey*4)*ESS;
if(Ballemeny[i].Type=="Shield")Ballemeny[i].Size--;
}
if((Enemeny[j].Type=="L1MB")&&(Ballemeny[i].Hits>0))
{
circlefill(buffer,(int)Enemeny[j].Ex,(int)Enemeny[j].Ey, Enemeny[j].Size, 0);
Enemeny[j].Size--;
if(Enemeny[j].Size<1)Enemeny[j].hit=Enemeny[j].ELife;
Enemeny[j].WR+=2;
}
if((Enemeny[j].Type=="L2MB")&&(Ballemeny[i].Hits>0))
{
Freezies++;
circlefill(buffer,(int)Enemeny[j].Ex,(int)Enemeny[j].Ey, Enemeny[j].Size, 0);
if(Enemeny[j].Size<1)Enemeny[j].hit=Enemeny[j].ELife;
}
if((Enemeny[j].isBoss)&&(Ballemeny[i].Hits>0)&&(Ballemeny[i].Type!="Shield"))
{
if(Mana<ManaMax)Mana+=mcharge;
if((BossLife<300)&&(BossL==1))killedE++;
killedE+=.5;
circlefill(buffer,(int)Enemeny[j].Ex,(int)Enemeny[j].Ey, Enemeny[j].Size, 0);
if(BossL==1)
{
Enemeny[j].Size--;
Enemeny[j].WR+=2;
Enemeny[j].hit+=level+5;
}
if(BossL==4)
{
Aballx=Ballemeny[i].Ballx;
Abally=Ballemeny[i].Bally;
}
if(BossL==5)
{
if(BossLife>3999)
{
Enemeny[j].Size--;
Enemeny[j].WR+=5;
}
if(BossLife<4000&&BossLife>2999)
{
Enemeny[j].Size=15;
Enemeny[j].WR=50;
}
if(BossLife<3000&&BossLife>1999)
{
Enemeny[j].WR=50;
Enemeny[j].Size=18;
}
if(BossLife<2000&&BossLife>999)
{
Enemeny[j].WR=60;
Enemeny[j].Size=12;
}
if(BossLife<1000)
{
Enemeny[j].WR=30;
Enemeny[j].Size+=2;
Enemeny[j].Ec++;
}
}
BossLife=Enemeny[j].ELife-Enemeny[j].hit;
}
}
if((Ballemeny[i].Type=="Frost")||(Ballemeny[i].Type=="Blizzard")||(Ballemeny[i].Type=="DeepFreeze")||(Ballemeny[i].Type=="IceShield"))Enemeny[j].Freeze=true;
if(Enemeny[j].hit>=Enemeny[j].ELife)
{
if(Mana<ManaMax)Mana+=Enemeny[j].hit*2;
while((1+rand()%18)!=(1+rand()%15))
{
int bsa;
int randn10=-16+rand()%32; // -1 and 16
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[j].Ex+randn10-(PlayerXY[0]+randn10))*(Enemeny[j].Ex+randn10-(PlayerXY[0]+randn10)));
sSQREY=((Enemeny[j].Ey+randn10-(PlayerXY[1]+randn10))*(Enemeny[j].Ey+randn10-(PlayerXY[1]+randn10)));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Enemeny[j].Ex;
bloodspray[bsa].by=Enemeny[j].Ey;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].bslopex=(Enemeny[j].Ex+randn10-PlayerXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[j].Ey+randn10-PlayerXY[1]+randn10)/slopeEH;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
if(Enemeny[j].isBoss==false)
{
if(!BossMode)
{
Killed++;
if(L1Dead)MBSTL1--;
if(L2Dead)MBSTL2--;
if(L3Dead)MBSTL3--;
if(L4Dead)MBSTL4--;
if(L5Dead)MBSTL5--;
killed++;
killedl++;
AllClear--;
killedE++;
if(1+rand()%20>17) //17
{
int spc;
for(spc=0;Spec[spc].Valid;spc++);
Spec[spc].hit=0;
Spec[spc].Sx=Enemeny[j].Ex;
Spec[spc].Sy=Enemeny[j].Ey;
int randomnumbermodulusedfrom4=(1+rand()%18);
Spec[spc].Type="health";
if(randomnumbermodulusedfrom4>0)Spec[spc].Type="health";
if(randomnumbermodulusedfrom4>6)Spec[spc].Type="mana";
if(randomnumbermodulusedfrom4>10)Spec[spc].Type="speed";
if(randomnumbermodulusedfrom4>14)Spec[spc].Type="sloth";
if(randomnumbermodulusedfrom4>17)Spec[spc].Type="death";
Spec[spc].SLife=10;//(rand()%wave)*5;
Spec[spc].Valid=true;
}
}
nosound();
circlefill(buffer,(int)Enemeny[j].Ex,(int)Enemeny[j].Ey, Enemeny[j].Size, 0);
Enemeny[j].Valid=false;
Enemeny[j].Freeze=false;
}
if(Enemeny[j].isBoss==true)
{
Killed+=10;
if(L1Dead)MBSTL1--;
if(L2Dead)MBSTL2--;
if(L3Dead)MBSTL3--;
if(L4Dead)MBSTL4--;
if(L5Dead)MBSTL5--;
nosound();
circlefill(buffer,(int)Enemeny[j].Ex,(int)Enemeny[j].Ey, killed+2, 0);
for(size=0,color=0; size<21; size++, color++)
{
clear_to_color(buffer, makecol(255,255,255));
blit(buffer,screen,0,0,0,0,800,600);
//vsync();
for(int sizzem=0; sizzem<10; sizzem++)clear_to_color(screen, makecol(1,1,1));
}
Enemeny[j].Valid=false;
killedE=1;
killed+=10;
killedl++;
Enemeny[j].Freeze=false;
Enemeny[j].isBoss=false;
BossExist=false;
BossMode=false;
BossKilled();
}
if((Enemeny[j].Type=="L1MB")||(Enemeny[j].Type=="L2MB")||(Enemeny[j].Type=="L3MB")||(Enemeny[j].Type=="L4MB"))
{
int spc;
for(spc=0;Spec[spc].Valid;spc++);
Spec[spc].hit=0;
Spec[spc].Sx=Enemeny[j].Ex;
Spec[spc].Sx=Enemeny[j].Ey;
int randomnumbermodulusedfrom4=(1+rand()%10);
Spec[spc].Type="healthboost";
if(randomnumbermodulusedfrom4<7)Spec[spc].Type="healthboost";
if(randomnumbermodulusedfrom4>6&&RFI<6)Spec[spc].Type="RFInc";
if(randomnumbermodulusedfrom4==9)Spec[spc].Type="speedboost";
if(randomnumbermodulusedfrom4==5)Spec[spc].Type="levelup";
Spec[spc].SLife=40;
Spec[spc].Valid=true;
Killed+=4;
if(L1Dead)MBSTL1--;
if(L2Dead)MBSTL2--;
if(L3Dead)MBSTL3--;
if(L4Dead)MBSTL4--;
if(L5Dead)MBSTL5--;
if(Enemeny[j].Type=="L2MB")L2Lives=false;
if(Enemeny[j].Type=="L1MB")L1Lives=false;
nosound();
circlefill(buffer,(int)Enemeny[j].Ex,(int)Enemeny[j].Ey,Enemeny[j].Size+1, 0);
Enemeny[j].Valid=false;
killed+=4;
killedl++;
Enemeny[j].Freeze=false;
}
}
Ballemeny[i].Hits--;
if(Ballemeny[i].Type=="Powerball")Ballemeny[i].Size--;
}
}
}
return 0;
}
int Enemy()
{
int i=0;
EAmount=wave;
if((wave*4)>50)EAmount/=2;
for(i=0;i<(EAmount*4);i++)
{
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
Enemeny[i].Ec=47;
int randomnumbermodulusedfrom4=(1+rand()%4);
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%SCREEN_W);
Enemeny[i].Ey=SCREEN_H+rand()%100;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%SCREEN_W);
Enemeny[i].Ey=-rand()%100;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=-rand()%100;
Enemeny[i].Ey=(rand()%SCREEN_H);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=SCREEN_W+rand()%100;
Enemeny[i].Ey=(rand()%SCREEN_H);
}
Enemeny[i].Valid=true;
Enemeny[i].Wait=100;
Enemeny[i].Size=10;
Enemeny[i].Type="Normal";
Enemeny[i].WR=(5+rand()%wave);
Enemeny[i].ELife=Enemeny[i].WR-5;
Enemeny[i].Freeze=false;
if(AllClear==level)AllClear=level;
}
if((Enemeny[i].Valid==true)&&((Enemeny[i].Type=="Normal")))
{
if(Enemeny[i].Status!="Victim")
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
}
if(!Enemeny[i].returning&&Enemeny[i].Status=="Victim")
{
sSQREX=(((PlayerXY[0]-30)-Enemeny[i].Ex)*((PlayerXY[0]-30)-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1]-30)-Enemeny[i].Ey)*((PlayerXY[1]-30)-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=((PlayerXY[0]-30)-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=((PlayerXY[1]-30)-Enemeny[i].Ey)/slopeEH;
}
if(Enemeny[i].returning&&Enemeny[i].Status=="Victim")
{
sSQREX=(((PlayerXY[0]+30)-Enemeny[i].Ex)*((PlayerXY[0]+30)-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1]+30)-Enemeny[i].Ey)*((PlayerXY[1]+30)-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=((PlayerXY[0]+30)-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=((PlayerXY[1]+30)-Enemeny[i].Ey)/slopeEH;
}
if(Enemeny[i].ELife/Enemeny[i].hit<.26)
{
/*
while((1+rand()%5)!=(1+rand()%6))
{
*/
while((1+rand()%2)!=(1+rand()%2))
{
int bsa;
int randn10=-1+rand()%26;
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[i].Ex+randn10-(PlayerXY[0]+randn10))*(Enemeny[i].Ex-(PlayerXY[0])));
sSQREY=((Enemeny[i].Ey+randn10-(PlayerXY[1]+randn10))*(Enemeny[i].Ey-(PlayerXY[1])));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Enemeny[i].Ex+(-10+rand()%20);
bloodspray[bsa].by=Enemeny[i].Ey+(-10+rand()%20);
bloodspray[bsa].bslopex=(Enemeny[i].Ex+randn10-PlayerXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[i].Ey+randn10-PlayerXY[1]+randn10)/slopeEH;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
//}
}
if(Enemeny[i].Ptime>0)
{
if(Enemeny[i].Status=="Victim")
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=((PlayerXY[0]+(-20+rand()%40))-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=((PlayerXY[1]+(-20+rand()%40))-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=(Enemeny[i].slopex)*12;
Enemeny[i].Ey+=(Enemeny[i].slopey)*12;
}
else
{
if(Enemeny[i].Ex<790&&Enemeny[i].Ex>10&&Enemeny[i].Ey<590&&Enemeny[i].Ey>10&&!Enemeny[i].returning)
{
Enemeny[i].Ex-=(Enemeny[i].slopex)*3*(Enemeny[i].Speed);
Enemeny[i].Ey-=(Enemeny[i].slopey)*3*(Enemeny[i].Speed);
while((1+rand()%3)!=(1+rand()%3))
{
int bsa;
int randn10=-1+rand()%26;
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[i].Ex+randn10-(PlayerXY[0]+randn10))*(Enemeny[i].Ex-(PlayerXY[0])));
sSQREY=((Enemeny[i].Ey+randn10-(PlayerXY[1]+randn10))*(Enemeny[i].Ey-(PlayerXY[1])));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Enemeny[i].Ex+(-10+rand()%20);
bloodspray[bsa].by=Enemeny[i].Ey+(-10+rand()%20);
bloodspray[bsa].bslopex=(Enemeny[i].Ex+randn10-PlayerXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[i].Ey+randn10-PlayerXY[1]+randn10)/slopeEH;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
}
else
{
Enemeny[i].returning=true;
Enemeny[i].Ex+=(Enemeny[i].slopex)*3*(Enemeny[i].Speed);
Enemeny[i].Ey+=(Enemeny[i].slopey)*3*(Enemeny[i].Speed);
while((1+rand()%18)!=(1+rand()%15))
{
int bsa;
int randn10=-1+rand()%16;
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[i].Ex-randn10-(PlayerXY[0]+randn10))*(Enemeny[i].Ex+(PlayerXY[0])));
sSQREY=((Enemeny[i].Ey-randn10-(PlayerXY[1]+randn10))*(Enemeny[i].Ey+(PlayerXY[1])));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Enemeny[i].Ex;
bloodspray[bsa].by=Enemeny[i].Ey;
bloodspray[bsa].bslopex=(Enemeny[i].Ex-randn10+PlayerXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[i].Ey-randn10+PlayerXY[1]+randn10)/slopeEH;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
}
}
Enemeny[i].Ptime--;
Enemeny[i].Speed--;
}
else Enemeny[i].returning=false;
if(slopeEH-10-Enemeny[i].Size<1||Enemeny[i].Status=="Victim")
{
if(!PiD)
{
Enemeny[i].Status="Normal";
if((level>(Enemeny[i].ELife-Enemeny[i].hit)+2)&&Enemeny[i].Status!="Victim")
{
Life-=(Enemeny[i].ELife+1)/2;
if(Life<1)Dead();
int DiffEL=level-((int)Enemeny[i].ELife-(int)Enemeny[i].hit);
//Enemeny[i].Sx-=(Enemeny[i].slopex*4)*ESS*DiffEL;
//Enemeny[i].Sy-=(Enemeny[i].slopey*4)*ESS*DiffEL;
Enemeny[i].Ptime=DiffEL;
Enemeny[i].Speed=DiffEL;
if (Enemeny[i].ELife+3>Enemeny[i].hit)Enemeny[i].hit++;
}
}
if(PiD)
{
if (Enemeny[i].ELife>Enemeny[i].hit)Enemeny[i].hit++;
if(Enemeny[i].Speed==0)
{
Enemeny[i].returning=(!Enemeny[i].returning);
Enemeny[i].Speed=5;
}
Enemeny[i].Ptime=1;
//Enemeny[i].Ex+=(Enemeny[i].slopex*4)*ESS*20;
//Enemeny[i].Ey+=(Enemeny[i].slopey*4)*ESS*20;
if(Enemeny[i].Status!="Victim")Enemeny[i].Speed=5;
Enemeny[i].Status="Victim";
while((1+rand()%18)!=(1+rand()%15))
{
int bsa;
int randn10=-1+rand()%16;
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[i].Ex-randn10-(PlayerXY[0]+randn10))*(Enemeny[i].Ex+(PlayerXY[0])));
sSQREY=((Enemeny[i].Ey-randn10-(PlayerXY[1]+randn10))*(Enemeny[i].Ey+(PlayerXY[1])));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Enemeny[i].Ex;
bloodspray[bsa].by=Enemeny[i].Ey;
bloodspray[bsa].bslopex=(Enemeny[i].Ex-randn10-PlayerXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[i].Ey-randn10-PlayerXY[1]+randn10)/slopeEH;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
}
}
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=100;
if(Enemeny[i].Freeze==true)
{
Enemeny[i].Wait=100*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT==level*5)
{
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=46;
}
}
if(slopeEH-10-Enemeny[i].Size>2)
{
if(!PiD&&Enemeny[i].Ptime==0)
{
Enemeny[i].Ex+=(Enemeny[i].slopex*6)*ESS;
Enemeny[i].Ey+=(Enemeny[i].slopey*6)*ESS;
}
if(PiD)
{
Enemeny[i].Ex-=(Enemeny[i].slopex*6)*ESS;
Enemeny[i].Ey-=(Enemeny[i].slopey*6)*ESS;
}
}
if(slopeEH-10-Enemeny[i].Size<=2)
{
if(!PiD)
{
if(level>Enemeny[i].ELife-Enemeny[i].hit)
{
Life-=Enemeny[i].ELife+1;
if(Life<1)Dead();
}
}
}
if(slopeEH-300-Enemeny[i].Size<1)
{
CloseEx=Enemeny[i].Ex;
CloseEy=Enemeny[i].Ey;
}
}
//int rrrrand=(1+rand()%2);
//if(rrrrand==1)
if(!sloth&&!Enemeny[i].Freeze)if(15-slopeEH<1)Enemeny[i].spin+=20;
if(sloth)if(15-slopeEH<1)Enemeny[i].spin+=5;
if(Enemeny[i].Freeze)Enemeny[i].spin+=5;
if((int)Enemeny[i].spin>256)Enemeny[i].spin=0;
//sSQREX=(((PlayerXY[0]+30)-Enemeny[i].Ex)*((PlayerXY[0]+30)-Enemeny[i].Ex));
//sSQREY=(((PlayerXY[1]+30)-Enemeny[i].Ey)*((PlayerXY[1]+30)-Enemeny[i].Ey));
//slopeEH itofix((int)slopeEH)
//Enemeny[i].facing=((sSQREX+sSQREY)/256);
rotate_sprite(buffer,DE1,(int)Enemeny[i].Ex-20,(int)Enemeny[i].Ey-20,itofix((int)(sSQREX+sSQREY)));
//if(rrrrand==2)rotate_sprite(buffer,DE2,(int)Enemeny[i].Ex-5,(int)Enemeny[i].Ey-5,itofix(((int)Enemeny[i].facing)));
}
Enemeny[i].Wait-=Enemeny[i].WR*2;
}
return 0;
}
int Help()
{
clear_to_color(buffer, makecol(0,0,0));
while(!key[KEY_ESC])
{
//if(SyncT)vsync();
//if(!SyncT)for(stop=0; stop<100000; stop++);
blit(buffer,screen,0,0,0,0,320,200);
clear_to_color(buffer, makecol(100,100,100));
soundm++;
textout(buffer,font, "Help", 120, 90, soundm);
/*
circlefill(buffer, 20,130,10,Sc);
if(soundoff==1)textout(buffer,font,"Mute ",5,130, Sc-1);
if(soundoff==2)textout(buffer,font,"UnMute",2,130, Sc-1);
if(((mouse_x>10)&&(mouse_x<30)&&(mouse_y>120)&&(mouse_y<140))&&(mouse_b & 1))
{
if((soundoff==2)&&(unchanged))
{
soundoff=1;
nosound();
circlefill(buffer, 20,130,20,0);
Sc=7;
unchanged=false;
}
if((soundoff==1)&&(unchanged))
{
soundoff=2;
nosound();
circlefill(buffer, 20,130,20,0);
Sc=2;
unchanged=false;
}
unchanged=true;
for(stop=0; stop<20000000; stop++);
}
circlefill(buffer, 20,100,10,2);
textout(buffer,font,"Sync",5,100, 1);
if(((mouse_x>10)&&(mouse_x<30)&&(mouse_y>90)&&(mouse_y<110))&&(mouse_b & 1))
{
SyncT=(!SyncT);
for(stop=0; stop<20000000; stop++);
}
circlefill(buffer, 100, 180, 10, Diff);
if((mouse_x>90&&mouse_x<110&&mouse_y>170&&mouse_y<190)&&(mouse_b & 1))
{
if((Diff==1)&&(unchanged))
{
Diff=2;
unchanged=false;
}
if((Diff==2)&&(unchanged))
{
Diff=3;
unchanged=false;
}
if((Diff==3)&&(unchanged))
{
Diff=1;
unchanged=false;
}
unchanged=true;
for(stop=0; stop<20000000; stop++);
}
if(Diff==1)
{
WT=50;
textout(buffer,font," Normal ",70,180, makecol(0,0,255));
}
if(Diff==2)
{
WT=80;
textout(buffer,font," Panzy ",70,180, makecol(255,0,0));
}
if(Diff==3)
{
WT=0;
textout(buffer,font,"Hardcore",70,180, makecol(0,255,0));
}
*/
Mouse(level);
}
for(stop=0; stop<20000000; stop++);
return 0;
}
int Dead()
{
while(!key[KEY_ESC])
{
soundm++;
//if(SyncT)vsync();
//if(!SyncT)for(stop=0; stop<100000; stop++);
blit(buffer,screen,0,0,0,0,320,200);
color++;
clear_to_color(buffer, makecol(0,0,0));
textout(buffer,font, "You Are Dead", 120, 90, color);
textprintf(buffer, font, 110, 100, color, "Enemies Killed: %i ", Killed);
textprintf(buffer, font, 110, 110, color, "Level Reached: %i ", level-1);
textout(buffer,font, " Hit Escape", 110, 120, color);
Mouse(level);
}
if(!WeaponTest)Highscorelist();
death=true;
return 0;
}
int Highscorelist()
{
clear_to_color(buffer, makecol(0,0,0));
int i,Ii,Scrolly=710,You;
bool HnC=true;
fout.open("magedot.dat");
while(!key[KEY_ENTER])
{
if(HnC)
{
for(i=0;i<101;i++)
{
if(Killed>=Highscores[i])
{
for(Ii=101;Ii>i;Ii--)
{
Highscores[Ii]=Highscores[Ii-1];
Names[Ii]=Names[Ii-1];
}
Highscores[i]=Killed;
You=Killed;
Killed=1;
Names[i]=Name;
}
fout<<Highscores[i];
fout<<endl;
fout<<Names[i];
fout<<endl;
}
HnC=false;
i=0;
}
//if(SyncT)vsync();
//if(!SyncT)for(stop=0; stop<1000000; stop++);
blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(0,0,0));
textprintf(buffer, font, 10, Scrolly, makecol(0,0,255), "%i ", Highscores[i]);
textprintf(buffer, font, 3, Scrolly+10, makecol(0,255,0),"%s ", Names[i].c_str());
textprintf(buffer, font, 10, Scrolly+30, makecol(0,0,255), "%i ", Highscores[i+1]);
textprintf(buffer, font, 3, Scrolly+40, makecol(0,255,0), "%s ", Names[i+1].c_str());
textprintf(buffer, font, 10, Scrolly+60, makecol(0,0,255), "%i ", Highscores[i+2]);
textprintf(buffer, font, 3, Scrolly+70, makecol(0,255,0), "%s ", Names[i+2].c_str());
textprintf(buffer, font, 10, Scrolly+90, makecol(0,0,255), "%i ", Highscores[i+3]);
textprintf(buffer, font, 3, Scrolly+100, makecol(0,255,0), "%s ", Names[i+3].c_str());
textprintf(buffer, font, 10, Scrolly+120, makecol(0,0,255), "%i ", Highscores[i+4]);
textprintf(buffer, font, 3, Scrolly+130, makecol(0,255,0), "%s ", Names[i+4].c_str());
textprintf(buffer, font, 10, Scrolly+150, makecol(0,0,255), "%i ", Highscores[i+5]);
textprintf(buffer, font, 3, Scrolly+160, makecol(0,255,0), "%s ", Names[i+5].c_str());
textprintf(buffer, font, 10, Scrolly+180, makecol(0,0,255), "%i ", Highscores[i+5]);
textprintf(buffer, font, 3, Scrolly+190, makecol(0,255,0), "%s ", Names[i+5].c_str());
textprintf(buffer, font, 10, Scrolly+210, makecol(0,0,255), "%i ", Highscores[i+6]);
textprintf(buffer, font, 3, Scrolly+220, makecol(0,255,0), "%s ", Names[i+6].c_str());
textprintf(buffer, font, 10, Scrolly+240, makecol(0,0,255), "%i ", Highscores[i+7]);
textprintf(buffer, font, 3, Scrolly+250, makecol(0,255,0), "%s ", Names[i+7].c_str());
textprintf(buffer, font, 10, Scrolly+270, makecol(0,0,255), "%i ", Highscores[i+8]);
textprintf(buffer, font, 3, Scrolly+280, makecol(0,255,0), "%s ", Names[i+8].c_str());
textprintf(buffer, font, 10, Scrolly+300, makecol(0,0,255), "%i ", Highscores[i+9]);
textprintf(buffer, font, 3, Scrolly+310, makecol(0,255,0), "%s ", Names[i+9].c_str());
for(Ii=i;Ii<11;Ii++)if(Highscores[Ii]==You)textout(buffer,font, "You Rank in HERE", 200, 40, makecol(1+rand()%255,1+rand()%255,1+rand()%255));
textout(buffer,font, "HighScores", 200, 10, makecol(255,255,0));
textprintf(buffer, font, 220, 20, makecol(255,255,255), " Top: %i ", (i+9));
if((Scrolly+310<0)&&(i<=ListSize))
{
Scrolly+=820;
i+=10;
}
if(i>101-10)break;
Scrolly--;
}
fout.close();
AIG=false;
return 0;
}
int Boss()
{
if(BossL==1)
{
int i;
for(i=0;i<(int)killedE;i++)
{
if((Enemeny[i].Valid==false)&&(BossExist==false))
{
Enemeny[i].hit=0;
Enemeny[i].Ec=47;
Enemeny[i].Ex=SCREEN_W;
Enemeny[i].Ey=100;
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
Enemeny[i].ELife=1000;
Enemeny[i].Valid=true;
Enemeny[i].Wait=10;
Enemeny[i].Size=105;
Enemeny[i].WR=20;
Enemeny[i].Freeze=false;
Enemeny[i].Type="L1Boss";
Enemeny[i].isBoss=true;
BossExist=true;
BossLife=Enemeny[i].ELife;
}
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
Enemeny[i].Ec=BossColor;
int randomnumbermodulusedfrom4=(1+rand()%5); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=BossEx+85;
Enemeny[i].Ey=BossEy+85;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=BossEx-85;
Enemeny[i].Ey=BossEy-85;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=BossEx+85;
Enemeny[i].Ey=BossEy-85;
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=BossEx-85;
Enemeny[i].Ey=BossEy+85;
}
if(randomnumbermodulusedfrom4==5)
{
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
}
Enemeny[i].ELife=6;
Enemeny[i].Valid=true;
Enemeny[i].Wait=WT;
Enemeny[i].Size=6;
Enemeny[i].WR=100;
Enemeny[i].Freeze=false;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT==level+8)
{
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=43;
}
}
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
if((Enemeny[i].Wizzait>120)||(Enemeny[i].Type=="L1Boss"))
{
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
if(Enemeny[i].Type!="L1Boss")Enemeny[i].Wizzait=0;
}
Enemeny[i].Wizzait++;
if(Enemeny[i].Type=="L1Boss")
{
Enemeny[i].Ex+=Enemeny[i].slopex*2;
Enemeny[i].Ey+=Enemeny[i].slopey*2;
}
if(Enemeny[i].Type!="L1Boss")
{
Enemeny[i].Ex+=Enemeny[i].slopex*10;
Enemeny[i].Ey+=Enemeny[i].slopey*10;
}
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=2;
if(Life<1)Dead();
}
}
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size,makecol(0,255,0));
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
if(Enemeny[i].isBoss)
{
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
BossColor=Enemeny[i].Ec;
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
}
if(BossL==2)
{
int i;
for(i=0;i<(int)killedE;i++)
{
if((Enemeny[i].Valid==false)&&(BossExist==false))
{
Enemeny[i].hit=0;
Enemeny[i].Ec=60;
Enemeny[i].Ex=SCREEN_W;
Enemeny[i].Ey=100;
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
Enemeny[i].ELife=800;
Enemeny[i].Valid=true;
Enemeny[i].Wait=100;
Enemeny[i].Size=30;
Enemeny[i].WR=70;
Enemeny[i].Freeze=false;
Enemeny[i].isBoss=true;
Enemeny[i].Type="L2Boss";
BossExist=true;
BossLife=Enemeny[i].ELife;
}
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
int randomnumbermodulusedfrom4=(1+rand()%5); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=198;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=318;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==5)
{
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
}
int randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%5);
if(BossLife>1400)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%8);
if(BossLife>1000)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%16);
if(BossLife>600)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%20);
if(BossLife>300)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%25);
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Type="Frosty";
Enemeny[i].ELife=1;
Enemeny[i].Valid=true;
Enemeny[i].Wait=70+(randomnumbermodulusedfromsomethingderivedfromthebosslife*randomnumbermodulusedfromsomethingderivedfromthebosslife);
Enemeny[i].Size=1+rand()%3;
Enemeny[i].WR=100;
Enemeny[i].Freeze=false;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1||(!(Enemeny[i].isBoss)))
{
Enemeny[i].Wait=100;
if(Enemeny[i].isBoss==true)
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*3;
Enemeny[i].Ey+=Enemeny[i].slopey*3;
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=4;
if(Life<1)Dead();
}
Enemeny[i].Ec=27;
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec+((int)Enemeny[i].hit*10));
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
}
if(Enemeny[i].Type=="Frosty")
{
Enemeny[i].Ex+=Enemeny[i].slopex*5;
Enemeny[i].Ey+=Enemeny[i].slopey*5;
Enemeny[i].Ec=makecol(255,255,255);
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, makecol(255,255,255));
if(Enemeny[i].Ex>SCREEN_W||Enemeny[i].Ex<0||Enemeny[i].Ey>SCREEN_H||Enemeny[i].Ey<0)
{
Enemeny[i].Valid=false;
Enemeny[i].Type=="";
}
if((((Enemeny[i].Ex+Enemeny[i].Size)>(PlayerXY[0]-10))&&((Enemeny[i].Ex-Enemeny[i].Size)<(PlayerXY[0]+10))&&((Enemeny[i].Ey-Enemeny[i].Size)<(PlayerXY[1]+10))&&((Enemeny[i].Ey+Enemeny[i].Size)>(PlayerXY[1]-10))))
{
PlayerIsFrozen=true;
if(FreezeD<8)FreezeD+=2; //edit freeze to increase till blah
Enemeny[i].Valid=false;
int randomnumbermodulusedfrom4=(1+rand()%5); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%SCREEN_W);
Enemeny[i].Ey=198;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%SCREEN_W);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%SCREEN_H);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=318;
Enemeny[i].Ey=(rand()%SCREEN_H);
}
if(randomnumbermodulusedfrom4==5)
{
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
}
}
}
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
}
if(BossL==3)
{
int i;
for(i=0;i<(int)killedE*4;i++)
{
if((Enemeny[i].Valid==false)&&(BossExist==false))
{
Enemeny[i].hit=0;
Enemeny[i].Ec=makecol(0,0,0);
Enemeny[i].Ex=SCREEN_W;
Enemeny[i].Ey=100;
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
Enemeny[i].ELife=1500;
Enemeny[i].Valid=true;
Enemeny[i].Wait=10;
Enemeny[i].Size=25;
Enemeny[i].WR=30;
Enemeny[i].Freeze=false;
Enemeny[i].isBoss=true;
Enemeny[i].Type="L3Boss";
BossExist=true;
BossLife=Enemeny[i].ELife;
}
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
Enemeny[i].Ec=BossColor;
int randomnumbermodulusedfrom4=(1+rand()%4);
int KRand=((int)killedE+rand()%((int)killedE*20));
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
Enemeny[i].ELife=1;
Enemeny[i].Valid=true;
Enemeny[i].Wait=WT;
Enemeny[i].Size=2;
Enemeny[i].WR=60;
Enemeny[i].Freeze=false;
if(BossIsFrozen)Enemeny[i].Freeze=true;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
if(Enemeny[i].isBoss)BossIsFrozen=true;
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT==WT*2)
{
if(Enemeny[i].isBoss)BossIsFrozen=false;
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=makecol(0,0,0);
}
}
if(!Enemeny[i].isBoss)
{
if(BossIsFrozen)Enemeny[i].Freeze=true;
sSQREX=(((BossEx)-Enemeny[i].Ex)*((BossEx)-Enemeny[i].Ex));
sSQREY=(((BossEy)-Enemeny[i].Ey)*((BossEy)-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(BossEx-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(BossEy-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*5;
Enemeny[i].Ey+=Enemeny[i].slopey*5;
}
if(Enemeny[i].isBoss)
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*3;
Enemeny[i].Ey+=Enemeny[i].slopey*3;
}
if((Enemeny[i].Ex<BossEx+5)&&(Enemeny[i].Ex>BossEx-5)&&(Enemeny[i].Ey<BossEy+5)&&(Enemeny[i].Ey>BossEy-5)&&(!Enemeny[i].isBoss))
{
if(BossIsFrozen)Enemeny[i].Freeze=true;
int randomnumbermodulusedfrom4=(1+rand()%4);
int KRand=((int)killedE+rand()%((int)killedE*20));
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
}
if((((Enemeny[i].Ex+Enemeny[i].Size)>(PlayerXY[0]-3))&&((Enemeny[i].Ex-Enemeny[i].Size)<(PlayerXY[0]+3))&&((Enemeny[i].Ey-Enemeny[i].Size)<(PlayerXY[1]+3))&&((Enemeny[i].Ey+Enemeny[i].Size)>(PlayerXY[1]-3))))
{
Life-=6;
if(Life<1)Dead();
}
}
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
if(Enemeny[i].isBoss)
{
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
BossColor=Enemeny[i].Ec;
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
}
if(BossL==4)
{
int i;
for(i=0;i<3;i++)
{
if((Enemeny[i].Valid==false)&&(BossExist==false))
{
Enemeny[i].hit=0;
Enemeny[i].Ec=10;
Enemeny[i].Ex=SCREEN_W;
Enemeny[i].Ey=100;
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
Enemeny[i].ELife=2000;
Enemeny[i].Valid=true;
Enemeny[i].Wait=1;
Enemeny[i].Size=30;
Enemeny[i].WR=40;
Enemeny[i].Freeze=false;
Enemeny[i].isBoss=true;
Enemeny[i].Type="L4Boss";
BossExist=true;
BossLife=Enemeny[i].ELife;
}
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
Enemeny[i].Ec=(int)killedE;
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
Enemeny[i].ELife=(int)killedE;
Enemeny[i].Valid=true;
Enemeny[i].Wait=1;
Enemeny[i].Type="Shield";
Enemeny[i].Size=(int)killedE;
Enemeny[i].WR=45;
Enemeny[i].Freeze=false;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT>level+8)
{
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=43;
}
}
if(!Enemeny[i].isBoss)
{
sSQREX=(((BossEx)-Enemeny[i].Ex)*((BossEx)-Enemeny[i].Ex));
sSQREY=(((BossEy)-Enemeny[i].Ey)*((BossEy)-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(BossEx-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(BossEy-Enemeny[i].Ey)/slopeEH;
}
if(Enemeny[i].isBoss)
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
}
if(((Enemeny[i].slopex/Enemeny[i].slopex)==1)&&((Enemeny[i].slopey/Enemeny[i].slopey)==1))
{
Enemeny[i].Ex+=Enemeny[i].slopex*5;
Enemeny[i].Ey+=Enemeny[i].slopey*5;
}
if((Enemeny[i].Ex<BossEx+5)&&(Enemeny[i].Ex>BossEx-5)&&(Enemeny[i].Ey<BossEy+5)&&(Enemeny[i].Ey>BossEy-5)&&(!Enemeny[i].isBoss))
{
if((((Enemeny[i].Ex+Enemeny[i].Size)>(PlayerXY[0]-3))&&((Enemeny[i].Ex-Enemeny[i].Size)<(PlayerXY[0]+3))&&((Enemeny[i].Ey-Enemeny[i].Size)<(PlayerXY[1]+3))&&((Enemeny[i].Ey+Enemeny[i].Size)>(PlayerXY[1]-3))))
{
Life-=8;
if(Life<1)Dead();
}
}
if(Enemeny[i].isBoss)
{
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
BossColor=Enemeny[i].Ec;
}
if(!Enemeny[i].isBoss)circle(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, makecol(1+rand()%254,1+rand()%254,1+rand()%254));
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
}
if(BossL==5)
{
int i;
for(i=0;i<10;i++)
{
if((Enemeny[i].Valid==false)&&(BossExist==false))
{
Enemeny[i].hit=0;
Enemeny[i].Ec=47;
Enemeny[i].Ex=SCREEN_W;
Enemeny[i].Ey=100;
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
Enemeny[i].ELife=5000;
Enemeny[i].Valid=true;
Enemeny[i].Wait=10;
Enemeny[i].Size=150;
Enemeny[i].WR=20;
Enemeny[i].Freeze=false;
Enemeny[i].isBoss=true;
Enemeny[i].Type="L5Boss";
BossExist=true;
BossLife=Enemeny[i].ELife;
}
if(BossLife>3999)
{
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
Enemeny[i].Ec=BossColor;
int randomnumbermodulusedfrom4=(1+rand()%5); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=BossEx+15;
Enemeny[i].Ey=BossEy+15;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=BossEx-15;
Enemeny[i].Ey=BossEy-15;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=BossEx+15;
Enemeny[i].Ey=BossEy-15;
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=BossEx-15;
Enemeny[i].Ey=BossEy+15;
}
if(randomnumbermodulusedfrom4==5)
{
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
}
Enemeny[i].ELife=1;
Enemeny[i].Valid=true;
Enemeny[i].Wait=WT;
Enemeny[i].Size=2;
Enemeny[i].WR=100;
Enemeny[i].Freeze=false;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT==level+8)
{
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=43;
}
}
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*3;
Enemeny[i].Ey+=Enemeny[i].slopey*3;
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=10;
if(Life<1)Dead();
}
}
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
if(Enemeny[i].isBoss)
{
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
BossColor=Enemeny[i].Ec;
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
if(BossLife<4000&&BossLife>2999)
{
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
int randomnumbermodulusedfrom4=(1+rand()%5); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=198;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=318;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==5)
{
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
}
int randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%5);
if(BossLife>1400)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%8);
if(BossLife>1000)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%16);
if(BossLife>600)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%20);
if(BossLife>300)randomnumbermodulusedfromsomethingderivedfromthebosslife=(rand()%25);
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Type="Frosty";
Enemeny[i].ELife=20;
Enemeny[i].Valid=true;
Enemeny[i].Wait=70+(randomnumbermodulusedfromsomethingderivedfromthebosslife*randomnumbermodulusedfromsomethingderivedfromthebosslife);
Enemeny[i].Size=2;
Enemeny[i].WR=100;
Enemeny[i].Freeze=false;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1||(!(Enemeny[i].isBoss)))
{
Enemeny[i].Wait=100;
if(Enemeny[i].isBoss==true)
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*4;
Enemeny[i].Ey+=Enemeny[i].slopey*4;
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=11;
if(Life<1)Dead();
}
Enemeny[i].Ec=makecol(205,205,255);
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
}
if(Enemeny[i].Type=="Frosty")
{
Enemeny[i].Ex+=Enemeny[i].slopex*8;
Enemeny[i].Ey+=Enemeny[i].slopey*8;
Enemeny[i].Ec=makecol(255,255,255);
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
if((((Enemeny[i].Ex+Enemeny[i].Size)>(PlayerXY[0]-3))&&((Enemeny[i].Ex-Enemeny[i].Size)<(PlayerXY[0]+3))&&((Enemeny[i].Ey-Enemeny[i].Size)<(PlayerXY[1]+3))&&((Enemeny[i].Ey+Enemeny[i].Size)>(PlayerXY[1]-3))))
{
PlayerIsFrozen=true;
if(FreezeD<6)FreezeD+=2;
Enemeny[i].Valid=false;
int randomnumbermodulusedfrom4=(1+rand()%5); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=198;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=318;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==5)
{
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
}
}
}
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
if(BossLife<3000&&BossLife>1999)
{
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
Enemeny[i].Ec=BossColor;
int randomnumbermodulusedfrom4=(1+rand()%4);
int KRand=((int)killedE+rand()%((int)killedE*15));
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
Enemeny[i].ELife=1;
Enemeny[i].Valid=true;
Enemeny[i].Wait=WT;
Enemeny[i].Size=2;
Enemeny[i].WR=80;
Enemeny[i].Freeze=false;
if(BossIsFrozen)Enemeny[i].Freeze=true;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
if(Enemeny[i].isBoss)BossIsFrozen=true;
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT==WT*2)
{
if(Enemeny[i].isBoss)BossIsFrozen=false;
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=43;
}
}
if(!Enemeny[i].isBoss)
{
if(BossIsFrozen)Enemeny[i].Freeze=true;
sSQREX=(((BossEx)-Enemeny[i].Ex)*((BossEx)-Enemeny[i].Ex));
sSQREY=(((BossEy)-Enemeny[i].Ey)*((BossEy)-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(BossEx-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(BossEy-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*4;
Enemeny[i].Ey+=Enemeny[i].slopey*4;
}
if(Enemeny[i].isBoss)
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex;
Enemeny[i].Ey+=Enemeny[i].slopey;
}
if((Enemeny[i].Ex<BossEx+5)&&(Enemeny[i].Ex>BossEx-5)&&(Enemeny[i].Ey<BossEy+5)&&(Enemeny[i].Ey>BossEy-5)&&(!Enemeny[i].isBoss))
{
if(BossIsFrozen)Enemeny[i].Freeze=true;
int randomnumbermodulusedfrom4=(1+rand()%4);
int KRand=((int)killedE+rand()%((int)killedE*20));
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=BossEx+rand()%KRand;
Enemeny[i].Ey=BossEy-rand()%KRand;
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=BossEx-rand()%KRand;
Enemeny[i].Ey=BossEy+rand()%KRand;
}
}
if((((Enemeny[i].Ex+Enemeny[i].Size)>(PlayerXY[0]-3))&&((Enemeny[i].Ex-Enemeny[i].Size)<(PlayerXY[0]+3))&&((Enemeny[i].Ey-Enemeny[i].Size)<(PlayerXY[1]+3))&&((Enemeny[i].Ey+Enemeny[i].Size)>(PlayerXY[1]-3))))
{
Life-=12;
if(Life<1)Dead();
}
}
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
if(Enemeny[i].isBoss)
{
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
BossColor=Enemeny[i].Ec;
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
if(BossLife<2000&&BossLife>999)
{
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
Enemeny[i].Ec=(int)killedE;
Enemeny[i].Ex=BossEx;
Enemeny[i].Ey=BossEy;
Enemeny[i].ELife=(int)killedE;
Enemeny[i].Valid=true;
Enemeny[i].Wait=1;
Enemeny[i].Type="Shield";
Enemeny[i].Size=40;
Enemeny[i].WR=55;
Enemeny[i].Freeze=false;
}
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT>level+8)
{
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=43;
}
}
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*5;
Enemeny[i].Ey+=Enemeny[i].slopey*5;
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=13;
if(Life<1)Dead();
}
}
if(!Enemeny[i].isBoss)
{
circle(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, makecol(rand()%255,rand()%255,rand()%255));
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
}
if(Enemeny[i].isBoss)
{
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, makecol(rand()%255,rand()%255,rand()%255));
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
BossColor=Enemeny[i].Ec;
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
if(BossLife<1000)
{
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT==level+8)
{
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=43;
}
}
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*5;
Enemeny[i].Ey+=Enemeny[i].slopey*5;
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=15;
if(Life<1)Dead();
}
}
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, makecol(rand()%255,rand()%255,rand()%255));
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
if(Enemeny[i].isBoss)
{
BossEx=Enemeny[i].Ex;
BossEy=Enemeny[i].Ey;
BossColor=Enemeny[i].Ec;
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
}
}
return 0;
}
int Leveling()
{
if((killedl>(level*level))&&(BossExist==false))
{
nosound();
mcharge+=.01;
LifeM+=level*3;
ManaMax+=level*5;
if(Life<LifeM)Life+=level*2;
if(Mana<ManaMax)Mana+=level*5;
level++;
killedl=0;
}
return 0;
}
int BossKilled()
{
clear_to_color(buffer, makecol(0,0,0));
double Scroll=0;
if(BossL==1)
{
while(!key[KEY_ENTER])
{
blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(0,0,0));
Scroll+=.05;
textout(buffer,font, "You defeated the first of DotMorte's", 5, 220-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Evil Legion Commanders, GigantoDot. ", 5, 240-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "His Death will anger DotMorte, So ", 5, 260-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Be warned as next in line may be the ", 5, 280-(int)Scroll,makecol(255,255,255));
textout(buffer,font, "Evil Frost Mage, AntarctiDot. But don't ", 5, 300-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "fear, your battle with GigantoDot has ", 5, 320-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Earned a new weapon for your arsenal", 5, 340-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " The Legendary Spell, Power Ball. To use", 5, 360-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "this new weapon hit your [space bar], and", 5, 380-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "unleash the power of GigantoDot.", 10, 400-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " Hit Enter ",5, 428-(int)Scroll, makecol(255,255,255));
}
PowerBall=true;
L1Dead=true;
clear_to_color(blood,0);
clear_to_color(buffer, makecol(0,0,0));
}
if(BossL==2)
{
while(!key[KEY_ENTER])
{
blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(0,0,0));
Scroll+=.05;
textout(buffer,font, "You have defeated AntarctiDot 2nd", 1, 220-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Evil Legion Commander, with his Death ", 1, 240-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "DotMorte suffers the loss of his Best", 1, 260-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Ice Mage, gaining fear that now you ", 1, 280-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "control his powers over ice, giving you ", 1, 300-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "A new spell.[R-Click] will now", 1, 320-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Sends streams of ice at your enemies", 1, 340-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "using the power of AntarctiDot.", 1, 360-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "DotMorte knows of this,there are ", 1, 380-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "hushed talks of SWARM being near.", 1, 400-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " Hit Enter ", 5, 428-(int)Scroll, 15);
}
L2Dead=true;
Freeze=true;
clear_to_color(blood,0);
clear_to_color(buffer, makecol(0,0,0));
}
if(BossL==3)
{
while(!key[KEY_ENTER])
{
Scroll+=.05;
blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(0,0,0));
textout(buffer,font, "You have defeated SWARM 3rd of the", 2, 220-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Evil Legion Commanders,The creatures", 10, 240-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Destroyed who made the SWARM will", 10, 260-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "leave a dent in the ranks of DotMorte's", 10, 280-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Legions, And as the Death of the SWARM ", 10, 300-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "commenced you felt power surge into you ", 10, 320-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " as you recieved a new spell, SWARM, To ", 10, 340-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "SWARM just hold down [TAB] and", 10, 360-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "your blasts will now swarm your reticle.", 10, 380-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Be Ready, ShieldDot was seen near here", 10, 400-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " Hit Enter ", 5, 428-(int)Scroll, 15);
}
L3Dead=true;
Swarm=true;
clear_to_color(blood,0);
clear_to_color(buffer, makecol(0,0,0));
}
if(BossL==4)
{
while(!key[KEY_ENTER])
{
blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(0,0,0));
Scroll+=.05;
textout(buffer,font, "You have defeated ShieldDot, 4th of", 2, 220-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "the Evil Legion Commanders, His now", 2, 240-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "dead body that was once was magically", 2, 260-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "protected has faded away and left you", 2, 280-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "with a new spell. Shield. To use the", 2, 300-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Shield hit [X], and a bubble of power", 2, 320-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "will surround you. This bubble will ", 2, 340-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "give you limited protection...but it", 2, 360-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "is heard that it may gain usefulness", 2, 380-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "as you progress. Be wary, Evil", 2, 400-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "surrounds us in this land....", 2, 420-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " Hit Enter ", 2, 438-(int)Scroll, 15);
}
L4Dead=true;
Shield=true;
clear_to_color(blood,0);
clear_to_color(buffer, makecol(0,0,0));
}
if(BossL==5)
{
while(!key[KEY_ENTER])
{
Scroll+=.05;
blit(buffer,screen,0,0,0,0,800,600);
clear_to_color(buffer, makecol(0,0,0));
textout(buffer,font, "You have achieved something once", 2, 220-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "thought impossible, you have defeated", 2, 240-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "ShifterDot One of the Most Powerful", 2, 260-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "beings in Dotmorte's legions, You are", 2, 280-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "now in control of one of the most ", 2, 300-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "useful powers in the land. You have", 2, 320-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "gained the ability...Spell Fusion!!", 2, 340-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Spell Fusion is the ability to take 2 ", 2, 360-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Spells and fuse them together to make", 2, 380-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "A new spell, To use Spell Fusion hit", 2, 400-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "[ALT] and you will then be set in ", 2, 420-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "Fusion Mode, the new spell is set to ", 2, 440-(int)Scroll, makecol(255,255,255));
textout(buffer,font, "[V] and will be listed at the top", 2, 460-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " of the Screen. ", 2, 480-(int)Scroll, makecol(255,255,255));
textout(buffer,font, " Hit Enter ", 2, 488-(int)Scroll, 15);
}
L5Dead=true;
fusion=true;
clear_to_color(blood,0);
clear_to_color(buffer, makecol(0,0,0));
}
PlayerXY[0]=SCREEN_W/2;
PlayerXY[1]=SCREEN_H/2;
killedE=1;
wave++;
Life+=level;
int i;
for(i=0;i<101;i++)
{
Enemeny[i].Valid=false;
Enemeny[i].Ex=0;
Enemeny[i].Ey=0;
}
return 0;
}
int Waves()
{
if((killedE>(wave*15))&&(BossExist==false))
{
MMX2=200;
MMY2=-100;
//PlayerXY[0]=SCREEN_W/2;
//PlayerXY[1]=SCREEN_H/2;
killedE=killedE/4;
wave++;
NewWave=true;
int i;
for(i=0;i<=Killed;i++)
{
while((1+rand()%29)!=(1+rand()%20))
{
int bsa;
int randn10=-1+rand()%16;
for(bsa=0;bloodspray[bsa].Valid&&bsa<301;bsa++);
sSQREX=((Enemeny[i].Ex+randn10-(PlayerXY[0]+randn10))*(Enemeny[i].Ex-(PlayerXY[0])));
sSQREY=((Enemeny[i].Ey+randn10-(PlayerXY[1]+randn10))*(Enemeny[i].Ey-(PlayerXY[1])));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[bsa].bx=Enemeny[i].Ex;
bloodspray[bsa].by=Enemeny[i].Ey;
bloodspray[bsa].bslopex=(Enemeny[i].Ex+randn10-PlayerXY[0]+randn10)/slopeEH;
bloodspray[bsa].bslopey=(Enemeny[i].Ey+randn10-PlayerXY[1]+randn10)/slopeEH;
bloodspray[bsa].size=1+rand()%2;
bloodspray[bsa].Grounded=1;
bloodspray[bsa].Valid=true;
}
Enemeny[i].ELife=0;
Enemeny[i].hit=0;
Enemeny[i].Wait=0;
Enemeny[i].WR=0;
Enemeny[i].Size=0;
Enemeny[i].Valid=false;
Enemeny[i].Type="Normal";
BossExist=false;
BossMode=false;
}
if((wave==3)&&(!WeaponTest)&&(!L1Dead))
{
BossMode=true;
BossL=1;
Boss();
}
if((wave==6)&&(!WeaponTest)&&(!L2Dead))
{
BossMode=true;
BossL=2;
Boss();
}
if((wave==9)&&(!WeaponTest)&&(!L3Dead))
{
fade_out(3);
BossMode=true;
BossL=3;
Boss();
fade_in(sprite_palette,3);
}
if((wave==12)&&(!WeaponTest)&&(!L4Dead))
{
BossMode=true;
BossL=4;
Boss();
}
if((wave==15)&&(!WeaponTest)&&(!L5Dead))
{
BossMode=true;
BossL=5;
Boss();
}
}
return 0;
}
int SFusion()
{
F1="";
F2="";
Fused="";
clear_to_color(buffer, makecol(0,0,0));
while(!key[KEY_1])
{
soundm++;
//if(SyncT)vsync();
//if(!SyncT)for(stop=0; stop<1000000; stop++);
blit(buffer,screen,0,0,0,0,320,200);
clear_to_color(buffer, makecol(0,0,0));
color++;
textout(buffer,font, "Spell Fusion", 120, 90, color);
textout(buffer,font, "Please hit the key for any spell", 2, 110, color);
textout(buffer,font, "Then Hit [1]", 2, 120, color);
if(key[KEY_TAB])F1="Swarm";
if(key[KEY_X])F1="Shield";
if(key[KEY_SPACE])F1="Powerball";
if(mouse_b & 2)F1="Frost";
textout(buffer,font, "1st Spell: ", 4, 39, 2);
textout(buffer,font,F1.c_str(), 84, 39, 2);
if(soundoff==1)
{
sound((rand()%60)+1);
if (soundm==100)
{
nosound();
soundm=0;
}
}
}
clear_to_color(buffer, makecol(0,0,0));
while(!key[KEY_2])
{
soundm++;
//if(SyncT)vsync();
//if(!SyncT)for(stop=0; stop<1000000; stop++);
blit(buffer,screen,0,0,0,0,320,200);
clear_to_color(buffer, makecol(0,0,0));
color++;
textout(buffer,font, "Spell Fusion", 120, 90, color);
textout(buffer,font, "Now hit a second spell key.", 2, 110, color);
textout(buffer,font, "Then Hit [2]", 2, 120, color);
if(key[KEY_TAB])F2="Swarm";
if(key[KEY_X])F2="Shield";
if(key[KEY_SPACE])F2="Powerball";
if(mouse_b & 2)F2="Frost";
textout(buffer,font, "1st Spell: ", 4, 39, 2);
textout(buffer,font,F1.c_str(), 84, 39, 2);
textout(buffer,font, "2nd Spell: ", 4, 59, 2);
textout(buffer,font,F2.c_str(), 84, 59, 2);
if(soundoff==1)
{
sound((rand()%60)+1);
if (soundm==100)
{
nosound();
soundm=0;
}
}
}
if(F1=="Powerball")
{
if(F2=="Swarm")Fused="PowerSwarm";
if(F2=="Frost")Fused="DeepFreeze";
if(F2=="Shield")Fused="PlasmaBlast";
}
if(F1=="Frost")
{
if(F2=="Swarm")Fused="Blizzard";
if(F2=="Shield")Fused="IceShield";
if(F2=="Powerball")Fused="DeepFreeze";
}
if(F1=="Swarm")
{
if(F2=="Shield")Fused="SwarmShield";
if(F2=="Frost")Fused="Blizzard";
if(F2=="Powerball")Fused="PowerSwarm";
}
clear_to_color(buffer, makecol(0,0,0));
return 0;
}
int MiniBosses()
{
if((L1Dead)&&(MBSTL1==0))
{
int i;
for(i=0;i<1000;i++)
{
if((Enemeny[i].Valid==false)&&(MBSTL1==0))
{
MBSTL1=100;
Enemeny[i].hit=0;
Enemeny[i].Ec=47;
int randomnumbermodulusedfrom4=(1+rand()%4);
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%800);
Enemeny[i].Ey=600;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%800);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%600);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=800;
Enemeny[i].Ey=(rand()%600);
}
Enemeny[i].ELife=100*wave;
Enemeny[i].Valid=true;
Enemeny[i].Wait=10;
Enemeny[i].Size=10*wave;
Enemeny[i].WR=20;
Enemeny[i].Freeze=false;
Enemeny[i].Type="L1MB";
BossLife=Enemeny[i].ELife;
L1Lives=true;
}
}
}
if(L1Lives)
{
int i;
for(i=0;i<1000;i++)
{
if(Enemeny[i].Type=="L1MB")
{
if(Enemeny[i].Valid==true)
{
if(Enemeny[i].Wait<1)
{
Enemeny[i].Wait=WT;
if(Enemeny[i].Freeze==true)
{
Enemeny[i].Wait=WT*4;
Enemeny[i].FT+=1;
if(Enemeny[i].FT==level+8)
{
Enemeny[i].Freeze=false;
Enemeny[i].FT=0;
Enemeny[i].Ec=43;
}
}
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*3;
Enemeny[i].Ey+=Enemeny[i].slopey*3;
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=4*wave;
if(Life<1)Dead();
}
}
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
}
}
if((L2Dead)&&(MBSTL2==0))
{
int i;
for(i=0;i<wave*4;i++)
{
if((Enemeny[i].Valid==false)&&(MBSTL2==0))
{
MBSTL2=130;
Freezies=1;
Enemeny[i].hit=0;
Enemeny[i].Ec=60;
int randomnumbermodulusedfrom4=(1+rand()%4);
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%800);
Enemeny[i].Ey=600;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%800);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%600);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=800;
Enemeny[i].Ey=(rand()%600);
}
Enemeny[i].ELife=70*wave;
Enemeny[i].Valid=true;
Enemeny[i].Wait=100;
Enemeny[i].Size=10;
Enemeny[i].WR=40;
Enemeny[i].Freeze=false;
Enemeny[i].Type="L2MB";
L2Lives=true;
}
}
}
if(L2Lives)
{
int i;
for(i=0;i<wave*4;i++)
{
if(Enemeny[i].Valid==false)
{
Enemeny[i].hit=0;
int randomnumbermodulusedfrom4=(1+rand()%4); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=198;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=318;
Enemeny[i].Ey=(rand()%198);
}
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Type="Frosty";
Enemeny[i].ELife=1;
Enemeny[i].Valid=true;
Enemeny[i].Wait=70;
Enemeny[i].Size=1;
Enemeny[i].WR=100;
Enemeny[i].Freeze=false;
}
if(Enemeny[i].Valid==true)
{
if(((Enemeny[i].Wait<1)&&(Enemeny[i].Type=="L2MB"))||(Enemeny[i].Type=="Frosty"))
{
Enemeny[i].Wait=100;
if(Enemeny[i].Type=="L2MB")
{
sSQREX=(((PlayerXY[0])-Enemeny[i].Ex)*((PlayerXY[0])-Enemeny[i].Ex));
sSQREY=(((PlayerXY[1])-Enemeny[i].Ey)*((PlayerXY[1])-Enemeny[i].Ey));
slopeEH=sqrt(sSQREX+sSQREY);
Enemeny[i].slopex=(PlayerXY[0]-Enemeny[i].Ex)/slopeEH;
Enemeny[i].slopey=(PlayerXY[1]-Enemeny[i].Ey)/slopeEH;
Enemeny[i].Ex+=Enemeny[i].slopex*4;
Enemeny[i].Ey+=Enemeny[i].slopey*4;
if(slopeEH-10-Enemeny[i].Size<1)
{
Life-=LifeM/10;
if(Life<1)Dead();
}
Enemeny[i].Ec=27;
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, makecol(245+rand()%10,245+rand()%10,245+rand()%10));
Enemeny[i].bex=Enemeny[i].Ex;
Enemeny[i].bey=Enemeny[i].Ey;
}
if(Enemeny[i].Type=="Frosty")
{
Enemeny[i].Ex+=Enemeny[i].slopex*6;
Enemeny[i].Ey+=Enemeny[i].slopey*6;
Enemeny[i].Ec=makecol(255,255,255);
circlefill(buffer,(int)Enemeny[i].Ex,(int)Enemeny[i].Ey,Enemeny[i].Size, Enemeny[i].Ec);
if(Enemeny[i].Ex>SCREEN_W||Enemeny[i].Ex<0||Enemeny[i].Ey>SCREEN_H||Enemeny[i].Ey<0)
{
Enemeny[i].Valid=false;
Enemeny[i].Type=="Normal";
}
if((((Enemeny[i].Ex+Enemeny[i].Size)>(PlayerXY[0]-3))&&((Enemeny[i].Ex-Enemeny[i].Size)<(PlayerXY[0]+3))&&((Enemeny[i].Ey-Enemeny[i].Size)<(PlayerXY[1]+3))&&((Enemeny[i].Ey+Enemeny[i].Size)>(PlayerXY[1]-3))))
{
PlayerIsFrozen=true;
if(FreezeD<8)FreezeD+=2;
Enemeny[i].Valid=false;
Enemeny[i].Type=="Normal";
int randomnumbermodulusedfrom4=(1+rand()%4); //modulused from 5 now i guess
if(randomnumbermodulusedfrom4==1)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=198;
}
if(randomnumbermodulusedfrom4==2)
{
Enemeny[i].Ex=(rand()%318);
Enemeny[i].Ey=2;
}
if(randomnumbermodulusedfrom4==3)
{
Enemeny[i].Ex=2;
Enemeny[i].Ey=(rand()%198);
}
if(randomnumbermodulusedfrom4==4)
{
Enemeny[i].Ex=318;
Enemeny[i].Ey=(rand()%198);
}
}
}
}
}
Enemeny[i].Wait-=Enemeny[i].WR;
}
}
return 0;
}
int Bonus()
{
int i=0;
for(i=0;i<100;i++)
{
color++;
if(Spec[i].Valid)
{
sSQREX=(((PlayerXY[0])-Spec[i].Sx-10)*((PlayerXY[0])-Spec[i].Sx-10));
sSQREY=(((PlayerXY[1])-Spec[i].Sy-10)*((PlayerXY[1])-Spec[i].Sy-10));
slopeEH=sqrt(sSQREX+sSQREY);
if(Spec[i].Type=="health")draw_sprite(buffer,healthS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="mana")draw_sprite(buffer,manaS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="sloth")draw_sprite(buffer,slothS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="speed")draw_sprite(buffer,speedS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="death")draw_sprite(buffer,deathS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="healthboost")draw_sprite(buffer,healthBS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="RFInc")draw_sprite(buffer,RFIncS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="speedboost")draw_sprite(buffer,speedboostS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if(Spec[i].Type=="levelup")draw_sprite(buffer,levelupS,(int)Spec[i].Sx,(int)Spec[i].Sy);
if((slopeEH-10-20<1))
{
Spec[i].Valid=false;
lastpickup=Spec[i].Type;
pickup=100;
Spec[i].Ssize=0;
if(Spec[i].Type=="health")if(Life<LifeM)Life+=LifeM*.35;
if(Spec[i].Type=="mana")if(Mana<ManaMax)Mana+=ManaMax*.35;
if((Spec[i].Type=="speed")&&(!boosting))
{
boosting=true;
PBS*=2;
pickup=250;
}
if((Spec[i].Type=="sloth")&&(!sloth))
{
sloth=true;
ESS=.5;
pickup=250;
}
if((Spec[i].Type=="death")&&(!PiD))
{
PiD=true;
pickup=250;
}
if(Spec[i].Type=="healthboost")LifeM+=LifeM/20;
if(Spec[i].Type=="RFInc")RFI++;
if(Spec[i].Type=="speedboost")PBS++;
if(Spec[i].Type=="levelup")killedl=(level*level);
if(Spec[i].Type=="");
}
}
}
return 0;
}
int Blood()
{
int i;
for(i=0;i<300;i++)
{
color++;
if(bloodspray[i].Valid)
{
sSQREX=(((PlayerXY[0])-bloodspray[i].bx+(-5+rand()%10))*((PlayerXY[0])-bloodspray[i].bx+(-5+rand()%10))); //-5
sSQREY=(((PlayerXY[1])-bloodspray[i].by+(-5+rand()%10))*((PlayerXY[1])-bloodspray[i].by+(-5+rand()%10)));
slopeEH=sqrt(sSQREX+sSQREY);
bloodspray[i].bx+=bloodspray[i].bslopex*2;//*(7-(-1+rand()%2));
bloodspray[i].by+=bloodspray[i].bslopey*2;//*(7-(-1+rand()%2));
if(Enemeny[i].Type!="Frosty")circlefill(buffer,(int)bloodspray[i].bx,(int)bloodspray[i].by,(int)bloodspray[i].size,makecol(210+rand()%45,0,0));
if(Enemeny[i].Type=="Frosty")circlefill(buffer,(int)bloodspray[i].bx,(int)bloodspray[i].by,1,makecol(255,255,255));
bloodspray[i].timer+=1+rand()%6;
//if((slopeEH-10-10<1)&&(PiD))
//{
//bloodspray[i].Valid=false;
//if(Life<LifeM)Life+=mcharge;
//}
if(bloodspray[i].timer>40)
{
//if(!bloodspray[i].Grounded)
//{
bloodspray[i].timer=0;
//}
//if(bloodspray[i].Grounded)
//{
bloodspray[i].Valid=false;
if(Enemeny[i].Type!="Frosty")circlefill(blood,(int)bloodspray[i].bx,(int)bloodspray[i].by,(int)bloodspray[i].size,makecol(170+rand()%35,0,0));
if(Enemeny[i].Type=="Frosty")circlefill(blood,(int)bloodspray[i].bx,(int)bloodspray[i].by,1,makecol(255,255,255));
bloodspray[i].bslopex=0;
bloodspray[i].bslopey=0;
}
//}
}
}
return 0;
}
int Sparkle()
{
int i;
for(i=0;i<1000;i++)
{
if(Sparky[i].Valid)
{
Sparky[i].Sx+=Sparky[i].Sslopex;
Sparky[i].Sy+=Sparky[i].Sslopey;
if(Sparky[i].type=="freeze")circlefill(buffer,(int)Sparky[i].Sx,(int)Sparky[i].Sy,1,makecol(255,255,255));
else circlefill(buffer,(int)Sparky[i].Sx,(int)Sparky[i].Sy,1,makecol(1+rand()%254,1+rand()%254,1+rand()%254));
Sparky[i].timer+=1+rand()%6;
if(Sparky[i].dead&&Sparky[i].timer>80)
{
Sparky[i].timer=0;
Sparky[i].dead=0;
Sparky[i].type="";
Sparky[i].Valid=0;
Sparky[i].Sslopex=0;
Sparky[i].Sslopey=0;
}
if(!Sparky[i].dead&&Sparky[i].timer>40)
{
Sparky[i].timer=0;
Sparky[i].dead=0;
Sparky[i].type="";
Sparky[i].Valid=0;
Sparky[i].Sslopex=0;
Sparky[i].Sslopey=0;
}
}
}
return 0;
}