The Object Oriented Game Approach Part 1: Objects
(For the next series of articles, I would assume that programming would be a fundamental part of one’s body, if not, then go practice! Also ,you need to brush up on some Object Oriented concept. Happy Reading)
Today, we would be tackling about Object Oriented Paradigm, in relation with Game Programming. For now, think inside the box.
First picture a room, say for example picture a computer room.
What should be inside this kind of room? More or less we can see a number of CPU’s, keyboards,mouses,monitors,cables and maybe one or two printers.Is the room airconditioned? Then you can probably feel a little cold inside this room. Hear some music or probably some noise? Is a sound system probably present too?Also, you should not forget about the tables and the seats where the computers are, or the AVR’s where the computers are hooked too! Have you gotten a feel of the room yet?
Planning is almost always done first instead of just rushing in and just coding whatever pops out of the mind. Coding without planning is only done for those things that need to be crammed. Game programming shouldn’t be one of them.
Now proceed to the next step. Ask yourself these questions:
a)Where are you again?
b)How many objects are in the room?
c)Why are these objects here in the first place?
d)What is the purpose of a specific object?
e)How does an object work?
f)What are the functions of these objects?
Let us answer these questions , respectively, based on the given premises earlier,. First of all we are in a computer room which is probably airconditioned. So we could say that there is an aircon, that which would count as our first visible object. To reduce your counting workload, we could say that there are computer parts (keyboard,mouse,monitor,CPU,AVR) which can be collectively termed as computer sets. There are probably, at least 2 computer sets inside the computer room, so include them in the count, say x. Don’t forget the miscellaneous gadgets/items (cables ,printers, sound system) which we could say count y. All in all, we are sure that there are at least 2 objects in the computer room, and x+y more object sets.
Now why are these objects here? They are probably serving the purpose of being in the computer room. For example the purpose of the aircon is to control the temperature to a level that an entity using the room won’t be too flustered by heat or cold. Also, since this is a computer room, the computer sets, collectively perform the task. Let us focus on a computer set. It has been assumed that the computer set has a keyboard, mouse, monitor, CPU, and AVR. How are these objects related? Take for instance the mouse and the keyboard. Their primary use is to navigate the computer, like what a steering wheel does for a car. Can the computer be functional without a mouse or a keyboard? It would probably still work, but it will not serve your purpose Unless you have another means of navigating/controlling the computer, which for this case , no other alternatives where given, the computer would be useless without a mouse and keyboard.
Moving on how is this related to game programming?
- First of all, in game programming, we should take note of the things that we need, and are essential to development of the game. From the language and engine that we will be using, to the device required by the games. You don’t expect a user to play a iPhone like “touch-based” game on a personal computer, nor the other way around, unless they have the alternative to control the game otherwise.
- Second, this Object Oriented Paradigm gives us the sense of a real-world-like thinking pattern in a way that we could think of things that we will be using. For example, we could simulate the way objects interact in the real world and translate it into code. If an object collides with another object, won’t it be proper that some kind of event happens? If a car crashes to a tree or another car, won’t that be somewhat a part of realism?
- Third, a lot of games are designed in the Object Oriented way of thinking because codes will become more portable and usable for other workers as well. For example, rather than create a new car for each instance of car in your game, why not just extend a current model for a car? It probably has a lot of things that you would not need to remake/recreate anymore
- Fourth,as codes for objects and events are reusable, building a similar or a sequel game will provide to be a lot easier, than always recoding all the same objects as before.
- Lastly, most object oriented game designs give porting to another system a perspective because the SDK(Software Development Kits) more or less, feature a similar set of functions. Also, you don’t need to recode much of your game’s impotant items, except for required system calls. For example, the game MyBrute first appeared in personal computers as a webgame. Because it was a hit in the web, it was ported as an iPhone app, which also became a hit. It was enhanced during porting because the controls are not limited by the keyboard and the mouse, but given a new light by the touchscreen interface
These are only a few of the so many reasons why you should definitely practice this Object Oriented approach in thinking and not only confined by Game Programming.

