Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Seperating my game into classes  (Read 1128 times)

0 Members and 1 Guest are viewing this topic.

vro

  • Newbie
  • *
  • Posts: 44
    • View Profile
Seperating my game into classes
« on: July 25, 2011, 01:08:07 am »
Hey all, I could use some suggestions for separating my game into classes.

It is a almost-complete Asteroids clone, but my code keeps getting harder and harder to read because everything is in main() besides the projectile class.

So I'm thinking, I'll probably need to separate everything into the following classes:

Asteroid - self explanatory

Projectile - " "

ImageManager - so each class can call a reference to the image it needs to create a sprite instead of loading the images in main()

Game - where everything comes together, the game loop, calling the drawSprite functions of asteroid and projectile, etc.

Does this sound pretty standard so far? And would it be better if I put the control events (say for moving the ship with the up arrow) in the Game class or should they go in the Ship class?

None of the actual work is above me, it's just this is my first game besides messing around with the pong example, so I am not sure how to organize everything.

Thanks!!!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Seperating my game into classes
« Reply #1 on: July 25, 2011, 01:39:41 am »
Recently, a very similar topic was discussed :)

For general C++ design tips, see here.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything