OK Even weirder the circles work fine:
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
// Circle-drawing functions which:
// 1. make circles visible on the screen for those people who have the dbCircle bug,
// 2. make it possible to draw filled circles.
// The algorythm is copied from this article by John Kennedy:
// http://homepage.smc.edu/kennedy_john/BCIRCLE.PDF
// For filled circle: connect the calculated points
// with horizontal lines.
void PlotCircleLines(int CX, int CY, int X, int Y)
{
dbLine(CX + X, CY + Y, CX - X, CY + Y);
dbLine(CX - X, CY - Y, CX + X, CY - Y);
dbLine(CX + Y, CY + X, CX + Y, CY - X);
dbLine(CX - Y, CY + X, CX - Y, CY - X);
}
// For unfilled circle: plot the outline.
void PlotCirclePoints(int CX, int CY, int X, int Y)
{
// These should be dots, but dbDot would disappear as well,
// so we draw one-pixel-long lines.
dbLine(CX + X, CY + Y, CX + X + 1, CY + Y + 1);
dbLine(CX - X, CY + Y, CX - X + 1, CY + Y + 1);
dbLine(CX - X, CY - Y, CX - X + 1, CY - Y + 1);
dbLine(CX + X, CY - Y, CX + X + 1, CY - Y + 1);
dbLine(CX + Y, CY + X, CX + Y + 1, CY + X + 1);
dbLine(CX - Y, CY + X, CX - Y + 1, CY + X + 1);
dbLine(CX - Y, CY - X, CX - Y + 1, CY - X + 1);
dbLine(CX + Y, CY - X, CX + Y + 1, CY - X + 1);
}
// Parameters: center point coordinates, radius, filled or not.
void drawCircle(int CX, int CY, int R, bool Filled)
{
int X, Y, XChange, YChange, RadiusError;
X = R;
Y = 0;
XChange = 1 - 2 * R;
YChange = 1;
RadiusError = 0;
while (X >= Y)
{
if (Filled) PlotCircleLines(CX, CY, X, Y);
else PlotCirclePoints(CX, CY, X, Y);
Y++;
RadiusError += YChange;
YChange += 2;
if (2 * RadiusError + XChange > 0)
{
X--;
RadiusError += XChange;
XChange += 2;
}
}
}
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// set ink & background colour
DWORD foreground1 = dbRGB(60,60,60);
DWORD background1 = dbRGB(250,250,250);
dbInk(foreground1,background1);
int x=0;
int y=0;
// board array
int aBoard[3][3];
aBoard[1][0] = 1;
aBoard[0][0] = 2;
aBoard[2][1] = 2;
aBoard[1][1] = 2;
// our main loop
while ( LoopGDK ( ) )
{
dbCLS (background1);
for(x=0; x<=3; x++)
{
dbLine(20,20+(x*100),320,20+(x*100));
dbLine(20+(x*100),20,20+(x*100),320);
}
for(x=0; x<=2; x++)
{
for(y=0; y<=2; y++)
{
// find mouse position.
if(dbMouseX()>(20+x*100) && dbMouseX()<(120+x*100) && dbMouseY()>(20+y*100) && dbMouseY()<(120+y*100))
{
// if the mouse is over a grid square draw a shaded box on it.
dbBox(21+(x*100),21+(y*100),120+(x*100),120+(y*100),dbRGB(200,30,30),dbRGB(200,100,100),dbRGB(200,100,100),dbRGB(200,200,200));
}
if(aBoard[x][y]==1)
{
// draw crosses
dbLine(30+(x*100),30+(y*100),110+(x*100),110+(y*100));
dbLine(110+(x*100),30+(y*100),30+(x*100),110+(y*100));
}
if(aBoard[x][y]==2)
{
// draw noughts
drawCircle(70+(x*100),70+(y*100),40,0);
}
//drawCircle(100,100,60,0);
}
}
// update the screen
dbSync ( );
}
// return back to windows
return;
}
(circle function from
http://forum.thegamecreators.com/?m=forum_view&t=158250&b=22&p=0)
EDIT: You were right. How odd. I assumed that unless otherwise declared, variables were 0. That wouldn't explain why the circles weren't affected if it was just completely random numbers. Or would it. Oh well thanks for the help mate you're a legend I had no idea what was going on there.
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
// Circle-drawing functions which:
// 1. make circles visible on the screen for those people who have the dbCircle bug,
// 2. make it possible to draw filled circles.
// The algorythm is copied from this article by John Kennedy:
// http://homepage.smc.edu/kennedy_john/BCIRCLE.PDF
// For filled circle: connect the calculated points
// with horizontal lines.
void PlotCircleLines(int CX, int CY, int X, int Y)
{
dbLine(CX + X, CY + Y, CX - X, CY + Y);
dbLine(CX - X, CY - Y, CX + X, CY - Y);
dbLine(CX + Y, CY + X, CX + Y, CY - X);
dbLine(CX - Y, CY + X, CX - Y, CY - X);
}
// For unfilled circle: plot the outline.
void PlotCirclePoints(int CX, int CY, int X, int Y)
{
// These should be dots, but dbDot would disappear as well,
// so we draw one-pixel-long lines.
dbLine(CX + X, CY + Y, CX + X + 1, CY + Y + 1);
dbLine(CX - X, CY + Y, CX - X + 1, CY + Y + 1);
dbLine(CX - X, CY - Y, CX - X + 1, CY - Y + 1);
dbLine(CX + X, CY - Y, CX + X + 1, CY - Y + 1);
dbLine(CX + Y, CY + X, CX + Y + 1, CY + X + 1);
dbLine(CX - Y, CY + X, CX - Y + 1, CY + X + 1);
dbLine(CX - Y, CY - X, CX - Y + 1, CY - X + 1);
dbLine(CX + Y, CY - X, CX + Y + 1, CY - X + 1);
}
// Parameters: center point coordinates, radius, filled or not.
void drawCircle(int CX, int CY, int R, bool Filled)
{
int X, Y, XChange, YChange, RadiusError;
X = R;
Y = 0;
XChange = 1 - 2 * R;
YChange = 1;
RadiusError = 0;
while (X >= Y)
{
if (Filled) PlotCircleLines(CX, CY, X, Y);
else PlotCirclePoints(CX, CY, X, Y);
Y++;
RadiusError += YChange;
YChange += 2;
if (2 * RadiusError + XChange > 0)
{
X--;
RadiusError += XChange;
XChange += 2;
}
}
}
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// set ink & background colour
DWORD foreground1 = dbRGB(60,60,60);
DWORD background1 = dbRGB(250,250,250);
dbInk(foreground1,background1);
int x=0;
int y=0;
// board array
int aBoard[3][3];
for(x=0; x<=2; x++)
{
for(y=0; y<=2; y++)
{
aBoard[x][y] = 0;
}
}
aBoard[1][0] = 1;
aBoard[0][0] = 2;
aBoard[2][1] = 2;
aBoard[1][1] = 2;
// our main loop
while ( LoopGDK ( ) )
{
dbCLS (background1);
for(x=0; x<=3; x++)
{
dbLine(20,20+(x*100),320,20+(x*100));
dbLine(20+(x*100),20,20+(x*100),320);
}
for(x=0; x<=2; x++)
{
for(y=0; y<=2; y++)
{
// find mouse position.
if(dbMouseX()>(20+x*100) && dbMouseX()<(120+x*100) && dbMouseY()>(20+y*100) && dbMouseY()<(120+y*100))
{
// if the mouse is over a grid square draw a shaded box on it.
dbBox(21+(x*100),21+(y*100),120+(x*100),120+(y*100),dbRGB(200,30,30),dbRGB(200,100,100),dbRGB(200,100,100),dbRGB(200,200,200));
}
if(aBoard[x][y]==1)
{
// draw crosses
dbLine(30+(x*100),30+(y*100),110+(x*100),110+(y*100));
dbLine(110+(x*100),30+(y*100),30+(x*100),110+(y*100));
}
if(aBoard[x][y]==2)
{
// draw noughts
drawCircle(70+(x*100),70+(y*100),40,0);
}
//drawCircle(100,100,60,0);
}
}
// update the screen
dbSync ( );
}
// return back to windows
return;
}
Still showing 2 crosses/circles offset by about a pixel until I move the mouse cursor over the grid though... No idea what's causing that.
"A West Texas girl, just like me"
-Bush