Hello!
I'm working on developing a Space Defender game in VB, where the player's main ship is represented by a class module. This is mostly to learn more about classes and creating an object that is as stand-alone as possible. I realize that the object should "encapsulate" all the methods and variables it needs in order to act as an object, allowing the client code to be ignorant of its internal being.
My question is concerning the bitmap image of the class.
On one hand it seems that I should try to make the bitmap part of the class, in keeping with the encapsulation theory, and allowing the game engine to focus on game stuff, not object stuff. But a class module can't (that I know of) maintain its own reference to a bitmap, which forces me to either load it from a .bmp file, or reference a picturebox on a different form in the app. (in both cases, my class's intelligence is scattered around, defeating the purpose.)
On the other hand, if the game engine has to update an object's bitmap every time it moves or explodes, does that not also kill the benefit of OOP? Which is the better tecnique? I'm trying to get a good handle on objects in order to smoothen the transition to C++. Thanks to all for any input.
Mike
I'm working on developing a Space Defender game in VB, where the player's main ship is represented by a class module. This is mostly to learn more about classes and creating an object that is as stand-alone as possible. I realize that the object should "encapsulate" all the methods and variables it needs in order to act as an object, allowing the client code to be ignorant of its internal being.
My question is concerning the bitmap image of the class.
On one hand it seems that I should try to make the bitmap part of the class, in keeping with the encapsulation theory, and allowing the game engine to focus on game stuff, not object stuff. But a class module can't (that I know of) maintain its own reference to a bitmap, which forces me to either load it from a .bmp file, or reference a picturebox on a different form in the app. (in both cases, my class's intelligence is scattered around, defeating the purpose.)
On the other hand, if the game engine has to update an object's bitmap every time it moves or explodes, does that not also kill the benefit of OOP? Which is the better tecnique? I'm trying to get a good handle on objects in order to smoothen the transition to C++. Thanks to all for any input.
Mike