I'm trying to make Sierpinski triangles. Anyone take a look at the code and see what I'm doing wrong? >_<
#include "DarkGDK.h"
//F U N C T I O N P R O T O T Y P E S
void screenSetup(); //Set up the screen
void paint(); //Paint the screen
void recurFunc1(int, int, int); //
void recurFunc2(int, int, int);
void recurFunc3(int, int, int);
/**
Primary user function for darkGDK programs.
*/
void DarkGDK ()
{
screenSetup(); //Set up the screen
int sizeLength = 100;
int xStart = (dbScreenWidth() / 2) - 100;
int yStart = (dbScreenHeight() / 2) - 100;
//Primary game loop. LoopGDK() returns FALSE if and only if the
//user attempts to terminate the program
while (LoopGDK())
{
while(sizeLength == 100)
{
recurFunc1(xStart, yStart + sizeLength / 2, sizeLength / 2);
recurFunc2(xStart + sizeLength, yStart + sizeLength / 2, sizeLength / 2);
recurFunc3(xStart + sizeLength / 4, yStart, sizeLength / 2);
}
}
// return back to windows
return;
}
void recurFunc1(int xPos, int yPos, int size)
{
if (size <= 1)
{
dbBox(xPos, yPos, xPos + size, yPos + size);
return;
}
else
{
recurFunc1(xPos, yPos + size / 2, size / 2);
recurFunc2(xPos + size, yPos + size / 2, size / 2);
recurFunc3(xPos + size / 4, yPos, size / 2);
}
}
void recurFunc2(int xPos, int yPos, int size)
{
if (size <= 1)
{
dbBox(xPos, yPos, xPos + size, yPos + size);
return;
}
else
{
recurFunc1(xPos, yPos + size / 2, size / 2);
recurFunc2(xPos + size, yPos + size / 2, size / 2);
recurFunc3(xPos + size / 4, yPos, size / 2);
}
}
void recurFunc3(int xPos, int yPos, int size)
{
if (size <= 1)
{
dbBox(xPos, yPos, xPos + size, yPos + size);
return;
}
else
{
recurFunc1(xPos, yPos + size / 2, size / 2);
recurFunc2(xPos + size, yPos + size / 2, size / 2);
recurFunc3(xPos + size / 4, yPos, size / 2);
}
}
/**
Initialize the screen parameters
*/
void screenSetup()
{
char windowTitle[] = "Sierpinski Triangle";
dbSetWindowTitle(windowTitle);
dbSyncOn();
dbSyncRate(60);
return;
}