Hello,
I've recently started C++ and I was hoping to make a maze game. The user will rotate the maze with the 'left' and 'right' arrow keys and the ball will move accordingly. I can do that with a load of physics, no bother. But when I create the 'maze' image the background - the free space where the ball moves around in isn't free at all. So when I place the ball in the maze it is always touching a wall and won't move at all.
Here's the code
#include "darkGDK.h"
void DarkGDK (void)
{
dbSetWindowTitle("The Loggerhead's Labyrinth");
dbSetDisplayMode (1024,768,32);
dbSetWindowPosition(0,0);
dbSyncOn();
dbSyncRate(60);
dbDisableEscapeKey();
dbSetImageColorKey(255,0,255);
dbLoadImage("maze.bmp",1);
dbLoadImage("ball.bmp",2);
dbSprite(1,512,384,1);
dbSprite(2,512,384,2);
dbOffsetSprite (1,(dbSpriteWidth(1))/2,(dbSpriteHeight(1))/2);
dbOffsetSprite (2,(dbSpriteWidth(2))/2,(dbSpriteHeight(2))/2);
dbMaximiseWindow();
while(LoopGDK())
{
if(dbRightKey() == 1)
{
dbRotateSprite(1,dbSpriteAngle(1)+1);
}
if(dbLeftKey() == 1)
{
dbRotateSprite(1,dbSpriteAngle(1)-1);
}
if(dbEscapeKey() == 1)
{
break;
}
if(dbSpriteCollision(1,2))
{
dbMoveSprite(2,1);
}
dbSync();
}
}
Is there a way of setting the background to transparent in the "dbSetImageColorKey(255,0,255);" or do I need to do I need to save the picture in a special way? Or is there something I can do in the collision line "if(dbSpriteCollision(1,2))"?
I have plenty of question, just no answers. I really need some answers
Thanks.