I can't get into this too much, but here's a really simple example of stuff that's already been posted here...
(Note that ':' is what replaces the current '.' and '.' replaces the current '\'... slightly off-putting at first but you'll get used to it.)
For those not familiar, 'methods' are basically just functions specific to the type, and can operate directly on the type fields (hence x and y in the methods above refer to the x/y fields of the Player type).
In the above example, I create an object of type Player (p:Player) and call its Update method in the main loop. The x/y fields are initialised to the centre of the screen when the object is created (optional).
The Update method above also calls the Draw method, partly just to show an example of more than one method, and partly because doing it this way means you can create different object types based upon this one ('extending' the type) and just have to replace ('override') the Draw method to make the new type draw differently:
(So objects of type 'Rocket' have all the same fields and methods as 'Players' but the Draw method is changed.)
There's loads more to it, of course, and you can do some really powerful stuff, but I won't go any further since everything is subject to change.
Anyway, I've always hated OO because I feared it until now, but once you've done a little of this yourself, you'll probably find you want to keep doing things this way. Speed has not been an issue.
(And for anyone horrified by this stuff, you can of course just carry on much the same as you do now!)
------------------------------------------------------------------------------- Object definition... ------------------------------------------------------------------------------- Type Player Field x = GraphicsWidth () / 2 Field y = GraphicsHeight () / 2 Method Update () If KeyDown (KEY_LEFT) x = x - 1 If KeyDown (KEY_RIGHT) x = x + 1 If KeyDown (KEY_UP) y = y - 1 If KeyDown (KEY_DOWN) y = y + 1 Draw End Method Method Draw () Rect x, y, 8, 8 End Method End Type ------------------------------------------------------------------------------- Demo usage... ------------------------------------------------------------------------------- Graphics 640, 480 p:Player = New Player Repeat Cls p.Update () Flip Until KeyDown (KEY_ESCAPE)
(Note that ':' is what replaces the current '.' and '.' replaces the current '\'... slightly off-putting at first but you'll get used to it.)
For those not familiar, 'methods' are basically just functions specific to the type, and can operate directly on the type fields (hence x and y in the methods above refer to the x/y fields of the Player type).
In the above example, I create an object of type Player (p:Player) and call its Update method in the main loop. The x/y fields are initialised to the centre of the screen when the object is created (optional).
The Update method above also calls the Draw method, partly just to show an example of more than one method, and partly because doing it this way means you can create different object types based upon this one ('extending' the type) and just have to replace ('override') the Draw method to make the new type draw differently:
Type Rocket Extends Player Method Draw () Oval x, y, 32, 32 End Method End Type
(So objects of type 'Rocket' have all the same fields and methods as 'Players' but the Draw method is changed.)
There's loads more to it, of course, and you can do some really powerful stuff, but I won't go any further since everything is subject to change.
Anyway, I've always hated OO because I feared it until now, but once you've done a little of this yourself, you'll probably find you want to keep doing things this way. Speed has not been an issue.
(And for anyone horrified by this stuff, you can of course just carry on much the same as you do now!)