Alright. Im trying to make my first Dark DGK game in 2d so that I can firm up on the basics. However, the basics are giving me some trouble. Here is my whole source 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 )
{
dbSetWindowOff();
dbSetDisplayMode(1440,900,32);
dbHideMouse() ;
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
int color = dbRGB(12,10,12) ;
int anglemod = 1 ;
int movemod = 12 ;
int shotnumber = 4;
int shotnumber1 = 301;
int bullet,wavetime,chance,shottimer,shoottime,bullet1,col ;
int bulletspeed[400] ;
int bulletclass[400] ;
dbColorBackdrop(0,color) ;
dbBox(0,0,40,40) ;
dbGetImage (1,0,0,4,8,1) ;
//dbGetimage (2,0,0,20,20,1) ;
dbLoadImage (\"xboxship.bmp\",2,1) ;
dbLoadImage (\"xboxbaddie.bmp\",3,1) ;
dbLoadImage (\"xboxbaddiegun.bmp\",4,1) ;
//set up the player object
dbSprite(1,dbScreenWidth()/2,dbScreenHeight()/2,2);
dbOffsetSprite(1,dbSpriteWidth(1)/2,dbSpriteHeight(1)/2) ;
dbScaleSprite(1,120) ;
dbMoveSprite(1,dbScreenHeight()/3) ;
dbFlipSprite(1) ;
dbSetSpritePriority(1,3);
//set up the enemy object
dbSprite(2,dbScreenWidth()/2,dbScreenHeight()/2,3) ;
dbOffsetSprite(2,dbSpriteWidth(2)/2,dbSpriteHeight(2)/2) ;
dbSetSpriteDiffuse(2,255,0,0) ;
dbSetSpritePriority(2,2) ;
dbScaleSprite(2,130) ;
//dbSprite(3,dbSpriteX(2),dbSpriteY(2),4) ;
// dbOffsetSprite(3,0,dbSpriteHeight(2)/2) ;
//dbSetSpritePriority(3,3) ;
// our main loop
while ( LoopGDK ( ) )
{
//for (start = 1; start <= 10; start++) {
// dbPrint(dbStr(start));
//}
//take care of player movement
if (dbRightKey()) {
dbRotateSprite(1,dbSpriteAngle(1)+90+anglemod) ;
dbMoveSprite(1,movemod) ;
dbRotateSprite(1,dbSpriteAngle(1)-90+anglemod) ;
}
if (dbLeftKey()) {
dbRotateSprite(1,dbSpriteAngle(1)-90-anglemod) ;
dbMoveSprite(1,movemod) ;
dbRotateSprite(1,dbSpriteAngle(1)+90-anglemod) ;
}
if (dbSpaceKey()&&dbTimer()>shoottime) {
// shoottime=shoottime + 20 ;
dbSprite(shotnumber,dbSpriteX(1),dbSpriteY(1),1) ;
dbOffsetSprite(shotnumber,dbSpriteWidth(shotnumber)/2,dbSpriteHeight(shotnumber)/2) ;
dbRotateSprite(shotnumber,dbSpriteAngle(1)+180) ;
dbScaleSprite(shotnumber,100) ;
dbSetSpriteDiffuse(shotnumber,0,255-dbSpriteScaleX(shotnumber),0) ;
bulletspeed[shotnumber]=3+dbRND(2) ;
shotnumber++ ;
dbMoveSprite(shotnumber,30) ;
bulletclass[shotnumber] = 2 ;
///
if(shotnumber>400) {
shotnumber=4 ;
}
}
//dbRotateSprite(1,dbSpriteAngle(1)+180) ;
//take care of enemy ship
//dbRotateSprite(2,-dbAtanFull(dbSpriteX(1)-dbSpriteX(2),dbSpriteY(1)-dbSpriteY(2))) ;
if (dbTimer()>wavetime) {
wavetime=dbTimer()+300;//+dbRND(100) ;
dbRotateSprite(2,dbSpriteAngle(2)+20) ;//dbRND(359)) ;
//chance=dbRND(4) ;
//dbRandomize(dbTimer());
if(chance==3) {
dbRotateSprite(2,-dbAtanFull(dbSpriteX(1)-dbSpriteX(2),dbSpriteY(1)-dbSpriteY(2))-40) ;
}
}
dbRotateSprite(2,dbSpriteAngle(2)+3) ;
//dbRotateSprite(3,dbSpriteAngle(2));
//shotcreation
//if (dbMouseClick()) {
if (dbTimer()>shottimer) {
shottimer=dbTimer()+5 ;
dbSprite(shotnumber,dbSpriteX(2),dbSpriteY(2),4) ;
dbOffsetSprite(shotnumber,dbSpriteWidth(shotnumber)/2,dbSpriteHeight(shotnumber)/2) ;
dbRotateSprite(shotnumber,dbSpriteAngle(2)+180) ;
dbScaleSprite(shotnumber,100) ;
dbSetSpriteDiffuse(shotnumber,255-dbSpriteScaleX(shotnumber),0,0) ;
bulletspeed[shotnumber]=3+dbRND(2) ;
shotnumber++ ;
bulletclass[shotnumber]=2 ;
if(shotnumber>399) {
shotnumber=4 ;
}
}
//handle bullets
//for (start = 1; start <= 10; start++) {
for (bullet = 4; bullet <= 400; bullet++) {
if (dbSpriteExist(bullet)) {
dbMoveSprite(bullet,bulletspeed[bullet]) ;
col=dbSpriteCollision(bullet,0) ;
if (col!=1 || col!=2) {
dbDeleteSprite(col) ;
}
col=0 ;
}
}
dbSync ( );
}
// return back to windows
return;
}
heres the problem. For testing purposes, I want the player ship (sprite one) and the enemy ship (sprite two) to be invinsible. So when I do all the shot collision detection, its somthing like this.
for (bullet = 4; bullet <= 400; bullet++) {
if (dbSpriteExist(bullet)) {
dbMoveSprite(bullet,bulletspeed[bullet]) ;
col=dbSpriteCollision(bullet,0) ;
if (col!=1 || col!=2) {
dbDeleteSprite(col) ;
}
col=0 ;
}
}
When I go to test it, The shots still blow up the player and the enemy.
So my question is, why did that happen. I clearly coded that (in english)
if col doesnt equal 1 or 2
delete sprite col
endif
but it doesnt seem to do pay any attention to the doesnt equal to?