Here, I am demonstrating how I typically handle my actor objects when making games using an object-oriented approach. I like all of my game entities (like the player and NPC characters) to be their own objects with methods that are common to them (update and draw being the main needed items).
The snippet here is my starting templet for most of my games. The "Actor" table is my default object. The method "New" can be used for two things:
- creating a subclass which will inherit all properties and methods of actor, unless they are overwritten explicitly
- instantiating the "actor" into the game
If you are looking for a code snippet to get started and you want to use an object oriented approach, I encourage you to give this a try. Thanks!
[Please log in to post a comment]