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 / ESP card game!

Years of Service
User Offline
Joined: 30th Nov 2013
Posted: 30th Nov 2013 09:17
I am trying to get a esp card game to work but I am having difficulties. Can anyone help?

// include the Dark GDK header file (
#include "DarkGDK.h"

//Constants to use for the image numbers
const int triangle = 1;
const int square = 2;
const int circle = 3;

//Other constants
const int refreshRate = 60;
const int textX = 319;
const int textY = 120;
const int backDrop = 4;
const int esp_backface = 5;

//Function Prototypes
void setUp();
void displayImages(int [], int);
void shuffle(int [], int);
void swap(int &, int &);
bool mouseFullClick(int &, int &);
bool onSprite(int, int, int);

void DarkGDK ()
//Variables to hold mouse coordinates.
int mouseX, mouseY;

//Create an array to hold the image numbers.
const int SIZE = 3;
int images[SIZE] = {triangle, square, circle};

//Perform setup operations.

//Game Loop
while ( LoopGDK() )
//Get the mouse location.
mouseX = dbMouseX();
mouseY = dbMouseY();

//Display the images.
displayImages(images, SIZE);

//Prompt the user to click on a card.
dbCenterText( textX, textY,"Click on the card that you think is the triangle!");

//Refresh the screen.

//**The setUp function performs setup operations.**
void setUp()
//Load the images.

//Disable auto-refresh and set the refresh rate.

//**Display Image Function**
void displayImages(int images[], int size)
//Variables for the image XY coordinates
int x = 0;
int y = (dbScreenHeight() / 2) - (dbGetImageHeight(images[0]) / 2);

//Display the images.
for (int index = 0; index < size; index ++)
//Display an image
dbPasteImage( images[index], x, y );

//Increase x for the next image.
x+= dbGetImageWidth( images[index] );

//*Shuffle Function**
void shuffle(int numbers [], int size)
//Variables to hold a random subscript
int randomSub;

//Seed the random number generator.
dbRandomize(dbTimer() );

//Setup through the array, swapping each element with ar andom element.
for (int index = 0; index < size; index++)
//Get a random subscript.
randomSub = dbRND(size - 1);

//Swap two elements.
swap( numbers[index], numbers[randomSub] );


//**Swap Function**
void swap(int &a, int &b)
//Assign a to temp.
int temp = a;

//Assign b to a.
a = b;

//Assign temp to b.
b = temp;

//**mouseClick Funtion**
bool mouseFullClick(int &x, int &y)
//Variables to hold the return value.
bool buttonClick = false;

//If the mouse button is pressed, process a full clicking action.
if (dbMouseClick() ==1 )
//Get tte mouse pointer coordiantes.
x = dbMouseX();
y = dbMouseY();

//Wait for the user to release the mouse button.
while (dbMouseClick() ==1)
//Do nothing in this loop.

//Set the buttonClick to true.
buttonClick = true;

//Return true of false to indicate wheather the mouse was clicked.
return buttonClick;

//**onSprite Function**
bool onSprite(int spriteNum, int pointX, int pointY)
//Variables to hold the value to return.
bool insideSprite;

//Get the X coordinate of the sprite's upper-left corner.
int upperX = dbSpriteX(spriteNum) - dbSpriteOffsetX(spriteNum);

//Get the Y coordinate of the sprite's upper-left corner.
int upperY = dbSpriteY(spriteNum) - dbSpriteOffsetY(spriteNum);

//Get the X coordinate of the sprite's lower-right corner.
int lowerX = upperX + dbSpriteWidth(spriteNum);

//Get the Y coordinate of the sprite's lower-right corner.
int lowerY = upperY + dbSpriteHeight(spriteNum);

//Determine whether (pointX, pointY) is inside the sprite's bounding rectangle.
if (pointX >= upperX && pointY >= upperY && pointX <= lowerX && pointY <= lowerY)
insideSprite = true;
insideSprite = false;

//Return the value of insideSprite.
return insideSprite;
The Tall Man
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 2nd Dec 2013 01:15
I've never used sprites in DarkDGK. But I remember reading in this forum some time ago a suggestion that in your case would be to make your cards sprites, and create a sprite that's 1x1 and transparent (or not), that takes the position of your mouse pointer. Then once you detect a mouse click, you can see if the pointer sprite is colliding with a card sprite.

Login to post a reply

Server time is: 2023-11-29 21:48:07
Your offset time is: 2023-11-29 21:48:07