Sure and sorry. There's a slight bug in the createTable part, nevermind it, I know how to get over it. My annoyance level is on the camera handling and the randomize (that apparently does not randomize).
I have tried to take out the dbSetCurrentCamera with no luck. But I never tried to put it on a loop and to be honest, it doesn't make any sense the way I see it, maybe I'm wrong.
There are some variables there that just exist to assure that loops are executed once and some debugging, that will be cleaned out later, so pay no attention to it as I'm still developing C++ also.
#include "DarkSDK.h"
// No idea if this stays here or goes in too functions and main loop
int checkHexX, checkHexY;
int currentHexX = 1; // This value must be given by the main game loop
int currentHexY = 1; // This value must be given by the main game loop
int level;
// Class declaration
class hexagon // Game pieces
{
public:
int color;
int type;
int hexX;
int hexY;
};
// Function prototypes
void checkBoard ( int currentHexX, int currentHexY );
void createBoard ( int level );
void DarkSDK ()
{
// Initialize all the Jazz
dbSyncOn ();
dbSyncRate ( 90 );
dbSetDisplayMode ( 800, 600, 32 );
// Load media
dbLoadImage ( "rubi.jpg", 1 );
dbLoadImage ( "nature.jpg", 2 );
dbLoadImage ( "ivory.jpg", 3 );
dbLoadImage ( "sand.jpg", 4 );
dbLoadImage ( "sky.jpg", 5 );
dbLoadImage ( "life.jpg", 6 );
dbLoadImage ( "sphere1.jpg", 7 );
dbLoadObject ( "hexagon.x", 1 );
// Create the skycube
dbMakeObjectSphere ( 2, -1000000 );
dbSetSphereMappingOn ( 2, 7 );
// Camera stuff
float basicSize = dbObjectSizeX ( 1 );
dbMakeCamera ( 1 );
dbSetCurrentCamera ( 1 );
dbPositionCamera ( 1, ( 4 * basicSize ), ( ( 3 * basicSize ) + ( basicSize / 2 ) ), -1000 );
dbPointCamera ( 1, ( 4 * basicSize ), ( ( 3 * basicSize ) + ( basicSize / 2 ) ), 0 );
// Main loop
int loop1 = 1; // Remove when menus are created
while ( LoopSDK() )
{
if ( loop1 == 1 )
{
createBoard ( 1 );
loop1++;
}
dbControlCameraUsingArrowKeys ( 1, 1, 1 );
dbSync ();
}
return;
}
void checkBoard ( int currentHexX, int currentHexY )
{
int posToCheck = 1;
while ( posToCheck < 7 )
{
switch ( posToCheck ) // Assign XY coordinates to the hexagons to be checked
{
case 1: checkHexX = currentHexX; checkHexY = currentHexY-1; break; // hexagon above
case 2: checkHexX = currentHexX+1; checkHexY = currentHexY-1; break; // hexagon above and right
case 3: checkHexX = currentHexX+1; checkHexY = currentHexY; break; // hexagon below and right
case 4: checkHexX = currentHexX; checkHexY = currentHexY+1; break; // hexagon below
case 5: checkHexX = currentHexX-1; checkHexY = currentHexY; break; // hexagon below and left
case 6: checkHexX = currentHexX-1; checkHexY = currentHexY-1; break; // hexagon above and left
}
// TODO: Check if colours meet and the rest of the mambo jambo
posToCheck++;
return;
}
}
void createBoard ( int level )
{
float pieceSize = dbObjectSizeX ( 1 );
int objectNumber = 1;
int X = 1;
while ( X <= 7 )
{
int Y = 1;
while ( Y <= 6 )
{
if ( X % 2 == 0 && Y == 1 )
{
Y++;
}
else
{
if ( Y == 1 && X == 1 ) // Create the initial piece
{
dbMakeObject ( objectNumber , 1, 1 );
}
else // Clone the rest
{
dbCloneObject ( objectNumber, 1 );
}
int texture = ( 1 + dbRnd ( 5 ) );
dbTextureObject ( objectNumber, texture );
if ( X % 2 != 0 )
{
dbPositionObject ( objectNumber, ( X * pieceSize ), ( Y * pieceSize ), 0 );
}
else
{
dbPositionObject ( objectNumber, ( X * pieceSize ), ( ( Y * pieceSize ) + ( pieceSize / 2 ) ), 0 );
}
objectNumber++;
Y++;
}
}
X++;
}
return;
}
Thank you in advance
V
I'm pretty sure I know everything. Doubts are something rare in me and I am never wrong, as this signature can prove.