Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actuallinhmai27

Posted 26 November 2012 - 12:48 AM

Hello guys, i have problem with my code


tankGame.h

class myTank;
class TankSteering;
//enum KEYS{ W, S, A, D,J,K};
class TankGame{
public:
  TankGame(ALLEGRO_DISPLAY* display);
  ~TankGame();
  myTank* m_player;
  TankSteering* m_TankSteering;
  void Update();
  void Render();
};


myTank.h

class TankGame;
class TankSteering;	

class myTank : public MovingEntity {
public:
  myTank(TankGame* tank_game, Vector2D pos, ALLEGRO_DISPLAY* display);
  ~myTank();
  void Update();
  void Render();
	....blah....
private:
....blah....
  TankSteering* m_pSteering;
  TankGame* m_tankGame;

};


tankSteering.h
class myTank;
class TankGame;
class TankSteering
{
public:
  TankSteering(myTank* player, TankGame* tankGame);
  //TankSteering();
  ~TankSteering();
  Vector2D Calculate();
  Vector2D Player_Steering();
private:
  TankGame* m_pTankGame;
  float m_fMaxForce;
  myTank* m_tplayer;
  float m_fDesRateForce;
};

TankGame.cpp

TankGame::TankGame(ALLEGRO_DISPLAY* display)
{
m_player = new myTank(this, Vector2D(200.0f, 200.0f), display);
//m_TankSteering = new TankSteering(this);
for(int i = 0; i < 6; i++)
{
  keys[i] = false;
}
}
blah blah

the thing is, when i remove the line "m_player = new myTank(this, Vector2D(200.0f, 200.0f), display);" in my tankGame, it work. But when i add this line in TankGame constructor, error "error Run-Time Check Failure #0" happened. when i create an object of myTank in mainfunction, it worked. Someone can help me Posted Image. Thank in advance

#1linhmai27

Posted 26 November 2012 - 12:46 AM

Hello guys, i have problem with my code


tankGame.h
<code>
class myTank;
class TankSteering;
//enum KEYS{ W, S, A, D,J,K};
class TankGame{
public:
TankGame(ALLEGRO_DISPLAY* display);
~TankGame();
myTank* m_player;
TankSteering* m_TankSteering;

void Update();
void Render();
};
</code>


myTank.h

<code>
class TankGame;
class TankSteering;

class myTank : public MovingEntity {
public:
myTank(TankGame* tank_game, Vector2D pos, ALLEGRO_DISPLAY* display);
~myTank();
void Update();
void Render();
....blah....
private:
....blah....
TankSteering* m_pSteering;
TankGame* m_tankGame;

};

</code>

tankSteering.h
<code>
class myTank;
class TankGame;
class TankSteering
{
public:
TankSteering(myTank* player, TankGame* tankGame);
//TankSteering();
~TankSteering();
Vector2D Calculate();
Vector2D Player_Steering();
private:
TankGame* m_pTankGame;
float m_fMaxForce;
myTank* m_tplayer;
float m_fDesRateForce;
};
</code>

TankGame.cpp
<code>

TankGame::TankGame(ALLEGRO_DISPLAY* display)
{
m_player = new myTank(this, Vector2D(200.0f, 200.0f), display);
//m_TankSteering = new TankSteering(this);
for(int i = 0; i < 6; i++)
{
keys[i] = false;
}
}
blah blah
</code>

the thing is, when i remove the line "m_player = new myTank(this, Vector2D(200.0f, 200.0f), display);" in my tankGame, it work. But when i add this line in TankGame constructor, error "error Run-Time Check Failure #0" happened. when i create an object of myTank in mainfunction, it worked. Someone can help me :). Thank in advance

PARTNERS