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 / Creating and using sprites: ESP Game

Author
Message
Chiang Zuki Productions
11
Years of Service
User Offline
Joined: 11th Jun 2012
Location:
Posted: 12th Jun 2012 00:54
I've been assigned to create an "ESP Game" here's what it says:

"Three cards are shown face down. Internally, the program should randomly select values for each card (one triangle, one square, and one circle) The user should be instructed to use the mouse to select which card is the triangle. The selected card should then be revealed. Repeat this 10 times and then display the number of times the user correctly identifies the triangle card."

I'm new to using dark gdk, so i'm taking this a step at a time. So far i'm just trying to load and create the sprites first. Below is my code:

#include "DarkGDK.h"


//Function Prototypes
void setup();



//Main Function
void DarkGDK()
{

dbWaitMouse();
}


//Load card images and create sprites
void setup()
{
dbLoadImage("esp_backface_A.bmp",1);
dbLoadImage("esp_backface_B",2);
dbLoadImage("esp_backface_C",3);
dbLoadImage("esp_backface_D",4);
dbLoadImage("esp_circle",5);
dbLoadImage("esp_square",6);
dbLoadImage("esp_triangle",7);

dbSprite(1,200,200,1);




}



Can someone tell me why I can't see the sprite i tried to display, and give me some tips on how to create this game? Thanks
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 12th Jun 2012 02:30
You need to call dbSync() after doing anything that will change the frame buffer (such as creating the new sprite in this instance).
The dbSync function basically performs all operations associated with rendering (the current camera view) and does not simply swap pixel buffers, something that might be worth to note.

The standard program layout continuously calls dbSync() in a loop (the "game loop", which runs until your game / program finishes). There can of course be situations where it is desirable to handle this in other ways, but that should be the general approach that is what you want to do most of the time. Also I don't think the window is redrawn with the last rendered image so even though it might seem that you could just slap in a dbSync() call right before dbWaitMouse() in your code there that might not necessarily provide a constant view of the sprite until the program finishes.


"Why do programmers get Halloween and Christmas mixed up?"
Chiang Zuki Productions
11
Years of Service
User Offline
Joined: 11th Jun 2012
Location:
Posted: 14th Jun 2012 19:28
Thanks, i'll give that a try and see what it does.

Login to post a reply

Server time is: 2024-03-28 21:48:23
Your offset time is: 2024-03-28 21:48:23