Ok so I have been attemping to put together a game where you move a airplane up and down the screen to pop balloons moving across the screen but I have had a snag cause when I run it I just get a black screen that wont close....suggestions?
#include "DarkGDK.h"
const int AIRPLANE_IMAGE = 1;
const int AIRPLANE_SPRITE = 1;
const int BACKGROUND_IMAGE = 2;
const int BACKGROUND_SPRITE = 2;
const int RED_IMAGE = 3;
const int RED_SPRITE = 3;
const int GREEN_IMAGE = 4;
const int GREEN_SPRITE = 4;
const int INTRO_IMAGE = 5;
const int REFRESH_RATE = 60;
const int POP_SOUND = 1;
const int INTRO_SOUND = 2;
const int MAX_BALLOONS = 50;
void loadContent();
void intro();
void setup(int &,int &,int &,int &);
void movingAirplane(int &);
void movingBalloons(int &,int &);
void collisionDetection(int &,int &);
void summaryScreen(int &, int &);
void DarkGDK()
{
int airplaneX,airplaneY;
int balloonY,balloonX;
int popped,missed;
loadContent();
intro();
setup(balloonX,balloonY,airplaneX,airplaneY);
while (LoopGDK())
{
movingAirplane(airplaneY);
movingBalloons(balloonX,balloonY);
collisionDetection(balloonX,balloonY);
}
summaryScreen(popped,missed);
}
void loadContent()
{
dbLoadImage("airplane.bmp",AIRPLANE_IMAGE);
dbLoadImage("skybackground.bmp",BACKGROUND_IMAGE);
dbLoadImage("redballoon.bmp",RED_IMAGE);
dbLoadImage("greenballoon.bmp",GREEN_IMAGE);
dbLoadImage("intro.bmp",INTRO_IMAGE);
dbLoadSound("balloonpopping.wav",POP_SOUND);
dbLoadSound("intromusic.wav",INTRO_SOUND);
}
void intro()
{
dbSetWindowTitle("Airplane Game");
dbLoopMusic(INTRO_SOUND);
dbPasteImage(INTRO_IMAGE,0,0);
dbWaitKey();
dbStopMusic(INTRO_SOUND);
dbCLS();
dbSync();
dbSyncRate(REFRESH_RATE);
}
void setup(int &balloonX,int &balloonY,int &airplaneX,int &airplaneY)
{
int spriteNum;
dbSprite(BACKGROUND_SPRITE,0,0,BACKGROUND_IMAGE);
dbSprite(AIRPLANE_SPRITE,0,0,AIRPLANE_IMAGE);
dbSprite(RED_SPRITE,0,0,RED_IMAGE);
dbSprite(GREEN_SPRITE,0,0,GREEN_IMAGE);
dbHideSprite(GREEN_SPRITE);
dbHideSprite(RED_SPRITE);
balloonX = 640;
dbRandomize(dbTimer());
balloonY = dbRND(dbScreenHeight());
airplaneX = 0;
dbRandomize(dbTimer());
airplaneY = dbRND(dbScreenHeight());
for(int count = 0; count < MAX_BALLOONS; count++)
{
spriteNum = 100 + count;
dbCloneSprite(RED_SPRITE, spriteNum);
dbCloneSprite(GREEN_SPRITE, spriteNum);
dbSprite(spriteNum,0,dbSpriteHeight(RED_SPRITE) / 4 * count,RED_IMAGE);
dbSprite(spriteNum,0,dbSpriteHeight(GREEN_SPRITE) / 2 * count,RED_IMAGE);
}
}
void movingAirplane(int &airplaneY)
{
if (dbUpKey())
{
if(airplaneY<=0)
{
airplaneY-=5;
}
}
if (dbDownKey())
{
if(airplaneY>=480)
{
airplaneY+=5;
}
}
}
void movingBalloons(int &balloonX,int &balloonY)
{
dbRandomize(dbTimer());
balloonY = dbRND(dbScreenWidth());
balloonX = 640;
dbSprite(RED_SPRITE,balloonX,balloonY,RED_IMAGE);
dbSprite(GREEN_SPRITE,balloonX,balloonY,GREEN_IMAGE);
if(balloonY>=0)
{
balloonX-=5;
}
if(balloonX<0)
{
dbSprite(RED_SPRITE,balloonX,balloonY,RED_IMAGE);
}
}
void collisionDetection(int &balloonX,int &balloonY)
{
dbRandomize(dbTimer());
balloonY = dbRND(dbScreenHeight());
balloonX = 640;
if(dbSpriteCollision(RED_SPRITE,AIRPLANE_SPRITE))
{
dbPlaySound(POP_SOUND);
dbSprite(RED_SPRITE,balloonX,balloonY,RED_IMAGE);
}
if(dbSpriteCollision(GREEN_SPRITE,AIRPLANE_SPRITE))
{
dbPlaySound(POP_SOUND);
dbSprite(GREEN_SPRITE,balloonX,balloonY,GREEN_IMAGE);
}
}
void summaryScreen(int &popped,int &missed)
{
dbSyncOff();
dbCLS();
dbSetTextSize(36);
dbCenterText(dbScreenWidth() / 2, 100, "GAME OVER!");
dbWait(4000);
for(int poppedCount = 0; poppedCount <= popped; poppedCount++)
{
dbCLS();
dbPasteImage(RED_IMAGE, 200, 240);
dbPasteImage(GREEN_IMAGE, 300, 240);
dbCenterText(dbScreenWidth() / 2,
100, "GAME RESULTS");
dbText(240,240,"x");
dbText(380,240,"x");
dbText(260,240,dbStr(poppedCount));
dbText(400,240, dbStr(missed) );
dbWait(2000);
dbCenterText(dbScreenWidth() / 2,
400, dbStr(poppedCount * 100));
}
if (popped == MAX_BALLOONS)
{
dbCenterText(dbScreenWidth() / 2,200, "PERFECT SCORE!");
dbWait(2000);
}
dbWaitKey();
}