Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've been tasked with writing an essay extolling the virtues of object oriented programming and creating an accompanying game to demonstrate them.

My initial idea is to find a tutorial for a simple game written in a programming language which does not follow the OOP paradigm (or written in an OOP language but not in an OOP way) and recreate it in an OOP way using either C# or Java (haven't yet decided). This would then allow me to make concrete comparisons between the two.

The game doesn't have to be anything complex; Tetris, Pong, etc. that sort of thing. The problem I've had so far is finding a suitable tutorial, any suggestions?

share|improve this question
1  
You don't say what paradigm you want to use as an alternative. Just look up tutorials for functional programming, it's one of the more popular alternatives. Give Haskell a try. It'll take a bit to wrap your head around, but it's fun. However, this isn't the site for people to answer with specific tutorials. Only you know the right tutorial for you. –  Byte56 Nov 14 '12 at 5:06
    
What exactly do you mean by "object-oriented"? You're not going to find very many programs in any language that don't collect related data into object or employ data hiding (they even do it in C libraries all the time). So what is it that you're not looking for? –  Nicol Bolas Nov 14 '12 at 6:10
    
By "does not follow OOP paradigm" you mean do not use inherence and things like that or don't even use classes etc. (i guess you can use class since you talked about Java and C#). Maybe you should take a look at Entity/System based games. t-machine.org/index.php/2007/09/03/… –  nathan Nov 14 '12 at 8:07
    
You want an A? Write a paper about why the underlying assumption of this task is incorrect. OOP is not more or less virtuous than any other properly constructed paradigm's approach to game code. It depends on the game in question, and different paradigms would ideally be used throughout a game's construction depending on the need. Component-Base Programming is best for entities like the player and enemies, Aspect Oriented Programming is best for many over-arching systems, Automata Based Programming is ideal for many kinds of AI. –  DampeS8N Nov 14 '12 at 16:22
    
@DampeS8N Not disagreeing with the general sentiment, but if the goal is to get high marks on an essay, then I really don't recommend being confrontational about what you interpret your professor's underlying assumptions to be. Particularly based on second-hand expertise. –  Trevor Powell Nov 14 '12 at 22:44

4 Answers 4

up vote 3 down vote accepted

You'll need something non-OOP to contrast with, which isn't just a bunch of spaghetti in which any clean or well structured code will be an improvement. Here are a few links to non-object oriented approaches that you can look at.

Functional programming in a few flavors:

Declarative or rule-based systems, like prolog or Inform 7 for text games:

Even with OOP it's not obvious that an inheritance heavy class hierarchy is the only approach. Component entity systems are another way to structure your game objects:

share|improve this answer
    
+1 for the first sentence, and for a generally concise and informative answer. –  jco Nov 14 '12 at 14:54

A really solid example would be Frag as FPS written in Haskell. However it will be too complex to grasp without good Haskell knowledge. As for tutorials based on non OOP game programming then this series of articles will explain Entity Systems.

I would point out though that starting with the conclusion and working back is going to be a pretty terrible way to write an article. In fact if you read this article talking about Entity Systems in 'Tony Hawk' games there is a solid case to be made for the idea that OOP is NOT the best technique to use in performant game design.

Good luck on your journey, I hope the articles are illuminating!

share|improve this answer
    
+1 for those entity system articles. –  jco Nov 14 '12 at 14:53

Maybe try making a text based game where all the commands are if else type statements. Maybe a more liner game would be best, think something like a choose your own adventure book. That would be a simple example of procedural programming. I suppose you could argue that variables of any sort are objects but they have those even in assembly so I'd say they are okay. This may even be the time to use the dreaded goto statement as even though it may not be best practice it would work in this situation

share|improve this answer

I've seen a couple of programming tutorials based on non OOP languages, mostly C. If you Google "C game programming tutorial" or similar then you should find them, however there are certainly more tutorials for OOP languages - after all, tutorials are aimed at beginners, and for beginners modern OOP languages (especially those like C# and Java) are easier to get started with than languages like C.

If I were you I would do the reverse however - write a simple game using OOP techniques, and then work backwards converting the same code so that it doesn't rely on any OOP features. With a simple game this should be quite achievable and if you use something like C/C++ a lot of your code will look very similar in both versions.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.