ok, i need help. i have tried and tried to get this friggin code to work. i want the sphere to hit the blocks and break them. but it just goes right through.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
void Populatefield( void );
void Gameupdate( void );
void CollisionState( void );
void Reflect( void);
void MakeObjs( void );
int NumberLives = 3;
int LevelNumber = 1;
int BALL = 1;
int YPos =250;
int XPos = -325;
// the main entry point for the application is this function
void KeyState()
{
if (dbRightKey() != 0)
{
dbMoveObjectRight( 2 , 1 );
}
if (dbLeftKey() != 0)
{
dbMoveObjectLeft( 2 , 1 );
}
}
void Reflect()
{
float angle = dbObjectAngleX(1);
if (angle > 0 && angle < 90)
{
dbXRotateObject( 1 , angle+90);
}
if (angle > 90 && angle < 180)
{
dbXRotateObject( 1 , (angle-90)+180);
}
if (angle > 180 && angle > 270)
{
dbXRotateObject( 1 , (angle-180)+270);
}
if (angle > 270 && angle < 359)
{
dbXRotateObject( 1 , (angle-270)+359);
}
}
void CollisionState()
{
int Block = dbObjectHit(1,0);
if (dbObjectCollision( 1 , 2)== 1)
{
Reflect();
}
if (Block == 6)
{
Reflect();
}
if (Block == 3)
{
Reflect();
}
if (Block == 5)
{
Reflect();
}
if (Block > 100)
{
dbDeleteObject(Block);
Reflect();
}
}
void MakeObjs()
{
dbMakeObjectSphere ( 1 , 10 ); //ball
dbMakeObjectBox( 2 , 40 , 5 , 5 ); //paddle
dbMakeObjectBox ( 3 , 800 , 10 , 10 ); //Top Barrier
dbMakeObjectBox ( 4 , 800 , 10 , 10 ); //Bottom Barrier
dbMakeObjectBox ( 5 , 10 , 800 , 10 ); //Left Barrier
dbMakeObjectBox ( 6 , 10 , 800 , 10); //Right Barrier
dbPositionObject ( 3 , 0 , 300 , 0 );
dbPositionObject ( 4 , 0 , -300 , 0 );
dbPositionObject ( 5 , -400 , 0 , 0 );
dbPositionObject ( 6 , 250 , 0 , 0 );
dbPositionObject ( 2 , 0 , -290 , 0 );
dbRotateObject ( 1 , 45 , 90 , 0 );
int BallID = 100;
//Set up the field
for (int i=0; i<40; i++)
{
dbMakeObjectBox(BallID , 50, 10, 25);
dbPositionObject(BallID, XPos, YPos, 5);
XPos += 55;
BallID +=1;
if (XPos >= 225)
{
XPos = -325;
YPos -= 25;
}
}
}
void Gameupdate()
{
dbMoveObject( 1 , 1 );
}
void Populatefield()
{
}
void DarkGDK ( void )
{
// Set up game speed and camera
dbSetGlobalCollisionOn();
dbAutoCamOff();
dbSyncOn ( );
dbSyncRate ( 60 );
dbPositionCamera ( 0 , 0 , -500 );
dbPointCamera ( 0 , 0 , 0 );
Populatefield();
MakeObjs();
// our main loop
while ( LoopGDK ( ) )
{
KeyState();
Gameupdate();
if (dbObjectCollision( 1 , 0 ) != 0)
{
CollisionState();
}
// update the screen
dbSync ( );
}
// return back to windows
return;
}
Artificial inteligence can not compare to natural stupidity