I appologize I will upload it when I can. I uploaded all of the changes in order already...
I'm not sure they will work because you have probably done this for yourself. But I copied and pasted all the changes into the sources I uploaded last...
Main.cpp:
#include "DarkGDK.h"
#include "SetupGame.h"
#include "GameControl.h"
#include "SC_Collision.h"
#include "CubeControl.h"
//Globals
int MouseClick;
//Game Modes
enum GameModes { new_game, play_game, menu_game, ai_game, cleanup_game };
GameModes _gmode = new_game;
void DarkGDK ( void )
{
SetupWindow();
LoadImages();
while ( LoopGDK ( ) )
{
switch ( _gmode )
{
case new_game:
SetupGame();
_gmode = play_game;
break;
case play_game:
MouseClick = dbMouseClick();
CamControl();
if ( MouseClick == 1 )
{
dbText( 20, 0, "1" );
PlayGame();
}
break;
}
dbSync ( );
}
return;
}
CubeControl.cpp:
#include "DarkGDK.h"
#include "SC_Collision.h"
#include "comm.h"
void Define ( int PlaneId, int axis, int direction );
void RotationTest ( int Planeid, int axis, int direction );
// Used to store Ids of cubes ( 0-7 are peripheals and 8 is the center )
int CubeId[8];
// Used to store the Test Positions
float ObjPos[3][9];
// Angle variables
float yangle = 0.0;
float xangle = 0.0;
float zangle = 0.0;
void GetId ( int planeId, int axis, int direction )
{
dbText( 20, 20, "3" );
float cpoy;
float cpox;
float cpoz;
Define( planeId, axis, direction );
for ( int i = 1; i <= 27; i++ )
{
dbText( 20, 40, "5" );
if ( dbObjectCollision( planeId, i ) )
{
dbText( 50, i*10, dbStr( i ) );
cpoy = dbObjectPositionY( i );
cpox = dbObjectPositionX( i );
cpoz = dbObjectPositionZ( i );
dbText( 20, 50, "6" );
for ( int j = 0; j <= 8; j++ )
{
if ( cpoy <= ObjPos[y][j] + 5 && cpoy >= ObjPos[y][j] - 5
&& cpoz <= ObjPos[z][j] + 5 && cpoz >= ObjPos[z][j] - 5
&& cpox <= ObjPos[x][j] + 5 && cpox >= ObjPos[x][j] -5 )
{
CubeId[j] = i;
dbText( 20, 60, "7" );
break;
}
}
}
}
for ( int j = 0; j < 9; j++ )
{
dbText( 0, j*10, dbStr( CubeId[j] ) );
}
RotationTest( planeId, axis, direction );
}
void RotationTest( int Planeid, int axis, int direction )
{
for ( int k = 1; k < 19; k++ )
{
switch ( direction )
{
case left:
yangle = dbObjectAngleY( Planeid ) - 5;
break;
case right:
yangle = dbObjectAngleY( Planeid ) + 5;
break;
case up:
if ( axis == x )
{
xangle = dbObjectAngleX( Planeid ) + 5;
break;
} else if ( axis == z )
{
zangle = dbObjectAngleZ( Planeid ) + 5;
break;
}
case down:
if ( axis == x )
{
xangle = dbObjectAngleX( Planeid ) - 5;
break;
} else if ( axis == z )
{
zangle = dbObjectAngleZ( Planeid ) - 5;
break;
}
default:
dbText( 0, 0, "error" );
}
Define( Planeid, axis, direction );
for ( int i = 1; i <= 9; i++ )
{
dbYRotateObject( Planeid, yangle );
dbXRotateObject( Planeid, xangle );
dbZRotateObject( Planeid, zangle );
dbPositionObject( CubeId[i-1], ObjPos[x][i-1], ObjPos[y][i-1], ObjPos[z][i-1] );
dbYRotateObject( CubeId[i-1], yangle );
dbXRotateObject( CubeId[i-1], xangle );
dbZRotateObject( CubeId[i-1], zangle );
}
dbSync();
}
for ( int i = 0; i < 9; i++ )
{
CubeId[i] = 0;
}
for ( int i = 0; i < 3; i++ )
{
for ( int j = 0; j < 9; j++ )
{
ObjPos[i][j] == 0;
}
}
}
void Define ( int PlaneId, int axis )
{
float centercubeposx = dbObjectPositionX( PlaneId );
float centercubeposz = dbObjectPositionZ( PlaneId );
float centercubeposy = dbObjectPositionY( PlaneId );
int i = 0;
switch ( axis )
{
case x:
// Angles
pyangle = dbObjectAngleY( PlaneId );
pzangle = dbObjectAngleZ( PlaneId );
pxangle = xangle;
zangle = 0;
yangle = 0;
// X's
for ( i; i < 9; i++ )
{
ObjPos[x][i] = centercubeposx;
}
// Y's
ObjPos[y][0] = ( dbCos( xangle + 225 ) * 212 + centercubeposy );
ObjPos[y][1] = ( dbCos( xangle + 270 ) * 150 + centercubeposy );
ObjPos[y][2] = ( dbCos( xangle + 315 ) * 212 + centercubeposy );
ObjPos[y][3] = ( dbCos( xangle + 360 ) * 150 + centercubeposy );
ObjPos[y][4] = ( dbCos( xangle + 405 ) * 212 + centercubeposy );
ObjPos[y][5] = ( dbCos( xangle + 450 ) * 150 + centercubeposy );
ObjPos[y][6] = ( dbCos( xangle + 495 ) * 212 + centercubeposy );
ObjPos[y][7] = ( dbCos( xangle + 540 ) * 150 + centercubeposy );
ObjPos[y][8] = centercubeposy;
// Z's
ObjPos[z][0] = ( dbSin( xangle + 225 ) * 212 + centercubeposz );
ObjPos[z][1] = ( dbSin( xangle + 270 ) * 150 + centercubeposz );
ObjPos[z][2] = ( dbSin( xangle + 315 ) * 212 + centercubeposz );
ObjPos[z][3] = ( dbSin( xangle + 360 ) * 150 + centercubeposz );
ObjPos[z][4] = ( dbSin( xangle + 405 ) * 212 + centercubeposz );
ObjPos[z][5] = ( dbSin( xangle + 450 ) * 150 + centercubeposz );
ObjPos[z][6] = ( dbSin( xangle + 495 ) * 212 + centercubeposz );
ObjPos[z][7] = ( dbSin( xangle + 540 ) * 150 + centercubeposz );
ObjPos[z][8] = centercubeposz;
break;
case y:
// Angles
pyangle = yangle;
pxangle = dbObjectAngleX( PlaneId );
pzangle = dbObjectAngleZ( PlaneId );
xangle = 0;
zangle = 0;
// X's
ObjPos[x][0] = ( dbSin( yangle + 225 ) * 212 + centercubeposx );
ObjPos[x][1] = ( dbSin( yangle + 270 ) * 150 + centercubeposx );
ObjPos[x][2] = ( dbSin( yangle + 315 ) * 212 + centercubeposx );
ObjPos[x][3] = ( dbSin( yangle + 360 ) * 150 + centercubeposx );
ObjPos[x][4] = ( dbSin( yangle + 405 ) * 212 + centercubeposx );
ObjPos[x][5] = ( dbSin( yangle + 450 ) * 150 + centercubeposx );
ObjPos[x][6] = ( dbSin( yangle + 495 ) * 212 + centercubeposx );
ObjPos[x][7] = ( dbSin( yangle + 540 ) * 150 + centercubeposx );
ObjPos[x][8] = centercubeposx;
// Y's
for ( i = 0; i < 9; i++ )
{
ObjPos[y][i] = centercubeposy;
}
// Z's
ObjPos[z][0] = ( dbCos( yangle + 225 ) * 212 + centercubeposz );
ObjPos[z][1] = ( dbCos( yangle + 270 ) * 150 + centercubeposz );
ObjPos[z][2] = ( dbCos( yangle + 315 ) * 212 + centercubeposz );
ObjPos[z][3] = ( dbCos( yangle + 360 ) * 150 + centercubeposz );
ObjPos[z][4] = ( dbCos( yangle + 405 ) * 212 + centercubeposz );
ObjPos[z][5] = ( dbCos( yangle + 450 ) * 150 + centercubeposz );
ObjPos[z][6] = ( dbCos( yangle + 495 ) * 212 + centercubeposz );
ObjPos[z][7] = ( dbCos( yangle + 540 ) * 150 + centercubeposz );
ObjPos[z][8] = centercubeposz;
break;
case z:
// Angles
pyangle = dbObjectAngleY( PlaneId );
pzangle = zangle;
pxangle = dbObjectAngleX( PlaneId );
xangle = 0;
yangle = 0;
// X's
ObjPos[x][0] = ( dbSin( zangle + 225 ) * 212 + centercubeposx );
ObjPos[x][1] = ( dbSin( zangle + 270 ) * 150 + centercubeposx );
ObjPos[x][2] = ( dbSin( zangle + 315 ) * 212 + centercubeposx );
ObjPos[x][3] = ( dbSin( zangle + 360 ) * 150 + centercubeposx );
ObjPos[x][4] = ( dbSin( zangle + 405 ) * 212 + centercubeposx );
ObjPos[x][5] = ( dbSin( zangle + 450 ) * 150 + centercubeposx );
ObjPos[x][6] = ( dbSin( zangle + 495 ) * 212 + centercubeposx );
ObjPos[x][7] = ( dbSin( zangle + 540 ) * 150 + centercubeposx );
ObjPos[x][8] = centercubeposx;
// Y's
ObjPos[y][0] = ( dbCos( zangle + 225 ) * 212 + centercubeposy );
ObjPos[y][1] = ( dbCos( zangle + 270 ) * 150 + centercubeposy );
ObjPos[y][2] = ( dbCos( zangle + 315 ) * 212 + centercubeposy );
ObjPos[y][3] = ( dbCos( zangle + 360 ) * 150 + centercubeposy );
ObjPos[y][4] = ( dbCos( zangle + 405 ) * 212 + centercubeposy );
ObjPos[y][5] = ( dbCos( zangle + 450 ) * 150 + centercubeposy );
ObjPos[y][6] = ( dbCos( zangle + 495 ) * 212 + centercubeposy );
ObjPos[y][7] = ( dbCos( zangle + 540 ) * 150 + centercubeposy );
ObjPos[y][8] = centercubeposy;
//Z's
for ( i = 0; i < 9; i++ )
{
ObjPos[z][i] = centercubeposz;
}
break;
default:
break;
}
SetupGame.cpp:
#include "DarkGDK.h"
#include "SC_Collision.h"
void SetupWindow( void )
{
if ( dbCheckDisplayMode( 800, 600, 32 ) )
dbSetDisplayMode( 800, 600, 32 );
dbSyncOn();
dbSyncRate( 60 );
dbSetImageColorKey( 255, 0, 255 );
dbLoadImage( "BackDrop.bmp", 7 );
dbSetGlobalCollisionOn();
dbAutoCamOff();
SC_Start();
}
void LoadImages( void )
{
dbLoadImage( "BlueCell.bmp", 1 );
dbLoadImage( "RedCell.bmp", 2 );
dbLoadImage( "YellowCell.bmp", 3 );
dbLoadImage( "WhiteCell.bmp", 4 );
dbLoadImage( "GreenCell.bmp", 5 );
dbLoadImage( "OrangeCell.bmp", 6 );
dbLoadImage( "BackDrop.bmp", 7 );
dbLoadImage( "RightArrow.bmp", 8 );
dbLoadImage( "UpArrow.bmp", 9 );
dbLoadImage( "DownArrow.bmp", 10 );
dbLoadImage( "LeftArrow.bmp", 11 );
}
void SetupGame( void )
{
for ( int x = 1; x <= 3; x++ )
{
for ( int y = 1; y <= 3; y++ )
{
for ( int z = 1; z <= 3; z++ )
{
if ( dbObjectExist( 1 ) == 1 )
{
dbCloneObject( 9*(x-1)+3*(y-1)+z, 1 );
dbPositionObject( 9*(x-1)+3*(y-1)+z, x*150, y*150, z*150 );
} else {
dbLoadObject( "planecube.dbo", 1 );
dbPositionObject( 9*(x-1)+3*(y-1)+z, x*150, y*150, z*150 );
}
}
}
}
//Texture Cube
for ( int i = 1; i <= 27; i++ )
{
for ( int h = 1; h <= 6; h++ )
{
dbTextureLimb( i, h, h );
}
}
// Framwork
// Make 9 planes
for ( int i = 1; i <= 9; i++ )
{
if ( i == 1 )
{
dbLoadObject( "planeframe.dbo", i+30);
//dbMakeObjectPlane( i + 30, 150, 150 );
} else {
dbCloneObject( i + 30, 31 );
}
dbHideObject( i + 30 ); // Remove the innerframework from visibility
}
//Position them around the center cubes of each side
dbPositionObject( 31, dbObjectPositionX( 13 ), dbObjectPositionY( 13 ), dbObjectPositionZ( 13 ) ); //Front ( no rotate )
dbPositionObject( 32, dbObjectPositionX( 15 ), dbObjectPositionY( 15 ), dbObjectPositionZ( 15 ) ); //Back ( no rotate )
dbPositionObject( 33, dbObjectPositionX( 17 ), dbObjectPositionY( 17 ), dbObjectPositionZ( 17 ) ); //Top ( x rotate )
dbPositionObject( 34, dbObjectPositionX( 11 ), dbObjectPositionY( 11 ), dbObjectPositionZ( 11 ) ); //bottom ( x rotate )
dbPositionObject( 35, dbObjectPositionX( 5 ), dbObjectPositionY( 5 ), dbObjectPositionZ( 5 ) ); //Left ( y rotate )
dbPositionObject( 36, dbObjectPositionX( 23 ), dbObjectPositionY( 23 ), dbObjectPositionZ( 23 ) ); //Right ( y rotate )
for ( int i = 37; i <= 39; i++ )
{
dbPositionObject( i, dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
}
//Rotate them appropriately
dbXRotateObject( 33, 90 );
dbXRotateObject( 34, 90 );
dbYRotateObject( 35, 90 );
dbYRotateObject( 36, 90 );
//Rotate the 3 in the middle
dbYRotateObject( 37, 90 );
dbYRotateObject( 38, 90 );
//Setup Lighting
dbSetLightRange( 0, 999 );
dbSetPointLight( 0, dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
/*dbMakeObjectPlane( 50, 1500, 1500 );
dbMakeLight( 7 );
dbSetPointLight( 50, dbObjectPositionX( 50 ), dbObjectPositionY( 50 ), dbObjectPositionZ( 50 ) );
dbPositionObject( 50, dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
int camx = dbCameraPositionX();
int camy = dbCameraPositionY();
int camz = dbCameraPositionZ();
dbPointObject( 50, camx, camz, camy );
dbTextureObject( 50, 7 );*/
dbPositionCamera( dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) - 900 );
for ( int i = 1; i <= 40; i++ )
{
if ( dbObjectExist( i ) )
{
dbSetObjectCollisionToBoxes( i );
}
}
}
GameControl.cpp:
#include "DarkGDK.h"
#include "SC_Collision.h"
#include "CubeControl.h"
#include "comm.h"
void BackDropControl ( void );
void PlayGame( void )
{
int mc = dbMouseClick();
if ( mc == 1 )
{
GetId( 31, z, up );
} else if ( mc == 2 )
{
GetId( 35, x, down );
} else if ( mc == 3 )
{
GetId( 38, y, left );
}
}
void CamControl( void )
{
dbPointCamera( dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
if ( dbLeftKey() )
{
dbPointCamera( dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
dbMoveCamera( 900.0 );
dbTurnCameraLeft( 5.0 );
dbMoveCamera( -900.0 );
BackDropControl( );
}
if ( dbRightKey() )
{
BackDropControl( );
dbPointCamera( dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
dbMoveCamera( 900.0 );
dbTurnCameraRight( 5.0 );
dbMoveCamera( -900.0 );
}
if ( dbUpKey() )
{
if ( dbCameraPositionY() < - 300 )
{
return;
} else {
BackDropControl( );
dbPointCamera( dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
dbMoveCamera( 900.0 );
dbPitchCameraUp( 5.0 );
dbMoveCamera( -900.0 );
}
}
if ( dbDownKey() )
{
if ( dbCameraPositionY() >= 900 )
{
return;
} else {
BackDropControl( );
dbPointCamera( dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
dbMoveCamera( 900.0 );
dbPitchCameraDown( 5.0 );
dbMoveCamera( -900.0 );
}
}
}
void BackDropControl( void )
{
dbPositionObject( 50, dbObjectPositionX( 14 ), dbObjectPositionY( 14 ), dbObjectPositionZ( 14 ) );
dbPointObject( 50, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() );
dbMoveObject( 50, -400 );
}
CubeControl.h:
#ifndef _CUBECONTROL_
#define _CUBECONTROL_
//Function lists
void scTEST ( void );
void RotationTest ( int Planeid );
void GetId ( int planeId );
#endif
comm.h:
#ifndef _COMM_H_
#define _COMM_H_
#include "DarkGDK.h"
// Used to index arrays containing x, y and z values
// Used to determine which axis a specific plane rotates around
const int x = 0;
const int y = 1;
const int z = 2;
// Angles
float yangle = 0.0;
float xangle = 0.0;
float zangle = 0.0;
//Directions
const int left = 1;
const int right = 2;
const int up = 3;
const int down = 4;
#endif
If this doesnt compile let me know... I should be able to upload the correct versions of these from my laptop later this evening.
EYE R T3H +ick +ack +oe mester