ok lol people are probably getting sick of me but..... righteo here is my problems
1. the missile in my game will not disapear when it collides with the asteroid no matter what i do (i tried dbhidesprite, dbdeletesprite and i tried just plain old repositioning it)
2. i don't know how to make an explosion out of all of the pictures i have please help here is code:
main.h:
#define MAX_BULLETS 3
#define FIREDELAY 10;
void _Initialise(void);
void _ProcessInput(void);
void _Initiate(void);
void _CloseDown(void);
void CreateBullet(void);
extern int g;
extern int XCord;
extern int YCord;
extern int b;
extern int AC;
extern char score;
extern long Bullets[];
extern long BulletsXPos[];
extern long FireDelay;
main.cpp
#include "DarkGDK.h"
#include "Main.h"
char score;
int b = 78;
int g = 2;
int XCord=450;
int YCord=460;
int AC = 50;
long Bullets[MAX_BULLETS];
long BulletsXPos[MAX_BULLETS];
long FireDelay;
void DarkGDK ( void )
{
_Initialise();
while ( LoopGDK ())
{
_ProcessInput(); // Get current state of keys/mouse
_Initiate();
dbSync();
dbHideMouse();
if (dbEscapeKey()) {
_CloseDown();
return;
}
}
}
input.cpp
#include "DarkGDK.h"
#include "Main.h"
char score;
int b = 78;
int g = 2;
int XCord=450;
int YCord=460;
int AC = 50;
long Bullets[MAX_BULLETS];
long BulletsXPos[MAX_BULLETS];
long FireDelay;
void DarkGDK ( void )
{
_Initialise();
while ( LoopGDK ())
{
_ProcessInput(); // Get current state of keys/mouse
_Initiate();
dbSync();
dbHideMouse();
if (dbEscapeKey()) {
_CloseDown();
return;
}
}
}
initiate.cpp
#include "DarkGDK.h"
#include "Main.h"
void _Initiate(void)
//asteroid, missile and ship collision detection
{
for (long nLoop = 0; nLoop < MAX_BULLETS; nLoop ++)
if (Bullets[nLoop])
{dbSprite(nLoop + b, BulletsXPos[nLoop], Bullets[nLoop], b);
}
else
{
dbHideSprite(nLoop + b);
}
for ( int i = 3; i < 60; 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 (dbSpriteHit(b, i)==1)
{
dbPlaySound (41);
dbSprite ( 82 , dbSpriteX ( i ) , dbSpriteY ( i ) , 82); dbSprite ( 82 , dbSpriteX ( i ) , dbSpriteY ( i ) , 82);
dbSprite ( 83 , dbSpriteX ( i ) , dbSpriteY ( i ) , 83);
dbSprite ( 84 , dbSpriteX ( i ) , dbSpriteY ( i ) , 84);
dbSprite ( 85 , dbSpriteX ( i ) , dbSpriteY ( i ) , 85);
dbSprite ( 86 , dbSpriteX ( i ) , dbSpriteY ( i ) , 86);
dbSprite ( 87 , dbSpriteX ( i ) , dbSpriteY ( i ) , 87);
dbSprite ( 88 , dbSpriteX ( i ) , dbSpriteY ( i ) , 88);
dbSprite ( 89 , dbSpriteX ( i ) , dbSpriteY ( i ) , 89);
dbSprite ( 90 , dbSpriteX ( i ) , dbSpriteY ( i ) , 90);
dbSprite ( 91 , dbSpriteX ( i ) , dbSpriteY ( i ) , 91);
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
score = score + 1;
}
}
}
initialise.cpp
#include "DarkGDK.h"
#include "Main.h"
void _Initialise(void)
{
dbText ( 210 , 230, "Welcome To DEEPSCPACE");
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSync ( );
dbSyncOn ( );
dbSyncRate ( 60 );
dbDisableEscapeKey ( );
dbRandomize ( dbTimer ( ) );
dbMaximiseWindow();
dbSetWindowTitle ("DeepSpace");
dbLoadSound ( "shoot.wav", 5);
dbLoadSound ("explode.wav", 41);
dbLoadMusic ( "background music.mp3", 4 );
dbSetDisplayMode ( 1024 , 768 , 32 );
dbLoadSound ( "jet.wav", 16);
dbLoadImage ( "background[1].png", 1 );
dbSprite ( 1, 0, 0, 1 );
for ( int i = 3; i < 60; i++ )
{
dbCreateAnimatedSprite ( i, "sprite.png", 4, 4, i );
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
dbLoadImage("spaceship.png", g);
dbSprite(g, XCord, YCord, g);//this will display the object
dbPlayMusic(4);
dbLoopMusic(4);
dbPlaySound(16);
dbLoopSound(16);
dbLoadImage ("bolt.png", b);
for (long nLoop = 0; nLoop < MAX_BULLETS; nLoop++)
Bullets[nLoop] = -1;
dbLoadImage ( "boom0001.png" , 81 );
dbLoadImage ( "boom0002.png" , 82 );
dbLoadImage ( "boom0003.png" , 83 );
dbLoadImage ( "boom0004.png" , 84 );
dbLoadImage ( "boom0005.png" , 85 );
dbLoadImage ( "boom0006.png" , 86 );
dbLoadImage ( "boom0007.png" , 87 );
dbLoadImage ( "boom0008.png" , 88 );
dbLoadImage ( "boom0009.png" , 89 );
dbLoadImage ( "boom0010.png" , 90 );
dbLoadImage ( "boom0011.png" , 91 );
}
Close Down.cpp
#include "DarkGDK.h"
#include "Main.h"
void _CloseDown(void)
{
dbSync ( );
for ( int i = 1; i < 30; i++ )
dbDeleteSprite ( i );
dbDeleteImage ( 1 );
}
any help would be great as this is my first game and (once i complete it) i'll use it as a reference for any other games i may or may not make....