Hi there, thanks for your help. I have asked about shooting before and am currrently trying to implement a class developed by another user that would be suitable for my game.
My main trouble is we havent even learnt how to implement classes properly at uni and yet I have to have a game prototype with classes done within the next five days!!
Any help on implementing this class and finally making my plane shoot would be VERY greatly appreciated. Here's my code:
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 3D project that uses Dark GDK
// it can be used as a starting point in making your own 3D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "DarkAI.h"
#pragma comment (lib, "DarkAI.lib")
#include "DarkLights.h"
#pragma comment (lib, "DarkLights.lib")
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn();
dbSyncRate( 60 );
dbSetDisplayMode(800, 600, 32);
dbSetCameraRange(1.0f, 30000.0f);
dbSetGlobalCollisionOn();
dbAutoCamOff();
bool highSpeed;
highSpeed = 0;
float minY;
dbLoadImage( "texture.jpg", 1 );
dbLoadImage( "detail.jpg", 2 );
dbLoadObject( "H-Jet Fighter-Move.x", 101 );
dbPositionObject( 101, 20, 50, 30 );
dbRotateObject( 101, 0, 0, 0 );
dbLoopObject( 101, 1, 1 );
dbSetObjectSpeed( 101, 2 );
dbSetupTerrain();
dbMakeObjectTerrain(102);
dbSetTerrainHeightMap( 102, "map.bmp" );
dbSetTerrainScale( 102, 30.0f, 0.0f, 30.0f );
dbSetTerrainLight( 102, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f );
dbSetTerrainTexture( 102, 1, 2 );
dbBuildTerrain(102);
dbLoadObject( "skybox2.x", 103 );
dbSetObjectLight( 103, 0 );
dbScaleObject( 103, 30000, 30000, 30000 );
LMStart();
AIStart();
AIAddPlayer(101, 1);
//Patrol Path 1
AIMakePath(1);
AIPathAddPoint(1, 950, 1050);
AIPathAddPoint(1, 1050, 1050);
AIPathAddPoint(1, 1050, 950);
AIPathAddPoint(1, 950, 950);
//Patrol Path 2
AIMakePath(2);
AIPathAddPoint(2, 1050, 950);
AIPathAddPoint(2, 950, 950);
AIPathAddPoint(2, 950, 1050);
AIPathAddPoint(2, 1050, 1050);
//Path 1 for enemies within building
AIMakePath(3);
AIPathAddPoint(3, 1000, 1100);
AIPathAddPoint(3, 1080, 1120);
//Path 2 for enemies within building
AIMakePath(4);
AIPathAddPoint(4, 1000, 1020);
AIPathAddPoint(4, 1080, 1100);
//Building Code
AIAddContainer(1);
dbMakeObjectCube(104, 10.0f);
dbPositionObject(104, 1000, 10, 1000);
dbScaleObject(104, 450, 200, 450);
dbSetObjectCull(104,0);
dbColorObject(104,dbRGB(184,181,117));
AIAddEnemy(104, 1, 1);
//Patrol Enemy 1 Code
dbMakeObjectCylinder(105, 5.0f);
dbPositionObject(105, 950, 5, 950);
dbScaleObject(105, 100, 150, 100);
dbSetObjectCull(105, 0);
dbColorObject(105,dbRGB(255,0,0));
AIAddEnemy(105, 1, 1);
AIEntityAssignPatrolPath(105, 1);
//Patrol Enemy 2 Code
dbMakeObjectCylinder(106, 5.0f);
dbPositionObject(106, 1050, 5, 1050);
dbScaleObject(106, 100, 150, 100);
dbSetObjectCull(106, 0);
dbColorObject(106,dbRGB(255,0,0));
AIAddEnemy(106, 1, 1);
AIEntityAssignPatrolPath(106, 2);
//Oil Tank Code
dbMakeObjectCylinder(107, 2.0f);
dbPositionObject(107, 1100, 0, 1100);
dbScaleObject(107, 100, 200, 100);
dbSetObjectCull(107, 0);
dbColorObject(107,dbRGB(159,159,142));
dbMakeObjectCylinder(108, 2.0f);
dbPositionObject(108, 1100, 0, 1120);
dbScaleObject(108, 100, 200, 100);
dbSetObjectCull(108, 0);
dbColorObject(108,dbRGB(159,159,142));
dbMakeObjectCylinder(109, 10.0f);
dbPositionObject(109, 1100, 5, 1110);
dbScaleObject(109, 100, 250, 100);
dbSetObjectCull(109, 0);
dbColorObject(109,dbRGB(159,159,142));
dbRotateObject(109, 90, 0, 0);
//Static Enemy Code
dbMakeObjectCylinder(113,5.0f);
dbPositionObject(113,1085,5,1120);
dbScaleObject(113,100,150,100);
dbSetObjectCull(113,0);
dbColorObject(113,dbRGB(255,0,0));
//Building Enemy 1 Code
dbMakeObjectCylinder(114,5.0f);
dbScaleObject(114,100,150,100);
dbSetObjectCull(114,0);
dbSetObjectSpeed(114, 3);
dbColorObject(114,dbRGB(255,0,0));
dbHideObject(114);
AIAddEnemy(114,1,1);
//Building Enemy 2 Code
dbMakeObjectCylinder(115,5.0f);
dbScaleObject(115,100,150,100);
dbSetObjectCull(115,0);
dbSetObjectSpeed(115,4);
dbColorObject(115,dbRGB(255,0,0));
dbHideObject(115);
AIAddEnemy(115,1,1);
//Target indicator
dbMakeObjectTriangle(110,1100,40,1100,1100,40,1120,1100,20,1110);
dbColorObject(110,dbRGB(122,249,108));
//Airforce base objects
//Afghan area objects
while ( LoopGDK ( ) )
{
dbSetCameraToFollow(dbObjectPositionX(101), dbObjectPositionY(101), dbObjectPositionZ(101), dbObjectAngleZ(101), -30, 20, 30, 1);
dbSetCameraToObjectOrientation(101);
dbPointCamera(dbObjectPositionX(101), dbObjectPositionY(101), dbObjectPositionZ(101));
if(dbObjectExist(109))
{
dbText(197,545,"Try and find a way to lure the guards out of the building...");
dbText(260,570,"HINT: A big explosion might do the the trick.");
} else
{
dbText(350,545,"Nice Shot!!");
}
if(dbKeyState(47)==1)
{
dbMakeObjectCylinder(112, 10.0f);
dbPositionObject(112, 1100, 5, 1110);
dbScaleObject(112, 100, 250, 100);
dbSetObjectCull(112, 0);
dbColorObject(112,dbRGB(159,159,142));
dbRotateObject(112, 90, 0, 0);
dbDeleteObject(109);
dbHideObject(110);
dbColorObject(112,dbRGB(0,0,0));
dbRotateObject(113, 90, 0, 0);
dbColorObject(113,dbRGB(0,0,0));
dbPositionObject(114,1000,5,1050);
dbShowObject(114);
AIEntityGoToPosition(114,1080,1100);
dbPositionObject(115,995,5,1045);
dbShowObject(115);
AIEntityGoToPosition(115,1075,1100);
/*AIEntityGoToPosition(105,dbObjectPositionX(113),dbObjectPositionZ(113));
AIEntityGoToPosition(106,1060,1110);*/
}
minY = dbGetTerrainGroundHeight(102, dbObjectPositionX(101), dbObjectPositionZ(101));
if(dbObjectPositionY(101) < minY+0.5)
{
dbPositionObject(101, dbObjectPositionX(101), minY+0.5, dbObjectPositionZ(101));
}
if(dbObjectPositionY(110) < 50)
{
dbMoveObjectUp(110,1.0);
} else
{
dbMoveObjectDown(110,30.0);
}
if(dbShiftKey()==1)
{
if(dbKeyState(44)==1)
{
dbRollObjectRight(101,1);
}
} else if(dbKeyState(44)==1)
{
dbRollObjectRight(101,3);
}
if(dbShiftKey()==1)
{
if(dbKeyState(45)==1)
{
dbRollObjectLeft(101,1);
}
} else if(dbKeyState(45)==1)
{
dbRollObjectLeft(101,3);
}
if(dbShiftKey()==1)
{
if(dbLeftKey()==1)
{
dbRollObjectRight(101,1);
dbTurnObjectLeft(101,2);
}
} else if(dbLeftKey()==1)
{
dbRollObjectRight(101,3);
dbTurnObjectLeft(101,5);
}
if(dbShiftKey()==1)
{
if(dbRightKey()==1)
{
dbRollObjectLeft(101,1);
dbTurnObjectRight(101,2);
}
} else if(dbRightKey()==1)
{
dbRollObjectLeft(101,3);
dbTurnObjectRight(101,5);
}
if(dbShiftKey()==1)
{
if(dbDownKey()==1)
{
dbPitchObjectDown(101,1);
}
} else if(dbDownKey()==1)
{
dbPitchObjectDown(101,3);
}
if(dbShiftKey()==1)
{
if(dbUpKey()==1)
{
dbPitchObjectUp(101,1);
}
} else if(dbUpKey()==1)
{
dbPitchObjectUp(101,3);
}
if(dbKeyState(46)==1)
{
if(highSpeed==0)
{
highSpeed = 1;
} else
{
highSpeed = 0;
}
}
if(dbSpaceKey()==1)
{
if(highSpeed==0)
{
dbMoveObject(101,-2);
dbPlayObject(101);
} else
{
dbMoveObject(101,-4);
}
}
dbSync ( );
AIUpdate();
}
return;
}
This is the code that clearly isnt mine, noting the tidyness!
#include "DarkGDK.h"
class bullet {
float posx;
float posy;
float posz;
float rotx;
float roty;
float rotz;
int life;
int speed;
int object;
public:
bullet(int obj);
~bullet(int obj);
move();
}
bullet::bullet(int obj) {
posx = dbObjectPositionX(1);
posy = dbObjectPositionY(1);
rotx = dbObjectAngleX(1);
life=100;
speed=10;
object=obj;
dbMakeObjectSphere(obj,10);
dbPositionObject(obj,posx,posy,posz);
dbRotateObject(obj,rotx,roty,rotz);
}
bullet::move() {
if (dbObjectExists(obj)) {
dbMoveObject(obj,speed);
life--;
if (life<=0) {
dbDeleteObject(obj);
}
}
}