like, get the player's location, get a random number between playerX-20 and playerX+20, and another random number between playerY-20 and playerY+20, and shoot to the random coordinate, you can change that 20 to whatever you want
i hope i got what you meant right lol
#include <vector>
using std::vector;
typedef struct _BULLET
{
int imageID;
int SpriteID;
int target_X;
int target_Y;
int damage;
int speed;
int enemySprite
} BULLET;
//..
//..
vector<BULLET> BulletV(0)
//...
//...in the game loop
if ( dbKeyState ( shooting key ) )
{
dbSprite ( SpriteID, playerX, playerY, imageID );
BULLET nbl;
nbl.spriteID = SpriteID;
nbl.imageID = imageID;
nbl.damage = 5;
nbl.speed = 2;
nbl.enemySprite = playertarget;
int X = dbRND ( 40 );
nbl.target_X = targetX-20+X;
int Y = dbRND ( 40 );
nbl.target_Y = targetX-20+Y;
BulletV.push_back ( nbl );
}
//...
//...
for ( int i = 0; i < BulletV.size(); i++ )
{
PointSprite ( target_X, target_Y );
dbMoveSprite ( BulletV[i].speed );
if ( dbSpriteCollision ( BulletV[i].SpriteID, BulletV[i].enemySprite ) )
{BulletV.erase (BulletV.begin()+i);/*hit the target*/}
if ( dbSpriteX(BulletV[i].spriteID) == BulletV[i].target_X) && dbSpriteY (BulletV[i].spriteID) == BulletV[i].target_Y )
{BulletV.erase (BulletV.begin()+i)}
}
alot of syntax errors prolly, but thats just an example, also, using structures and vectors is a good way for making bullets