Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Card game issues

Author
Message
RichSalmer
5
Years of Service
User Offline
Joined: 5th Dec 2013
Location:
Posted: 5th Dec 2013 00:24
I'm having some issues here getting anything to display. I worked on this while I was at work just using notepad and had no compiler, thought it all looked decent but when I start it up just get a black screen and a non-responsive window. Can anyone take a quick scan and maybe give a few pointers?


#include "DarkGDK.h"

bool mouseFullClick(int &, int &);//mouseclick function prototype
bool onSprite(int, int, int);

const int NUM_GUESS = 10;//constant value for the array
const int REFRESH_RATE = 60;
const int TRIANGLE_IMAGE = 1;
const int SQUARE_IMAGE = 2;
const int CIRCLE_IMAGE = 3;
const int CARD_IMAGE1 = 4;
const int CARD_IMAGE2 = 5;
const int CARD_IMAGE3 = 6;
const int BACKGROUND_IMAGE = 9;
const int CARD_SPRITE1 = 1;
const int CARD_SPRITE2 = 2;
const int CARD_SPRITE3 = 3;
const int CARD_X1 = 10;
const int CARD_X2 = 220;
const int CARD_X3 = 430;
const int CARD_Y = 100;

void DarkGDK ()
{

int mouseX, mouseY;//variables to hold mouse pointer's X and Y
int guess[NUM_GUESS];//array to store the guesses
dbLoadImage("background.png", 1);//place the background
while ( LoopGDK() )
{
dbSyncOn();

dbPasteImage(4, 10, 100, 0);//card 1
dbPasteImage(5, 220, 100, 0);//card 2
dbPasteImage(6, 430, 100, 0);//card 3


}//end of main while loop

dbWaitKey();
}




void setUp()
{

dbLoadImage("triangle.png", TRIANGLE_IMAGE);
dbLoadImage("square.png", SQUARE_IMAGE);
dbLoadImage("circle.png", CIRCLE_IMAGE);
dbLoadImage("card.png", CARD_IMAGE1);
dbLoadImage("card.png", CARD_IMAGE2);
dbLoadImage("card.png", CARD_IMAGE3);
dbLoadImage("background.png", BACKGROUND_IMAGE);

dbSprite(CARD_SPRITE1, CARD_X1, CARD_Y, 4);
dbSprite(CARD_SPRITE2, CARD_X2, CARD_Y, 5);
dbSprite(CARD_SPRITE3, CARD_X3, CARD_Y, 6);


dbSyncOn();
dbSyncRate(REFRESH_RATE);
}

bool mouseFullClick(int &x, int&y)
{
bool buttonClick = false;

if ( dbMouseClick() == 1)
{
x = dbMouseX();
y = dbMouseY();

while ( dbMouseClick() == 1)
{
//nothing happens
}
buttonClick = true;
}
return buttonClick;
}

bool onSprite(int spriteNum, int pointX, int pointY)
{
bool insideSprite;

int upperX = dbSpriteX(spriteNum) - dbSpriteOffsetX(spriteNum);

int upperY = dbSpriteY(spriteNum) - dbSpriteOffsetY(spriteNum);

int lowerX = upperX + dbSpriteWidth(spriteNum);

int lowerY = upperY + dbSpriteHeight(spriteNum);

if (pointX >= upperX && pointY >= upperY &&
pointX <= lowerX && pointY <= lowerY)
{
insideSprite = true;
}
else
{
insideSprite = false;
}

return insideSprite;
}
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 6th Dec 2013 01:58
You should only call dbSyncOn() once (or if you need to switch from sync on / off and back again); what you probably meant to put in your main loop is dbSync(). This will render the scene and present it to the screen. You don't have to, but you probably want to issue the sync call after you've done all visual movements / etc. updates in the loop cycle too, or what you'll see will always be one frame after the actual state of the game.

Also, use the [ code ] [ /code ] tags to get your pasted code to have proper intendation; makes it much easier to read.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2019-09-21 11:49:56
Your offset time is: 2019-09-21 11:49:56