Here's some extract from a game I made (using Strict):
C++ :
Forgive the messed up formatting.
Back in BMX
Note: each method you want to be able to use in Blitzmax, must be defiend in BMX extern in ORDER they appear in C++ with parameters, and in C++ must be listed as virtual and public. Look at the end of C++ file, you'll need a create and delete function that makes and returns your class, and frees your class. Remember no garbage collector! Call delete function in BMX when done!
Sorry I don't have time for more detail but hopefully you can get some ideas from this.
Extern Type gametype Method restart(x, y, mines) Method getsquare(x, y, showall) Method makemove(x, y) Method getmineshit() Method getmoves() Method gameover() Method getremaining() Method getmines() Method toggleflag(x, y) Method getflag(x, y) Method getflagnum() Method hitmine(x, y) End Type Function newgame:gametype(x, y, mines) Function endgame(game:gametype) End Extern;
C++ :
class gametype { Private stuff ... Public: gametype(int x, int y, int mines) { startnewgame(x, y, mines); } virtual void restart(int x, int y, int mines) { board.clearboard(); startnewgame(x, y, mines); } virtual int getsquare(int x, int y, bool showall) {} ETC } extern "C" { gametype* newgame(int x, int y, int mines) { return new gametype(x, y, mines); } void endgame(gametype* game) { delete game; } }
Forgive the messed up formatting.
Back in BMX
Local game:gametype = newgame(xsize, ysize, mines) game.makemove(mouseonx, mouseony) ETC
Note: each method you want to be able to use in Blitzmax, must be defiend in BMX extern in ORDER they appear in C++ with parameters, and in C++ must be listed as virtual and public. Look at the end of C++ file, you'll need a create and delete function that makes and returns your class, and frees your class. Remember no garbage collector! Call delete function in BMX when done!
Sorry I don't have time for more detail but hopefully you can get some ideas from this.