all of it? it has 1400 lines.
Here you have the output function:
void OutputText ( int, int, char*, DWORD );
(...)
void OutputText ( int X, int Y, char* String, DWORD fgColor )
{
ForeColor = g_pGlob->dwForeColor;
g_pGlob->dwForeColor = fgColor;
dbText ( X, Y, String );
g_pGlob->dwForeColor = ForeColor;
}
And i use it on SystemUpdate
/*
=================================================
SYSTEM UPpngE AND OTHER FUNCTIONS
=================================================
*/
void SystemUppnge()
{
OutputText(350, 100, "HEYOOOO", RGB(255,255,255));
}
If you want the code:
1500 LINES:
#include "DarkGDK.h"
#include <vector>
#include <time.h>
#include <windows.h>
#include "globstruct.h"
DWORD BackColor;
DWORD ForeColor;
void OutputText ( int, int, char*, DWORD );
float En1X [50] = { -500, -500, 300, -503, 1584, 1445, 1400, 700, 908, 0};
float En1Y [50] = { 500, -200, -600, -403, -4, 505, 698, 1400, 1400, 1100};
float En2X [50] = { -500, -500, 300, -503, 1584, 1445, 1400, 700, 908, 0};
float En2Y [50] = { 500, -200, -600, -403, -4, 505, 698, 1400, 1400, 1100};
int dificult = 1;
int GameState;
void SystemUppnge();
int GetFreeSpriteID ( void )
{
int id = 0;
while ( dbSpriteExist ( ++id ) );
return id;
}
void PointSprite ( int fromID, int Targetx, int Targety )
{
float ANGLE;
int DX = Targetx - dbSpriteX( fromID );
int DY = Targety - dbSpriteY( fromID );
int DIST = (DX * DX) + (DY * DY);
if( DIST > 0 )
{
ANGLE = dbAtanFull ( Targetx - dbSpriteX( fromID ), dbSpriteY( fromID ) - Targety );
dbRotateSprite( fromID , ANGLE - 180 );
}
}
int count=0;
using std::vector;
#define MAX_BULLETS 30
#define WallUpID 300
#define WallDownID 301
#define WallLeftID 302
#define WallRightID 303
#define WALL_H_IMAGE 305
#define WALL_V_IMAGE 306
#define BLOCKID 320
#define MAX_BLOCKS 3
#define ENEMY1_IMAGE 603
#define ENEMY2_IMAGE 604
#define ENEMY3_IMAGE 605
//Sounds
#define ENEMY_HURT 225
#define PLAYER_HURT 226
#define ENEMY_DIE 227
#define NEW_GUN 228
//Weapons
#define PISTOLID 401
#define RIFLEID 402
#define SMGID 403
//Spawn Pos
//THE ARRAYS//
#define ENEMY1_X 1600
#define ENEMY1_Y 600
#define ENEMY2_X -340
#define ENEMY2_Y 300
#define ENEMY3_X -400
#define ENEMY3_Y 700
#define ENEMY4_X 200
#define ENEMY4_Y -600
#define ENEMY5_X 1600
#define ENEMY5_Y 300
#define ROUND_2 10000
#define ROUND_3 36000
#define ROUND_4 70000
#define ROUND_5 90000
#define ROUND_6 120000
int EnemyCount;
int round = 1;
bool debug = false;
bool fps = true;
struct Enemy1
{
public:
void LoadEnemy(int PosID);
void Spawn();
void Move(int LastX, int LastY);
void Uppnge();
void Reload();
void DestroyEnemy(int spawwtime);
bool cSpawn;
bool alive;
float speed;
int hp;
float playerhp;
int spawnX, spawnY;
int id;
int x, y, sizeX, sizeY;
int score;
}enemy1 [50];
struct Enemy2
{
public:
void LoadEnemy(int PosID);
void Spawn(int SpawnX, int SpawnY);
void Move(int LastX, int LastY);
void Uppnge();
void Reload();
void DestroyEnemy(int spawwtime);
bool cSpawn2;
int PosID2;
int spawnX, spawnY;
float speed;
int hp;
int id;
int x, y, sizeX, sizeY;
int score;
}enemy2 [50];
struct Enemy3
{
public:
void LoadEnemy();
void Spawn(int SpawnX, int SpawnY);
void Move(int LastX, int LastY);
void Uppnge();
void Reload();
void DestroyEnemy(int spawwtime);
bool cSpawn3;
float speed;
int hp;
int id;
int x, y, sizeX, sizeY;
int score;
}en3;
struct Enemy4
{
public:
void LoadEnemy();
void Spawn(int SpawnX, int SpawnY);
void Move(int LastX, int LastY);
void Uppnge();
void Reload();
void DestroyEnemy(int spawwtime);
bool cSpawn4;
float speed;
int hp;
int id;
int x, y, sizeX, sizeY;
int score;
}en4;
struct Enemy5
{
public:
void LoadEnemy();
void Spawn(int SpawnX, int SpawnY);
void Move(int LastX, int LastY);
void Uppnge();
void Reload();
void DestroyEnemy(int spawwtime);
bool cSpawn5;
float speed;
int hp;
int id;
int x, y, sizeX, sizeY;
int score;
}en5;
struct BULLET{
public:
BULLET *Next,*Previous;
float x,y;
float Direction,Speed;
void make(int Px,int Py,float D,float S);
void destroy();
};
struct Player {
public:
time_t seconds;
void Init();
void Uppnge();
void Die();
void Shoot(int mx, int my, float S);
void Destroy();
bool rifle;
bool smg;
int gun;
int money, ammo, PlayerID, lifes, score;
float speed, BulletSpd, hp;
float x, y, width, height;
int velx, vely, SizeX, SizeY;
BULLET *LastBullet,*FirstBullet;
void MoveBullets();
}player;
void Player::MoveBullets(){
BULLET *B=FirstBullet->Next;
while (B!=NULL){
//move it
B->x+=dbCos(B->Direction)*B->Speed;
B->y+=dbSin(B->Direction)*B->Speed;
//check for collisions.....
bool Destroy=false;
//..... check for anything that will cause the bullet to need to be destoyed. this would set Destroy=true;
if ((B->x<0)||(B->x>1024)||(B->y<0)||(B->y>768)) Destroy=true;
/* Collision BULLET / ENEMY1*/
for(int x = 0; x < 30; x++)
{
float lx=dbABS(B->x-dbSpriteX(enemy1[x].id));
float ly=dbABS(B->y-dbSpriteY(enemy1[x].id));
if ((lx<enemy1[x].sizeX)&&(ly<enemy1[x].sizeY)){//hit
if(enemy1[x].hp < 0)
{
enemy1[x].DestroyEnemy(4);
dbPlaySound(ENEMY_DIE);
player.score += enemy1[x].score;
EnemyCount -= 1;
enemy1[x].Spawn();
}
else {
float damage = 10 * player.BulletSpd / 3;
enemy1[x].hp -= damage;
dbPlaySound(ENEMY_HURT);
}
Destroy = true; //this automaticaly destroys the bullet right?
}
}
/* END COLLISION FOR ENEMY 1 */
/* Collision BULLET / ENEMY2*/
for(int a = 0; a < 30; a++)
{
float lx2=dbABS(B->x-dbSpriteX(enemy2[a].id));
float ly2=dbABS(B->y-dbSpriteY(enemy2[a].id));
if ((lx2<enemy2[a].sizeX)&&(ly2<enemy2[a].sizeY)){//hit
if(enemy2[a].hp < 0)
{
dbPlaySound(ENEMY_DIE);
enemy2[a].DestroyEnemy(4);
player.score += enemy2[a].score;
EnemyCount -= 1;
enemy2[a].Reload();
}
else {
float damage = 10 * player.BulletSpd / 3;
enemy2[a].hp -= damage;
dbPlaySound(ENEMY_HURT);
}
Destroy = true; //this automaticaly2 destroys the bullet right?
}
}
/* END COLLISION FOR ENEMY 2 */
/* Collision BULLET / ENEMY3*/
float lx3=dbABS(B->x-dbSpriteX(en3.id));
float ly3=dbABS(B->y-dbSpriteY(en3.id));
if ((lx3<en3.sizeX)&&(ly3<en3.sizeY)){//hit
if(en3.hp < 0)
{
en3.DestroyEnemy(4);
player.score += en3.score;
EnemyCount -= 1;
en3.Reload();
dbPlaySound(ENEMY_DIE);
}
else {
float damage = 10 * player.BulletSpd / 3;
en3.hp -= damage;
dbPlaySound(ENEMY_HURT);
}
Destroy = true; //this automaticaly2 destroys the bullet right?
}
/* END COLLISION FOR ENEMY 3 */
/* Collision BULLET / ENEMY4*/
float lx4=dbABS(B->x-dbSpriteX(en4.id));
float ly4=dbABS(B->y-dbSpriteY(en4.id));
if ((lx4<en4.sizeX)&&(ly4<en4.sizeY)){//hit
if(en4.hp < 0)
{
en4.DestroyEnemy(4);
player.score += en4.score;
EnemyCount -= 1;
en4.Reload();
dbPlaySound(ENEMY_DIE);
}
else {
float damage = 10 * player.BulletSpd / 3;
en4.hp -= damage;
dbPlaySound(ENEMY_HURT);
}
Destroy = true; //this automaticaly2 destroys the bullet right?
}
/* END COLLISION FOR ENEMY 4 */
if (!Destroy){
//display
dbDot(B->x, B->y);
//here we go to the next bullet
B=B->Next;
}
else {
BULLET *OldNext=B->Next;
B->destroy();
B=OldNext;
count--;
}
}
}
void BULLET::make(int Px,int Py,float D,float S){
Next=new BULLET;
Next->Next=NULL;
Next->Previous=player.LastBullet;
Next->x=Px;
Next->y=Py;
Next->Direction=D;
Next->Speed=S;
player.LastBullet=Next;
}
void BULLET::destroy(){
if ((Next!=NULL)&&(Previous!=NULL)){//in the middle
Previous->Next=Next;
Next->Previous=Previous;
Next=Previous=NULL;
delete this;
}
else if ((Next==NULL)&&(Previous!=NULL)){//last
Previous->Next=NULL;
player.LastBullet=Previous;
Next=Previous=NULL;
delete this;
}
}
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetImageColorKey(255, 0, 255);
dbDisableEscapeKey ( );
dbSetDisplayModeAntialias(1024, 768, 32, 1, 0, 0);
dbSetWindowPosition( 0, 0);
dbSetWindowTitle("Shoot2Survive 4 - Last Man Stand");
if(
!dbFileExist("images//enemy1.png") &&
!dbFileExist("images//enemy2.png") &&
!dbFileExist("images//enemy4.png") &&
!dbFileExist("images//wallv.png") &&
!dbFileExist("images//wallh.png") &&
!dbFileExist("weps//pistol.png") &&
!dbFileExist("weps//rifle.png") &&
!dbFileExist("weps//smg.png") &&
!dbFileExist("weps//smgico.png") &&
!dbFileExist("weps//rifleico.png") &&
!dbFileExist("sfxs//pistol.wav") &&
!dbFileExist("sfx//smg.wav") &&
!dbFileExist("sfx//rifle.wav")
)
{
MessageBox (NULL, "There are missing files! Please re-install Shoot2Survive again to fix this problem!", "Missing Files", MB_OK);
return;
}
else
{
dbLoadImage("images//block.png", BLOCKID);
dbLoadImage("images//enemy2.png", ENEMY2_IMAGE);
dbLoadImage("images//enemy1.png", ENEMY1_IMAGE);
dbLoadImage("images//enemy4.png", ENEMY3_IMAGE);
dbLoadImage("images//wallv.png", WALL_V_IMAGE);
dbLoadImage("images//wallh.png", WALL_H_IMAGE);
//Weapons Images
dbLoadImage("weps//pistol.png", PISTOLID);
dbLoadImage("weps//rifle.png", RIFLEID);
dbLoadImage("weps//smg.png", SMGID);
dbLoadImage("weps//smgico.png", 751);
dbLoadImage("weps//rifleico.png", 752);
//Sounds
dbLoadSound("sfx//pistol.wav", PISTOLID);
dbLoadSound("sfx//smg.wav", SMGID);
dbLoadSound("sfx//rifle.wav", RIFLEID);
dbLoadSound("sfx//hurte.wav", ENEMY_HURT);
dbLoadSound("sfx//hurtp.wav", PLAYER_HURT);
dbLoadSound("sfx//die.wav", ENEMY_DIE);
dbLoadSound("sfx//newgun.wav", NEW_GUN);
}
player.Init();
for(int n = 0;n<50;n++)
{
enemy1[n].LoadEnemy(n);
}
for(int m = 0; m < 50; m++)
{
enemy2[m].LoadEnemy(m);
}
//Load Enemies
en3.LoadEnemy();
en4.LoadEnemy();
GameState = 1; /*1 - MainMenu
2 - Game
3 - Paused
4 - GameOver
5 - byebye
*/
while ( LoopGDK ( ) )
{
switch(GameState)
{
case 1:
dbCLS(RGB(0, 0, 0));
dbLoadImage("images//MainMenu.png", 500);
dbSprite(500, 0, 0, 500);
dbHideSprite(1);
dbHideSprite(500);
dbPasteImage(500, 0, 0);
if(dbMouseX() > 325 && dbMouseX() < 730 && dbMouseY() > 380 && dbMouseY() < 440 && dbMouseClick())
{
//dbShowSprite(1);
GameState = 6;
}
else if(dbMouseX() > 450 && dbMouseX() < 615 && dbMouseY() > 700 && dbMouseY() < 760 && dbMouseClick())
{
GameState = 5;
}
dbSync();
break;
case 2:
dbCLS(RGB(75, 75, 75));
SystemUppnge();
player.Uppnge();
//Handle enemies
for(int i = 0;i < 30;i++)
{
enemy1[i].Uppnge();
}
for(int i2 = 0; i2 < 30; i2++)
{
enemy2[i2].Uppnge();
}
en3.Uppnge();
en4.Uppnge();
if ( dbEscapeKey ( ) )
{
GameState = 5;
}
SystemUppnge();
dbSync ( );
break;
case 4:
dbCLS(RGB(0, 0, 0));
dbLoadImage("images//GameOver.png", 500);
dbSprite(500, 0, 0, 500);
dbHideSprite(500);
dbPasteImage(500, 0, 0);
if(dbKeyState(28))
{
GameState = 1;
}
else if(dbKeyState(1))
{
GameState = 5;
}
dbSync();
break;
case 5:
for ( int i = 1; i < 10000; i ++)
{
dbDeleteSound(i);
dbDeleteImage(i);
dbDeleteSprite(i);
}
player.Destroy();
for(int n = 0; n < 100000; n++)
{
if(dbSpriteExist(n))
{
dbDeleteImage(n);
dbDeleteSprite(n);
}
}
return;
break;
case 6:
//Difficulty
dbCLS(RGB(0, 0, 0));
dbLoadImage("images//Difficulty.png", 700);
dbSprite(500, 0, 0, 700);
dbHideSprite(1);
dbHideSprite(700);
dbPasteImage(700, 0, 0);
if(dbMouseX() > 405 && dbMouseX() < 615 && dbMouseY() > 425 && dbMouseY() < 570 && dbMouseClick()) //Easy
{
player.lifes = 400;
player.x = 600;
player.y = 500;
dbShowSprite(1);
GameState = 2;
dificult = 1;
}
else if(dbMouseX() > 422 && dbMouseX() < 600 && dbMouseY() > 535 && dbMouseY() < 584 && dbMouseClick()) //Normal
{
player.lifes = 10;
player.x = 600;
player.y = 500;
dbShowSprite(1);
GameState = 2;
dificult = 2;
}
else if(dbMouseX() > 448 && dbMouseX() < 570 && dbMouseY() > 647 && dbMouseY() < 700 && dbMouseClick()) //Hard
{
player.lifes = 2;
player.x = 600;
player.y = 500;
dbShowSprite(1);
GameState = 2;
dificult = 3;
}
else if( dbEscapeKey ( ) )
{
GameState = 5;
}
dbSync();
break;
}
}
for ( int i = 1; i < 5000; i ++)
{
dbDeleteImage(i);
dbDeleteSprite(i);
}
player.Destroy();
for(int n = 0; n < 5000; n++)
{
if(dbSpriteExist(n))
{
dbDeleteImage(n);
dbDeleteSprite(n);
}
}
return;
}
void Player::Init()
{
PlayerID = 1;
money = 1000;
speed = 3;
x = 1024 / 2;
y = 768 / 2;
lifes = 5;
SizeX = 20;
SizeY = 20;
dbOffsetSprite (PlayerID, x + 20, y + 20);
rifle = false;
smg = false;
gun = 1;
hp = 100;
width = 10;
height = 10;
BulletSpd = 3;
FirstBullet=new BULLET;
FirstBullet->Next=NULL;
FirstBullet->Previous=NULL;
LastBullet=FirstBullet;
seconds = time(0);
dbLoadImage("images//player.png", PlayerID);
dbSprite(PlayerID, x, y, PlayerID);
}
void Player::Uppnge()
{
if(dbKeyState(3))
{
if(smg) gun = 2;
}
else if(dbKeyState(4))
{
if(rifle) gun = 3;
}
else if(dbKeyState(2))
{
gun = 1;
}
if(gun == 1)
{
player.BulletSpd = 3;
}
else if(gun == 2)
{
player.BulletSpd = 6;
}
else if(gun == 3)
{
player.BulletSpd = 10;
}
dbText(20, 40, "Owned Weapons:");
dbText(20, 50, "Pistol (1)");
if(smg) dbText(20, 70, "MP5 SMG (2)");
if(rifle) dbText(20,90, "M4 Rifle (3)");
//Movement
if(dbUpKey() == 1)
{
dbMoveSprite(PlayerID, speed);
if(dbSpriteCollision(PlayerID, WallUpID))
{
dbRotateSprite(PlayerID,180);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallDownID))
{
dbRotateSprite(PlayerID,180);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallLeftID))
{
dbRotateSprite(PlayerID,180);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallRightID))
{
dbRotateSprite(PlayerID,180);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 1))
{
dbRotateSprite(PlayerID,180);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 2))
{
dbRotateSprite(PlayerID,180);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
}
if(dbRightKey() == 1)
{
dbRotateSprite(PlayerID,90);
dbMoveSprite(PlayerID,speed);
dbRotateSprite(PlayerID,0);
if(dbSpriteCollision(PlayerID, WallUpID))
{
dbRotateSprite(PlayerID,270);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallDownID))
{
dbRotateSprite(PlayerID,270);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallLeftID))
{
dbRotateSprite(PlayerID,270);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallRightID))
{
dbRotateSprite(PlayerID,270);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 1))
{
dbRotateSprite(PlayerID,270);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 2))
{
dbRotateSprite(PlayerID,270);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
}
if(dbLeftKey() == 1)
{
dbRotateSprite(PlayerID,270);
dbMoveSprite(PlayerID,speed);
dbRotateSprite(PlayerID,0);
if(dbSpriteCollision(PlayerID, WallUpID))
{
dbRotateSprite(PlayerID,90);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallDownID))
{
dbRotateSprite(PlayerID,90);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallLeftID))
{
dbRotateSprite(PlayerID,90);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, WallRightID))
{
dbRotateSprite(PlayerID,90);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 1))
{
dbRotateSprite(PlayerID,90);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 2))
{
dbRotateSprite(PlayerID,90);
dbMoveSprite(PlayerID, speed);
dbRotateSprite(PlayerID,0);
}
}
if (dbDownKey() == 1)
{
dbRotateSprite(PlayerID,180);
dbMoveSprite(PlayerID,speed);
dbRotateSprite(PlayerID,0);
//COLLISION DOWN
if(dbSpriteCollision(PlayerID, WallUpID))
{
dbMoveSprite(PlayerID,speed);
}
if(dbSpriteCollision(PlayerID, WallRightID))
{
dbMoveSprite(PlayerID,speed);
}
if(dbSpriteCollision(PlayerID, WallLeftID))
{
dbMoveSprite(PlayerID,speed);
}
if(dbSpriteCollision(PlayerID, WallDownID))
{
dbMoveSprite(PlayerID,speed);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 1))
{
dbMoveSprite(PlayerID,speed);
}
if(dbSpriteCollision(PlayerID, BLOCKID + 2))
{
dbMoveSprite(PlayerID,speed);
}
}
x=dbSpriteX(PlayerID);
y=dbSpriteY(PlayerID);
if(dbMouseClick())
{
if(player.gun == 1) dbPlaySound(PISTOLID);
else if(player.gun == 2) dbPlaySound(SMGID);
else if(player.gun == 3) dbPlaySound(RIFLEID);
Shoot(dbMouseX(), dbMouseY(), BulletSpd);
}
MoveBullets();
}
void Player::Shoot(int mx, int my, float S)
{
float D=dbATANFULL((my-y),(mx-x));
LastBullet->make(x + SizeX, y+SizeY, D, S);
count++;
}
void Player::Destroy()
{
//delete them all
while (FirstBullet->Next!=NULL) FirstBullet->Next->destroy();
delete FirstBullet;
}
/*
=================================================
SYSTEM UPpngE AND OTHER FUNCTIONS
=================================================
*/
void SystemUppnge()
{
dbText(300, 20, "HP: ");
dbText(325, 20, dbStr(player.hp));
dbSprite(WallUpID, 0,0, WALL_H_IMAGE);
dbSprite(WallDownID, 0, 759, WALL_H_IMAGE);
dbSprite(WallLeftID, 0, 0, WALL_V_IMAGE);
dbSprite(WallRightID, 1015, 0, WALL_V_IMAGE);
dbSprite(BLOCKID + 1, 300, 320, BLOCKID);
dbSprite(BLOCKID + 2, 760, 450, BLOCKID);
OutputText(350, 100, "HEYOOOO", RGB(255,255,255));
dbText(300, 40, "Lifes: ");
dbText(350, 40, dbStr(player.lifes));
dbText(300, 70, "Score: ");
dbText(350, 70, dbStr(player.score));
if(player.lifes < 0)
{
dbHideSprite(1);
GameState = 4;
}
//Round Handler
if(round == 1 && player.score > ROUND_2)
{
round = 2;
int rndom = dbRnd(10000);
if(player.smg != true)
{
dbPlaySound(NEW_GUN);
player.smg = true;
}
}
else if(round == 2 && player.score > ROUND_3)
{
round = 3;
}
else if(round == 3 && player.score > ROUND_4)
{
round = 4;
int rndom = dbRnd(10000);
if(player.rifle != true)
{
dbPlaySound(NEW_GUN);
player.rifle = true;
}
}
else if(round == 4 && player.score > ROUND_5)
{
round = 5;
}
else if(round == 5 && player.score > ROUND_6)
{
round = 6;
}
if(dbKeyState(12))
{
debug = true;
}
else if(dbKeyState(13))
{
debug = false;
}
if(debug)
{
dbText(20, 100, dbStr(dbMouseX()));
dbText(20, 130, dbStr(dbMouseY()));
}
dbText(450, 20, dbStr(round));
dbText(400, 20, "Round:");
if(fps)
{
dbText(20,20, "FPS: ");
dbText(60,20,dbStr(dbScreenFPS()));
}
if(player.gun == 1)
{
if(dbSpriteExist(SMGID) || dbSpriteExist(RIFLEID))
{
dbDeleteSprite(SMGID);
dbDeleteSprite(RIFLEID);
}
dbSprite(PISTOLID, 840, 20, PISTOLID);
}
else if(player.gun == 2)
{
if(dbSpriteExist(PISTOLID) || dbSpriteExist(RIFLEID))
{
dbDeleteSprite(PISTOLID);
dbDeleteSprite(RIFLEID);
}
dbSprite(PISTOLID, 700, 20, SMGID);
}
else if(player.gun == 3)
{
if(dbSpriteExist(PISTOLID) || dbSpriteExist(SMGID))
{
dbDeleteSprite(PISTOLID);
dbDeleteSprite(SMGID);
}
dbSprite(PISTOLID, 700, 20, RIFLEID);
}
}
/////////////////////////////////////////////////////////
/*
================================================
ENEMY 1
================================================
*/
void Enemy1::LoadEnemy(int PosID)
{
id = GetFreeSpriteID() + dbRnd(100000);
dbLoadImage("images//enemy1.png", ENEMY1_IMAGE);
speed = -1 * round + 0.5;
score = 100;
hp = 100;
spawnX = En1X[PosID];
spawnY = En1Y[PosID];
int reload = PosID;
sizeX = 40;
sizeY = 29;
cSpawn = true;
alive = true;
}
void Enemy1::Move(int LastX, int LastY)
{
if(!dbSpriteCollision(id, BLOCKID + 1))
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
}
if(!dbSpriteCollision(id, BLOCKID + 2))
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
}
}
void Enemy1::Uppnge()
{
x = dbSpriteX(id);
y = dbSpriteY(id);
if(cSpawn)
{
Spawn();
EnemyCount += 1;
cSpawn = false;
}
if(!dbSpriteCollision(id, 1))
{
Move(player.x, player.y);
}
else
{
player.lifes--;
dbPlaySound(PLAYER_HURT);
dbDeleteSprite(id);
cSpawn = true;
}
}
void Enemy1::Spawn()
{
dbSprite(id, spawnX, spawnY, ENEMY1_IMAGE);
}
void Enemy1::DestroyEnemy(int spawntime)
{
dbDeleteSprite(id);
}
void Enemy1::Reload()
{
}
/////////////////////////////////////////////////////////
/*
================================================
ENEMY 2
================================================
*/
void Enemy2::LoadEnemy(int PosID)
{
id = GetFreeSpriteID() + dbRnd(100000);
if(dbSpriteExist(id))
{
id = GetFreeSpriteID();
}
speed = -1 * round;
if(speed > 5)
{
speed = 5;
}
PosID2 = PosID;
score = 100;
hp = 300;
spawnX = En2X[PosID];
spawnY = En2Y[PosID];
sizeX = 40;
sizeY = 29;
cSpawn2 = true;
}
void Enemy2::Move(int LastX, int LastY)
{
if(!dbSpriteCollision(id, BLOCKID + 1))
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
}
if(!dbSpriteCollision(id, BLOCKID + 2))
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
}
}
void Enemy2::Uppnge()
{
x = dbSpriteX(enemy2[PosID2].id);
y = dbSpriteY(enemy2[PosID2].id);
if(cSpawn2)
{
Spawn(spawnX, spawnY);
EnemyCount += 1;
cSpawn2 = false;
}
if(!dbSpriteCollision(id, 1))
{
Move(player.x, player.y);
}
else
{
dbPlaySound(PLAYER_HURT);
player.lifes--;
dbDeleteSprite(id);
cSpawn2 = true;
}
}
void Enemy2::Spawn(int SpawnX, int SpawnY)
{
dbSprite(id, spawnX, spawnY, ENEMY2_IMAGE);
}
void Enemy2::DestroyEnemy(int spawntime)
{
int tempX = dbSpriteX(id);
int tempY = dbSpriteY(id);
dbDeleteSprite(id);
}
void Enemy2::Reload()
{
if(!dbSpriteExist(enemy2[PosID2].id))
{
LoadEnemy(PosID2);
}
}
/////////////////////////////////////////////////////////
/*
================================================
ENEMY 3
================================================
*/
void Enemy3::LoadEnemy()
{
id = GetFreeSpriteID() + dbRnd(10000);
if(dbSpriteExist(id))
{
id = GetFreeSpriteID();
}
speed = -2 * round;
score = 100;
hp = 400;
sizeX = 40;
sizeY = 29;
cSpawn3 = true;
}
void Enemy3::Move(int LastX, int LastY)
{
if(!dbSpriteCollision(id, BLOCKID + 1))
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
}
if(!dbSpriteCollision(id, BLOCKID + 2))
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
}
}
void Enemy3::Uppnge()
{
en3.x = dbSpriteX(en3.id);
en3.y = dbSpriteY(en3.id);
if(cSpawn3)
{
Spawn(ENEMY3_X, ENEMY3_Y);
EnemyCount += 1;
cSpawn3 = false;
}
if(!dbSpriteCollision(id, 1))
{
Move(player.x + player.SizeX, player.y + player.SizeY);
}
else
{
player.lifes--;
dbPlaySound(PLAYER_HURT);
dbDeleteSprite(id);
cSpawn3 = true;
}
}
void Enemy3::Spawn(int SpawnX, int SpawnY)
{
dbSprite(id, SpawnX, SpawnY, ENEMY2_IMAGE);
}
void Enemy3::DestroyEnemy(int spawntime)
{
dbDeleteSprite(id);
}
void Enemy3::Reload()
{
if(!dbSpriteExist(en3.id))
{
LoadEnemy();
}
}
////////////////////////////////////////////////////////
/*
================================================
ENEMY 4
================================================
*/
void Enemy4::LoadEnemy()
{
id = GetFreeSpriteID() + dbRnd(10000);
if(dbSpriteExist(id))
{
id = GetFreeSpriteID();
}
speed = -2 * round;
score = 100;
hp = 600;
sizeX = 40;
sizeY = 29;
cSpawn4 = true;
}
void Enemy4::Move(int LastX, int LastY)
{
PointSprite(id, LastX, LastY);
dbMoveSprite(id, speed);
}
void Enemy4::Uppnge()
{
en4.x = dbSpriteX(en4.id);
en4.y = dbSpriteY(en4.id);
if(cSpawn4)
{
Spawn(ENEMY4_X, ENEMY4_Y);
EnemyCount += 1;
cSpawn4 = false;
}
if(!dbSpriteCollision(id, 1))
{
Move(player.x + player.SizeX, player.y + player.SizeY);
}
else
{
player.lifes--;
dbDeleteSprite(id);
dbPlaySound(PLAYER_HURT);
cSpawn4 = true;
}
}
void Enemy4::Spawn(int SpawnX, int SpawnY)
{
dbSprite(id, SpawnX, SpawnY, ENEMY3_IMAGE);
}
void Enemy4::DestroyEnemy(int spawntime)
{
dbDeleteSprite(id);
}
void Enemy4::Reload()
{
if(!dbSpriteExist(en4.id))
{
LoadEnemy();
}
}
void OutputText ( int X, int Y, char* String, DWORD fgColor )
{
ForeColor = g_pGlob->dwForeColor;
g_pGlob->dwForeColor = fgColor;
dbText ( X, Y, String );
g_pGlob->dwForeColor = ForeColor;
}
C++ Medium 3.5/5
www.oryzhon.com <-- My company's website (W.I.P)