/* In here you need to create any movable objects that you wish to use. Sub-classes need to implement this function. */ int MyProjectMain::InitialiseObjects() { // Record the fact that we are about to change the array - so it doesn't get used elsewhere without reloading it DrawableObjectsChanged(); // Destroy any existing objects DestroyOldObjects(); // Create an array one element larger than the number of objects that you want. m_ppDisplayableObjects = new DisplayableObject*[2]; // You MUST set the array entry after the last one that you create to NULL, so that the system knows when to stop. // i.e. The LAST entry has to be NULL. The fact that it is NULL is used in order to work out where the end of the array is. m_ppDisplayableObjects[0] = new SimpleShape(this); m_ppDisplayableObjects[1] = NULL; return 0; }
/* In here you need to create any movable objects that you wish to use. Sub-classes need to implement this function. */ int BaseEngine::InitialiseObjects() { // Destroy any existing objects DestroyOldObjects(); // Create an array one element larger than the number of objects that you want. // e.g.: m_ppDisplayableObjects = new DisplayableObject*[MAXNUMBER+1]; // You MUST set the array entry after the last one that you create to NULL, so that the system knows when to stop. //e.g. m_ppDisplayableObjects[0] = new MyDisplayableObject( this, m_iPlayer1StartX, m_iPlayer1StartY); //e.g. m_ppDisplayableObjects[1] = new MyDisplayableObject( this, m_iPlayer2StartX, m_iPlayer2StartY); // i.e. The LAST entry has to be NULL. The fact that it is NULL is used in order to work out where the end of the array is. //e.g. m_ppDisplayableObjects[2] = NULL; // You should return the number of objects which you created. // e.g. return 2; return 0; }
/* Destructor - destroys moving objects */ BaseEngine::~BaseEngine(void) { DestroyOldObjects(); delete [] m_pUpdateRectangles; }
/* In here you need to create any movable objects that you wish to use. Sub-classes need to implement this function. */ int BouncingBallMain::InitialiseObjects() { // Record the fact that we are about to change the array - so it doesn't get used elsewhere without reloading it DrawableObjectsChanged(); // Destroy any existing objects DestroyOldObjects(); // Create a new object of type BouncingBall1 m_pBall1 = new BouncingBall1( this, 0/*Id*/, 1/*Type*/, 100/*Size*/, 1/*Colour*/, "A"/*Label*/, -10/*XLabelOffset*/, -15/*YLabelOffset*/, &obTileManager ); // Bouncing ball 1 has a movement object, tells it to move from // position a to position b, over a specific period of time. // The update for the ball will reverse the move at the end of this time m_pBall1->SetMovement( GetTime(), GetTime()+1000, GetTime(), 100, 100, 700, 500 ); // Create another, different, type of ball m_pBall2 = new BouncingBall2( this, 0/*Id*/, 1/*Type*/, 100/*Size*/, 2/*Colour*/, "B"/*Label*/, -10/*XLabelOffset*/, -15/*YLabelOffset*/ ); m_pBall2->SetPosition( 100,100 ); m_pBall2->SetSpeed( 1.1,1.0 ); // And a third ball m_pBall3 = new BouncingBall2( this, 0/*Id*/, 1/*Type*/, 100/*Size*/, 3/*Colour*/, "C"/*Label*/, -10/*XLabelOffset*/, -15/*YLabelOffset*/ ); m_pBall3->SetPosition( 300,250 ); m_pBall3->SetSpeed( 0.8,1.2 ); // Creates an array one element larger than the number of objects that you want. CreateObjectArray(3); // You MUST set the array entry after the last one that you create to NULL, so that the system knows when to stop. StoreObjectInArray(0, m_pBall1 ); StoreObjectInArray(1, m_pBall2 ); StoreObjectInArray(2, m_pBall3 ); // i.e. The LAST entry has to be NULL. The fact that it is NULL is used in order to work out where the end of the array is. StoreObjectInArray(3, NULL); // NOTE: We also need to destroy the objects, but the method at the // top of this function will destroy all objects pointed at by the // array elements so we can ignore that here. return 0; }
/* Destructor - destroys moving objects */ BaseEngine::~BaseEngine(void) { DestroyOldObjects(); }