Sorry for the late reply but I've run into some problems while trying to implement the code. Heres my Asteroid class;
#include "Asteroid.h"
#include "DarkGDK.h"
#include "Player.h"
#include "Terrain.h"
#include "AsteroidFactory.h"
float gravity = 1;
Asteroid::Asteroid(int ID, float posX, float posY, float posZ)
{
_ID = ID;
//const int number = 4;
//int Asteroid[number];
//Asteroid
dbMakeObjectSphere(_ID, 100);
//dbMakeObjectSphere(6, 100);
//dbPositionObject(6, 300, 1000, 500);
//dbMakeObjectSphere(7, 100);
dbPositionObject(_ID, posX, posY, posZ);
}
void Asteroid::Update(int collideObject){
dbMoveObjectDown(_ID, gravity);
//dbMoveObjectDown(7, gravity);
if(dbObjectCollision(_ID, collideObject) == 1)
{
dbDeleteObject(_ID);
}
//if(dbObjectPositionX(6) < 0) {
//dbPositionObject(6, 0, dbObjectPositionY(6), dbObjectPositionZ(6));
//}
//if(dbObjectCollision(7, 3) == 1)
//{
//dbDeleteObject(7);
//}
}
Asteroid::~Asteroid(void)
{
}
Heres the AsteroidFactory class;
#include "AsteroidFactory.h"
#include "DarkGDK.h"
#include "Asteroid.h"
#include "Player.h"
#include "Terrain.h"
int free_ID;
float spawnTime_;
float lastSpawn_;
float spawnLimit_;
int spawnCount_;
void Update();
std::vector<Asteroid*> asteroids_;
AsteroidFactory::AsteroidFactory(void)
{
}
void AsteroidFactory::Update(){
if(dbTimer() > lastSpawn_ + spawnTime_){
if(spawnCount_ < spawnLimit_){
Asteroids* a = new Asteroid(freeID_, dbRND(1000), 1000, dbRND(1000));
asteroids.puch_back(a);
lastSpawn_ = dbTimer();
freeID_++;
spawnCount_++;
}
}
}
AsteroidFactory::~AsteroidFactory(void)
{
}