Hi I have to implement a game where the user has to move one object to a given goal using the arrow keys. I have to use sprites for my moving object and for your goal. Use an image as background. When the sprite touches the goal it must display a text telling the user he has complete the game. This is what I have so far
#include "DarkGDK.h"
const int superman_starting_X =200;
const int superman_starting_Y = 100;
void CreateSprites();
void getsupermancoordinates(int &, int &);
void DarkGDK()
{
int supermanX =superman_starting_X;
int supermanY =superman_starting_Y;
dbSyncOn();
dbSyncRate(60);
CreateSprites();
while(LoopGDK())
{
getsupermancoordinates(supermanX, supermanY);
dbSprite(2, supermanX, supermanY, 2);
dbSync();
}
}
void CreateSprites()
{
dbSetImageColorKey(255,255,255);
dbLoadImage("clouds.png", 1);
dbLoadImage("superman.bmp", 2);
dbSprite(1,0,0,1);
dbSprite(2,200,100,2);
}
void getsupermancoordinates(int &x, int &y)
{
if(dbUpKey())
{
y--;
}
if(dbDownKey())
{
y++;
}
if(dbLeftKey())
{
x--;
}
if(dbRightKey())
{
x++;
}
}
My sprite is an image of superman flying around space.
The professor gave us an example http://www.sci.brooklyn.cuny.edu/~dzhu/cs151/Homework%204.htm