PDA

View Full Version : What are the real benefits to OOP? Especially in relation to flash gaming?


kilauea
06-13-2008, 04:42 AM
I learned all the actionscript I know a while back, and thus it was all based in AS2. I'm finally getting back to a project that got put on hold and all the coding is in AS2 and I'm trying to figure out where I'm going to go now.

My project is a point and click adventure game similar to the old Sierra classics (Kings Quest, Space Quest etc). Basically I'm just trying to figure out if its worth it to convert everything over to AS3, and if I do what benefits does that have, and specifically what benefits does OOP offer?

The coding I have done is point and click movement that triggers an animation on the main character and also collision detection that works with the scene and keeps the character within the "walls" (though I think this needs to be reworked anyway, actually if anyone can direct me to an AS3 tut or a resource that would help me make collision detection that would keep a character walking through a setting from going areas they aren't supposed to - in other words not just super simple but a way to build walls).

Thanks for any help in advance.

NickZA
06-13-2008, 05:23 PM
I would say this is going to depend on the scope of your game.

Procedural programming (i.e. using only functions, no objects) is often quicker to develop small things with. That's why a lot of prototype / proof of concept stuff you see done in Flash is written on one frame of the timeline -- no class files. This is not to say their authors do not usually write their programs using the OO approach when working on larger projects.

OO reduces repetition. It clarifies and gives meaning to how code is structured and utilised. If you make use of the fundamental OO principles WHILE USING objects, you can improve your productivity, and the maintainability and extensibility of your codebase, enormously. If you don't make use of these principles, you will still probably end up with something more maintainable than a typical procedural program. Procedural code rapidly becomes unmanagable for most of us.

It takes a bit of time to draw up class diagrams and understand how your objects are going to interact but as an OO adherent I cannot tell you I would do it any other way -- if for nothing else than how readable (and thus maintainable) this aproach make your code. IMHO, the only place for procedural/non-OO programming nowadays is in languages where:

-Classes are simply not supported by the language in question;
-Execution speed is absolutely crucial (eg. embedded programming, mission-critical real-time programming).

Even with AS2's half-baked support for objects, I would still build anything bigger than the smallest program (400-500 lines) using objects. :rolleyes:


Search these sites for collision detection methods:

8bitrocket.com - AS3 collisions but you need to implment your graphics using BitmapData, i.e. bye-bye MCs

gotoandplay.it - AS2/3 gaming tuts

tonypa.pri.ee - AS2/3 gaming tuts

...and even Kirupa.com.

rrh
06-14-2008, 05:50 PM
My favourite attribute of OOP in the context of games is polymorphism.

I recently posted an explanation of why I like it over on Kirupa:
http://www.kirupa.com/forum/showpost.php?p=2337304&postcount=9

bowljoman
06-16-2008, 04:37 PM
My favorite OO procedure is developing the game base class framework, and creating the interfaces allowing it to be extending it into different game types.