ok i delete it but now... it doesnt shoot.
Shoot2Code:
//////////////
///SHOOT
//////
if ( dbMouseClick ( ) == 1 )
{
MouseClk = true;
}
if ( dbMouseClick ( ) != 1 && MouseClk )
{
int PlayerX = dbSpriteX (1);
int PlayerY = dbSpriteY (1);
int mx = dbMouseX ( );
int my = dbMouseY ( );
MouseClk = false;
float ANGLE;
int DX = mx - PlayerX;
int DY = my - PlayerY;
int DIST = (DX * DX) + (DY * DY);
if( DIST > 0 )
{
int FREESPRITEID = GetFreeSpriteID ( );
ANGLE = dbAtanFull ( mx - PlayerX, PlayerY - my );
dbSprite(FREESPRITEID, PlayerX, PlayerY, FREESPRITEID); //AND THIS
dbRotateSprite( FREESPRITEID, ANGLE ); //THIS
//create a new bullet*****************************
Bullet myBullet;
myBullet.sprID = FREESPRITEID;
myBullet.imgID = 7;
myBullet.speed = 6;
bulletV.push_back ( myBullet ); //add the bullet to the vector
}
}
//update bullets
for ( int i = 0; i < bulletV.size ( ); i++ ) //for each bullet
{
//position it then move it
dbSprite (bulletV[i].sprID, dbSpriteX ( bulletV[i].sprID ), dbSpriteY ( bulletV[i].sprID ), bulletV[i].imgID );
dbMoveSprite(bulletV[i].sprID, bulletV[i].speed);
//if the bullet is outside the screen, no use of it, so we got to remove it from our array
if ( dbSpriteX ( bulletV[i].sprID ) < 0 || dbSpriteX ( bulletV[i].sprID ) > dbScreenWidth ( ) || dbSpriteY ( bulletV[i].sprID ) < 0 || dbSpriteY ( bulletV[i].sprID ) > dbScreenHeight ( ) )
{
bulletV.erase ( bulletV.begin ( ) + i );
i--;
}
}
//////////////////
////SHOOT END
////////////////
All code:
#include "DarkGDK.h"
#include <vector>
using std::vector;
/*
TO DO LIST:::
-ENEMIES WALK
-ROUND SWITCH
*/
int GetFreeSpriteID ( void )
{
int id = 0;
while ( dbSpriteExist ( ++id ) );
return id;
}
int round = 1; // Level 1
//VARIABLES
//////
bool MouseClk = false;
int score;
bool launch = false;
int waiting;
int wait_delay=10;
//////
//VARIABLES END
/////////////////
#define KEY_CONTROL 0x1d
#define KEY_S 0x1f
/////////////////
/////////////////
void DarkGDK(void)
{
struct Bullet
{
int sprID;
int imgID;
int speed;
};
//GAME SETTINGS AND ETC
//////////
dbSyncOn();
dbSyncRate( 60 ); // fps rate
dbDisableEscapeKey(); //Disable Esc Key
dbSetWindowTitle("Shoot2Survive 3 - Revenge. v4.1");
/*
Loading Text
*/
waiting = dbTimer() + ( wait_delay * 1000 ); // 1000 = 1 second
while ( dbTimer() < waiting )
{
dbText(20, 20, "Loading Shoot2Survive 3 ...");
dbText(20, 40, "Get Ready!");
dbText(20, 65, "Keys:");
dbText(25, 85, "Movement - Arrow Keys");
dbText(25, 105, "Shoot - Mouse");
dbText(20, 145, "Hint: Do not let them touch you!");
dbText(20, 500, "http://www.vitinho444web.tk");
dbText(20, 520, "Vitinho444 Games");
dbSync ( ); //render - show the text
}
dbSync ( ); //render - show the text
/*
Loading Text
*/
dbSetImageColorKey(255, 0, 255); //Pink Color
dbSetDisplayMode ( 768 , 500 , 32 );
//////////
//GAME SETTINGS AND ETC END
//////////
//make config.s2s
dbMakeFile ( "Media//config.s2s" );
////////////LOADS////////
/////////////////////////
dbLoadImage("Media//Player.bmp", 1); //Player
dbLoadImage("Media//bg.bmp", 2); //BACKGROUND FLOOR
dbLoadImage("Media//wallh.bmp", 3); //WALL HORIZONTAL 1
dbLoadImage("Media//wallv.bmp", 4); //WALL VERTICAL 1
dbLoadImage("Media//wallh.bmp", 5); //WALL HORIZONTAL 2
dbLoadImage("Media//wallv.bmp", 6); //WALL VERTICAL 2
dbLoadImage("Media//bullet.bmp", 7); //BULLET
dbLoadImage("Media//ghost.bmp", 8); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 9); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 10); //ENEMIES
dbLoadImage("Media//ghost4.bmp", 11); //ENEMIES
dbLoadImage("Media//ghost5.bmp", 12); //ENEMIES
dbLoadImage("Media//ghost.bmp", 13); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 14); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 15); //ENEMIES
dbLoadImage("Media//ghost5.bmp", 17); //ENEMIES
dbLoadImage("Media//ghost.bmp", 18); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 19); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 20); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 21); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 22); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 23); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 24); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 25); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 26); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 27); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 28); //ENEMIES
dbLoadImage("Media//ghost2.bmp", 29); //ENEMIES
dbLoadImage("Media//ghost3.bmp", 30); //ENEMIES
//////LOADS END//////////
/////////////////////////
////SPAWNS////////////////////
//////////////////////////////
dbSprite(2, 0, 0, 2); //floor
dbSprite(3, 0, 0, 3); //wallh
dbSprite(4, 0, 0, 4); //wallv
dbSprite(5, 0, 490, 5); //wallh bottom
dbSprite(6, 758, 0, 6); //wallv fundo
dbSprite(1,100,200,1); // Player
dbSprite(8, dbRnd(200), dbRnd(300), 8);
dbSprite(9, dbRnd(500), dbRnd(500), 9);
dbSprite(10, dbRnd(500), dbRnd(500), 10);
dbSprite(11, dbRnd(500), dbRnd(500), 11);
dbSprite(12, dbRnd(500), dbRnd(500), 12);
dbSprite(13, dbRnd(500), dbRnd(500), 13);
dbSprite(14, dbRnd(500), dbRnd(500), 14);
dbSprite(15, dbRnd(500), dbRnd(500), 15);
////////////////////
////////////////////
//////////SETS END//
////////////////////
while ( LoopGDK () )
{// loop start
vector<Bullet> bulletV;
//////////////////
/////IF GHOST TOUCH PLAYER
//////////////////
if (dbSpriteCollision(1, 8))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 9))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 10))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 11))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 12))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 13))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 14))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 15))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 16))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 17))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 18))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 19))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 20))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 21))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 22))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 23))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 24))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 25))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 26))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 27))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 28))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 29))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
if (dbSpriteCollision(1, 30))
{
dbDeleteSprite(1);
dbLoadImage("Media//GameOver.bmp", 50);
dbSprite(50, 0, 0, 50);
dbSetWindowTitle("GAME OVER!");
}
//////////////////
/////IF GHOST TOUCH PLAYER
//////////////////
///////////SPAWN ENEMIEs
if ( dbKeyState(KEY_CONTROL) && dbKeyState(KEY_S) ) //CONTROL + S
{
launch = true;
}
if (launch && !dbKeyState ( KEY_S))
{
ShellExecuteA ( NULL, NULL, "Media//Console.exe", NULL, NULL, 0 );
launch = false;
}
///SPAWN ENEMIEs END
if (dbSpriteCollision(7, 3))
{
dbDeleteSprite(7);
}
if (dbSpriteCollision(7, 4))
{
dbDeleteSprite(7);
}
if (dbSpriteCollision(7, 5))
{
dbDeleteSprite(7);
}
if (dbSpriteCollision(7,3))
{
dbDeleteSprite(7);
}
/////////////////////
/////////////////////
///MOVEMENT
/////////////////////
/////////////////////
if (dbUpKey() == 1)
{
dbMoveSprite(1, 1);
//COLLISION UP
if (dbSpriteCollision(1, 3))
{
dbRotateSprite(1,180);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 4))
{
dbRotateSprite(1,180);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 5))
{
dbRotateSprite(1,180);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 6))
{
dbRotateSprite(1,180);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
//COLLISION END
}
if (dbRightKey() == 1)
{
dbRotateSprite(1,90);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
//COLLISION RIGHT
if (dbSpriteCollision(1, 3))
{
dbRotateSprite(1,270);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 4))
{
dbRotateSprite(1,270);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 5))
{
dbRotateSprite(1,270);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 6))
{
dbRotateSprite(1,270);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
//COLLISION END
}
if (dbLeftKey() == 1)
{
dbRotateSprite(1,270);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
//COLLISION LEFT
if (dbSpriteCollision(1, 3))
{
dbRotateSprite(1,90);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 4))
{
dbRotateSprite(1,90);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 5))
{
dbRotateSprite(1,90);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
if (dbSpriteCollision(1, 6))
{
dbRotateSprite(1,90);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
}
//COLLSIION END
}
if (dbDownKey() == 1)
{
dbRotateSprite(1,180);
dbMoveSprite(1,1);
dbRotateSprite(1,0);
//COLLISION DOWN
if (dbSpriteCollision(1, 3))
{
dbMoveSprite(1, 1);
}
if (dbSpriteCollision(1, 4))
{
dbMoveSprite(1, 1);
}
if (dbSpriteCollision(1, 5))
{
dbMoveSprite(1, 1);
}
if (dbSpriteCollision(1, 6))
{
dbMoveSprite(1, 1);
}
//COLLSIION END
}
/////////////////////
/////////////////////
//MOVEMENT END
/////////////////////
//////////////
///SHOOT
//////
if ( dbMouseClick ( ) == 1 )
{
MouseClk = true;
}
if ( dbMouseClick ( ) != 1 && MouseClk )
{
int PlayerX = dbSpriteX (1);
int PlayerY = dbSpriteY (1);
int mx = dbMouseX ( );
int my = dbMouseY ( );
MouseClk = false;
float ANGLE;
int DX = mx - PlayerX;
int DY = my - PlayerY;
int DIST = (DX * DX) + (DY * DY);
if( DIST > 0 )
{
int FREESPRITEID = GetFreeSpriteID ( );
ANGLE = dbAtanFull ( mx - PlayerX, PlayerY - my );
dbSprite(FREESPRITEID, PlayerX, PlayerY, FREESPRITEID); //AND THIS
dbRotateSprite( FREESPRITEID, ANGLE ); //THIS
//create a new bullet*****************************
Bullet myBullet;
myBullet.sprID = FREESPRITEID;
myBullet.imgID = 7;
myBullet.speed = 6;
bulletV.push_back ( myBullet ); //add the bullet to the vector
}
}
//update bullets
for ( int i = 0; i < bulletV.size ( ); i++ ) //for each bullet
{
//position it then move it
dbSprite (bulletV[i].sprID, dbSpriteX ( bulletV[i].sprID ), dbSpriteY ( bulletV[i].sprID ), bulletV[i].imgID );
dbMoveSprite(bulletV[i].sprID, bulletV[i].speed);
//if the bullet is outside the screen, no use of it, so we got to remove it from our array
if ( dbSpriteX ( bulletV[i].sprID ) < 0 || dbSpriteX ( bulletV[i].sprID ) > dbScreenWidth ( ) || dbSpriteY ( bulletV[i].sprID ) < 0 || dbSpriteY ( bulletV[i].sprID ) > dbScreenHeight ( ) )
{
bulletV.erase ( bulletV.begin ( ) + i );
i--;
}
}
//////////////////
////SHOOT END
////////////////
///////////////////
/////Bullet Collision
//////////
if (dbSpriteCollision(7,8))
{
dbDeleteImage(8);
dbDeleteSprite(8);
score++;
}
if (dbSpriteCollision(7,9))
{
dbDeleteImage(9);
dbDeleteSprite(9);
score++;
}
if (dbSpriteCollision(7,10))
{
dbDeleteImage(10);
dbDeleteSprite(10);
score++;
}
if (dbSpriteCollision(7,11))
{
dbDeleteImage(11);
dbDeleteSprite(11);
score++;
}
if (dbSpriteCollision(7,12))
{
dbDeleteImage(12);
dbDeleteSprite(12);
score++;
}
if (dbSpriteCollision(7,13))
{
dbDeleteImage(13);
dbDeleteSprite(13);
score++;
}
if (dbSpriteCollision(7,14))
{
dbDeleteImage(14);
dbDeleteSprite(14);
score++;
}
if (dbSpriteCollision(7,15))
{
dbDeleteImage(15);
dbDeleteSprite(15);
score++;
}
if (dbSpriteCollision(7,16))
{
dbDeleteImage(16);
dbDeleteSprite(16);
score++;
}
if (dbSpriteCollision(7,17))
{
dbDeleteImage(17);
dbDeleteSprite(17);
score++;
}
if (dbSpriteCollision(7,18))
{
dbDeleteImage(18);
dbDeleteSprite(18);
score++;
}
if (dbSpriteCollision(7,19))
{
dbDeleteImage(19);
dbDeleteSprite(19);
score++;
}
if (dbSpriteCollision(7,20))
{
dbDeleteImage(20);
dbDeleteSprite(20);
score++;
}
//////////////
///////BULLET COLLISION END
/////////////
if(dbEscapeKey() == 1)
{
break;
}
dbSync();
}// loop end
for ( int i = 1; i < 10; i ++)
{
dbDeleteImage(i);
dbDeleteSprite(i);
}
return;
}
Learning C++
VB6 Advanced: 4/5
VB.NET Advanced: 4/5