the game i'm trying to make is a space shoot em up game but the problem i am having is that, the missile/projectile (bolt.png) that my spaceship (space.png) shoots out, acts exactly like the asteroids that i have loaded into the game in that, you (the player) will shoot out a missile than, when the missile reaches the top of the screen it (like the asteroids) comes back down, it is also way larger than it actually is in real life (this does not happen when the asteroids are not there)here is code
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbLoadMusic ( "background music.mp3", 4 );
dbSetDisplayMode ( 1024 , 768 , 32 );
dbSyncOn ( );
dbSyncRate ( 300 );
dbDisableEscapeKey ( );
dbRandomize ( dbTimer ( ) );
dbMaximiseWindow();
dbLoadImage ( "background.jpg", 1 );
dbSprite ( 1, 0, 0, 1 );
for ( int i = 3; i < 30; i++ )
{
dbCreateAnimatedSprite ( i, "sprite.png", 4, 4, i );
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
int g = 2;
int XCord=450;
int YCord=460;
dbLoadImage("spaceship.png", g);
dbSprite(g, XCord, YCord, g);//this will display the object
dbPlayMusic(4);
dbLoopMusic(4);
int b = 5;
dbLoadImage ("bolt.png", b);
int AC = 50;
while ( LoopGDK () )
{
for ( int i = 2; i < 30; i++ )
{
// move the sprite down and play its animation
// moving from frame 1 to 16 with a delay of 60 ms
dbMoveSprite ( i, -2 );
dbPlaySprite ( i, 1, 16, 60 );
// check the position of the sprite, if it has gone off scren
// then reposition it back to the top
if ( dbSpriteY ( i ) > 768 )
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
if(dbDownKey())//move down
{
YCord++;
YCord++;
YCord++;
YCord++;
YCord++;
}
if(dbUpKey())//move up
{
YCord=YCord-5;
}
if(dbRightKey())//move right
{
XCord++;
XCord++;
XCord++;
XCord++;
XCord++;
}
if(dbLeftKey())//move left
{
XCord=XCord-5;
}
dbSprite(g, XCord, YCord, g);//Set The Cordinates To XCord And YCord
{if (XCord > dbScreenWidth())
XCord = 0;
if (XCord < 0)
XCord = dbScreenWidth();
if (YCord > dbScreenHeight())
YCord = 0;
if (YCord < 0)
YCord = dbScreenHeight();
}
if( dbSpaceKey())
{
if(AC == 60)
{
dbSprite(b, XCord, YCord, b);
AC = 1;
}
}
if(AC < 60)//If the projectile is active,
{
dbMoveSprite(b, 18);//then make it move
AC++;
}
// here we check if the escape key has been pressed, when it has
// we will break out of the loop
if ( dbEscapeKey ( ) )
break;
// here we make a call to update the contents of the screen
dbSync ( );
}
// when the user presses escape the code will break out to this location
// and we can free up any previously allocated resources
// delete all the sprites
for ( int i = 1; i < 30; i++ )
dbDeleteSprite ( i );
// delete the backdrop image
dbDeleteImage ( 1 );
// and now everything is ready to return back to Windows
return;
}
attatched is a picture