Posted: 3rd Jun 2011 15:38
hi all, I'm a new beginner for using Dark GDK..
and I'm doing a memory game..
I drew all the cards and when I click on one of them it rotates..
but I don't know how to compare two pictures with each other and how to relate the picture underneath the card to the card itself..
here's the code I did so far..
#include "DarkGDK.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void LoadImage();
void Rotate();
const int REFRESH_RATE = 60;
const int s = 14;
const int stat=15;
const int statue=16;
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbDisableEscapeKey ( );
const int SIZE = 4;// Refresh rate
dbRandomize ( dbTimer ( ) );
LoadImage();
while ( LoopGDK ( ) )
{
Rotate();
dbSync ( );
}
return;
}
//----------------------------------------------------------
void LoadImage()
{
dbLoadImage("stat.jpg",stat);
dbSprite(stat,60,50,stat);
dbLoadImage("statue.jpg",statue);
dbSprite(statue,190,160,statue);
dbLoadImage("square.bmp", s);
dbSprite(1,30,20,s);
dbSprite(2,150,20,s);
dbSprite(3,270,20,s);
dbSprite(4,390,20,s);
dbSprite(5,30,120,s);
dbSprite(6,150,120,s);
dbSprite(7,270,120,s);
dbSprite(8,390,120,s);
dbSprite(9,30,220,s);
dbSprite(10,150,220,s);
dbSprite(11,270,220,s);
dbSprite(12,390,220,s);
}
//-----------------------------------------------------------
void Rotate()
{
dbLoadImage("pointer.png",150);
dbSprite(150,dbMouseX(),dbMouseY(),150);
dbHideSprite(150);
if (dbSpriteCollision(150,1)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(1,dbSpriteWidth(2)/2,dbSpriteHeight(2)/2);
}
else if (dbSpriteCollision(150,2)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(2,dbSpriteWidth(2)/2,dbSpriteHeight(2)/2);
}
else if (dbSpriteCollision(150,3)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(3,dbSpriteWidth(3)/2,dbSpriteHeight(3)/2);
}
else if (dbSpriteCollision(150,4)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(4,dbSpriteWidth(4)/2,dbSpriteHeight(4)/2);
}
else if (dbSpriteCollision(150,5)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(5,dbSpriteWidth(5)/2,dbSpriteHeight(5)/2);
}
else if (dbSpriteCollision(150,6)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(6,dbSpriteWidth(6)/2,dbSpriteHeight(6)/2);
}
else if (dbSpriteCollision(150,7)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(7,dbSpriteWidth(7)/2,dbSpriteHeight(7)/2);
}
else if (dbSpriteCollision(150,8)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(8,dbSpriteWidth(8)/2,dbSpriteHeight(8)/2);
}
else if (dbSpriteCollision(150,9)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(9,dbSpriteWidth(9)/2,dbSpriteHeight(9)/2);
}
else if (dbSpriteCollision(150,10)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(10,dbSpriteWidth(10)/2,dbSpriteHeight(10)/2);
}
else if (dbSpriteCollision(150,11)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(11,dbSpriteWidth(11)/2,dbSpriteHeight(11)/2);
}
else if (dbSpriteCollision(150,12)==1 && dbMouseClick()==1)
{
dbWait(250);
dbOffsetSprite(12,dbSpriteWidth(12)/2,dbSpriteHeight(12)/2);
}
}
please reply me as fast as you can...thank you