User Tools

Site Tools


en:examples:maths:initialising_an_orxvector

Initialising an empty orxVECTOR

Some ways to initialise an empty orxVECTOR.

  orxVECTOR position = {};
  orxVECTOR position = {0, 0, 0};
  orxVECTOR position = orxVECTOR_0;
  orxVECTOR position;
  position.fX = 0;
  position.fY = 0;
  position.fZ = 0;
  
  orxVECTOR position;
  orxVector_Set(&position, orx2F(0.0f), orx2F(0), orxFLOAT_0);
  

Uninitialised orxVECTORs can create unintended consequences in your game.

You can also do:

orxVECTOR tilePos;
orxVector_Set(&tilePos, orx2F(80.0f) * x, orx2F(160.0f), orxFLOAT_0);
orxObject_SetPosition(tile, &tilePos);
orxVECTOR pos;
orxObject_GetPosition(player, &pos);
pos.fX = -pos.fX;
orxObject_SetPosition(player, &pos);
en/examples/maths/initialising_an_orxvector.txt · Last modified: 2020/02/19 23:52 (5 years ago) by sausage