convert codes

Community Forums/Developer Stations/convert codes

Akat(Posted 2003) [#1]
beleive me i never know this method could be implement within B3D before til last night... i tried and it works...

c/C++ codes:
1)Create Types or struct
typedef struct Sprite
{
   bool Exist;
   u16 X,Y;
   etc...
}Sprite;

2)Create new Sprite Types
volatile Sprite Hero;
volatile Sprite Enemy;

3)This one was an easy call
Hero.Exist = true;
Enemy.Exist = true;

4)try call the function
InitSpr(&Hero,10,10,etc...)
InitSpr(&Enemy,10,10,etc...)

5)this is the function
void InitSpr(Sprite *spr,u16 x,u16 y,etc...)
{
   spr->X = x; spr->Y = y; spr->etc = ...
}

B3D codes:
1)
type Sprite
   field Exist
   field X#,Y#
   etc...
end type

2)
Hero.Sprite = new Sprite
Enemy.Sprite = new Sprite

3)
Hero\Exist = true
Enemy\Exist = true

4)
InitSpr(Hero,10,10,etc...)
InitSpr(Enemy,10,10,etc...)

5)
function InitSpr(spr.Sprite,x#,y#,etc...)
   spr\X# = x : spr\Y# = y : spr\etc = ...
end function


hope this one usefull for someone who love to convert the C/C++ codes into B3D...especially faster collision detection which u can found easily in C codes for 2D games...(and i know BB already have the collision detection command)... and i know this simple codes look stupid for someone who already known - so this isnt for u