Skip to main content
gamedev.net
🔒 Locked

Source Code Organization

Started by Ecco2000 Sep 19, 2000 at 12:52 AM 4 replies 400+ views
Original Post
Ecco2000
Ecco2000
I''ve been playing around with various API lately, and have decided to put my knowledge to use. But I am having trouble "organizing" my code. I''ve seen people use classes and i''ve seen people use modules. I''m just kinda curious which would be the easiest to start with. P.S. anyother code organizing pointer would be appreciated
"Don't make me come down there..." -GOD
Zipster
Zipster
It really depends on what you''re trying to accomplish. What do you have in mind?
Knarkles
Knarkles
I use modules implemented as classes.

-Jussi
Ecco2000
Ecco2000
Well I was thinking of a simple 2d space game that you could fly in the xy direction and the stars wizz by but i tried the module approach and could figure out where to put abstract things like draw player, check keys, etc.
"Don't make me come down there..." -GOD
a2k
a2k
what''s the diff between classes and modules? aren''t modules just those functions that are grouped in a logical set of events? cuz, i would like to think that i have all my classes and stuff, and the modules drive the class objects.

so, in my code, i pretty much have my NOUNS as classes, and my VERBS as modules. isn''t this right? good? bad? no?

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Qoy
Qoy
By modules, I''m assuming you mean just .cpp/h files filled with functions that are global, rather than belonging to a class. There''s no correct way to do this.. I think it depends on how you think. If you think of your graphics engine in terms of an engine object that you call functions on, use a class. If you think of your graphics engine as just a series of functions, then just do it in a module.

I personally mix these two approaches (as I''m pretty sure a lot of us do). For example, I have my image drawing code in a series of functions in a module: LoadBitmap, DrawBitmap, etc... But I have my enemies in classes, with a base and then specific enemies derived from that.

Object orientation and classes make more sense for some aspects of a game, but not all. There''s no rule that says you need to use only one approach, so I would go with whatever seems natural for whatever part you''re implementing at the moment.

Hope this helped a little.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.