@GA....
yeah... it was a bit of a pain until i got the generic engine working... then i saw how i could actually do something with it, and it was actually quite easy and more organized once i got the hang of using it...
@Rook...
take a quick look at the engine's tObject declaration...
now, say for instance you wanted to create a WINDOW object... first you would create a WINDOW class... this is simply a matter of editing a new file something like this...
notice the classes update function... this is the single function that is continuously called by the engine while it's main loop is spinning... you can leave this function empty for now, a placeholder where you will add all of the WINDOW classes functionality in later...
save this file as WindowClass.bb
next, you would register it with the engine, as described in the above posts (the only time you have to edit the engine code, but it is simple to do)...
once this is done, you could add a new WINDOW object to your game... you would do this in your code using the engine's CreateObject() function... like so...
the CreateObject() function is like a lil gameobject factory, where the fields in the TYPE declaration for tObject are filled in...
the subClass$ field gets the first arg, "WINDOW", which is the name of the class...
CreateObject() is also smart enough to check to see if the next arg is a blank string or not, and if not, then load in the model it references and return a Blitz3D entity to the hEntity field... this is what associates the object with a particular model...
finally, CreateObject() will also assign an objID to the new object, fill in that field, and will assign subsequent objIDs to all new objects added to the game that are of this particular subClass...
btw, you should now have 3 files open in your editor... OOEngine.bb, WindowClass.bb, and MyGame.bb...
the OOGameEngine is in OOEngine.bb, the WindowClass.bb is the one you just created, and MyGame is where the actual code for the game is gonna go...
lets go backa step or two, and look at the tObject declaration again... notice the status field... each new object has one and upon creation of the object it is equal to 0... you would use this field in your class implementation to do whatever you need to do during the first time the classes update function is run for a new object... then it is your responsibility to bump it up to 1...
ok, so there you have it... those are the key fields of interest for now... you are now ready to run your game... just remember to include WindowClass.bb and OOEngine.bb... you will see a model of a window appear in your game... and that's about it...
by default you'll be able to move the players view around, but not much else... remember, the window doesn't have any functionality at all, so it just sits there... now you can start adding functionality to your window, and test it as you go along, all of your window class functionality will be in one place, that UpdateWindows function in WindowClass.bb...
you would do the same thing when creating a BULLET class...
now that you have a lil insight to what's going on with the engine, where would the ability to make a window and a bullet object interact go?
well, seeing as the window is going to display the most effect of the interaction, i would put this functionality in WindowClass.bb... one way would be to check for collision between any object that has the subClass "BULLET", and the object of WINDOW class, then play a windows breaking sound, run a particle anim for breaking glass or whatever... and replace the mesh texture with a broken window texture, or have it disappear entirely... whatever you want your windows to do when hit by a slug...
ok... does this sorta explain what's happening... i've tried to keep it simple and straight forward... in actuality, the WINDOW object would wind up being created in the initialization part of a HOUSE or BUILDING class implementation... this way, once you've 'built one window, any new class of object can contain one... or tow, or fifty of em... the same goes for the bullet objects... it would be create by the GUN class object, and be controlled by it (fired)...
... but ya gotta walk before you can run, so a simple implementation just to get your feet wet was all we went into for now.
is anyone really interested in this... if so, i'lll take some time and post it and a lil doc thingee...
--Mike
yeah... it was a bit of a pain until i got the generic engine working... then i saw how i could actually do something with it, and it was actually quite easy and more organized once i got the hang of using it...
@Rook...
how each registered object is linked to a model
take a quick look at the engine's tObject declaration...
Type tObject Field status Field subClass$ Field hEntity Field objId Field maxAllowed Field controlObject.tObject Field name$ End Type
now, say for instance you wanted to create a WINDOW object... first you would create a WINDOW class... this is simply a matter of editing a new file something like this...
;------------------------------------------------------------------------------------------------------ ; ; WINDOW Class Globals Declarations ; ; declare a global specifying the maximum number of instances for this subtype here, and dimension ; each property to this global limit... this gives each new instance of the subclass the capability ; of being manipulated as an individual object via its \objId Field in the subclass Update method ; ; the property names should be unique as to avoid conflicts with other variables in your program ; ;------------------------------------------------------------------------------------------------------ Global MaxNumOfWindows=44 Function UpdateWindows(this.tObject) End Function
notice the classes update function... this is the single function that is continuously called by the engine while it's main loop is spinning... you can leave this function empty for now, a placeholder where you will add all of the WINDOW classes functionality in later...
save this file as WindowClass.bb
next, you would register it with the engine, as described in the above posts (the only time you have to edit the engine code, but it is simple to do)...
once this is done, you could add a new WINDOW object to your game... you would do this in your code using the engine's CreateObject() function... like so...
aWindow.tObject=createObject("WINDOW", theGame\System\HomeDir +"media\house\windows.b3d")
the CreateObject() function is like a lil gameobject factory, where the fields in the TYPE declaration for tObject are filled in...
the subClass$ field gets the first arg, "WINDOW", which is the name of the class...
CreateObject() is also smart enough to check to see if the next arg is a blank string or not, and if not, then load in the model it references and return a Blitz3D entity to the hEntity field... this is what associates the object with a particular model...
finally, CreateObject() will also assign an objID to the new object, fill in that field, and will assign subsequent objIDs to all new objects added to the game that are of this particular subClass...
btw, you should now have 3 files open in your editor... OOEngine.bb, WindowClass.bb, and MyGame.bb...
the OOGameEngine is in OOEngine.bb, the WindowClass.bb is the one you just created, and MyGame is where the actual code for the game is gonna go...
lets go backa step or two, and look at the tObject declaration again... notice the status field... each new object has one and upon creation of the object it is equal to 0... you would use this field in your class implementation to do whatever you need to do during the first time the classes update function is run for a new object... then it is your responsibility to bump it up to 1...
Function UpdateWindows(this.tObject) ; ----------------------------------------------- initialization ; if this\status=0 ;position it ;do whatever else you need to do to initialize each instance this\status=1 endif .... .... ; now do everything else a window does... continuously End Function
ok, so there you have it... those are the key fields of interest for now... you are now ready to run your game... just remember to include WindowClass.bb and OOEngine.bb... you will see a model of a window appear in your game... and that's about it...
by default you'll be able to move the players view around, but not much else... remember, the window doesn't have any functionality at all, so it just sits there... now you can start adding functionality to your window, and test it as you go along, all of your window class functionality will be in one place, that UpdateWindows function in WindowClass.bb...
you would do the same thing when creating a BULLET class...
now that you have a lil insight to what's going on with the engine, where would the ability to make a window and a bullet object interact go?
well, seeing as the window is going to display the most effect of the interaction, i would put this functionality in WindowClass.bb... one way would be to check for collision between any object that has the subClass "BULLET", and the object of WINDOW class, then play a windows breaking sound, run a particle anim for breaking glass or whatever... and replace the mesh texture with a broken window texture, or have it disappear entirely... whatever you want your windows to do when hit by a slug...
ok... does this sorta explain what's happening... i've tried to keep it simple and straight forward... in actuality, the WINDOW object would wind up being created in the initialization part of a HOUSE or BUILDING class implementation... this way, once you've 'built one window, any new class of object can contain one... or tow, or fifty of em... the same goes for the bullet objects... it would be create by the GUN class object, and be controlled by it (fired)...
... but ya gotta walk before you can run, so a simple implementation just to get your feet wet was all we went into for now.
is anyone really interested in this... if so, i'lll take some time and post it and a lil doc thingee...
--Mike