Questions about different pieces of a game

Started by
10 comments, last by NoodleCandy 10 years, 6 months ago

You are probably far better than I am at programming, but I have one rule when I start programming:

Keep it Simple.

I always try the most obvious and simplest route first, even though it may not be the fastest.

I also try to do things they way the happen in real life.

As for OOP:

If your class has a function that destroys the object once it's X or Y position reaches a certain point, then that will apply to every object that is a part of that class. That is the cool thing about classes. A fruit is a fruit. An apple is a member of the fruit class, and an orange is a member of the fruit class. Whether apple or fruit, both can be eaten.

I don't know if you know of a clone system or not that you could use, but that is one way to keep it fast so that only one object is being rendered. The rest are clones and don't have to be rendered individually.

You could also take advantage of arrays as well. Someone wrote a 3d particle system that was fewer than 200 lines, although they already had a pre-made clone function.

Just a few tips.

They call me the Tutorial Doctor.

Advertisement
Will you be using physics in your game? If you are, libraries like Box2D will do the collision detection for you and you just handle it in the callback functions it gives.

I hadn't thought of using physics in my project apart from velocity and collision detection (Do those things even really count as physics?) but thanks, I'll be checking out Box2D. EVEN BETTER is someone made a wrapper for Box2D for OpenFrameworks which hopefully means great things! At first glance, it seems like Box2D might be overkill but we'll see how that goes.

If your class has a function that destroys the object once it's X or Y position reaches a certain point, then that will apply to every object that is a part of that class.

That is cool as hell. For my implementation, I actually had the brute force looping and logic for this done in my game loop instead of in the objects' classes. So while I had classes, I wasn't using them properly sleep.png

I don't know if you know of a clone system or not that you could use, but that is one way to keep it fast so that only one object is being rendered. The rest are clones and don't have to be rendered individually.

I have not heard of this until now and it doesn't make sense in my head. Only one object is being rendered? Say I have 3 circles bouncing around on screen, wouldn't they all need to be rendered and each would have their own attributes: velocity, radius, etc.? I'll do some reading on this when I get the time but that idea made my head hurt.

You could also take advantage of arrays as well

I originally used arrays as in the old school array[size] for keeping track of objects but I was told "VECTORS ARE THE FUTURE!!!!" so I'm using them now. I wouldn't be surprised if someone will yell:"NO VECTORS ARE OLD AND BUSTED, X IS THE NEW HOTNESS"

You are probably far better than I am at programming

GUESS AGAIN

I do try to keep my code as simple as possible, but I think I might be overdoing it. As in, I get paralyzed with fear that my code might not be simple enough.

Back to asking questions: would anyone have nice game-centric tutorials or resources for things like dynamically spawning enemies in-game? I have some ideas in my head like "Spawn an enemy if variable x is y. Upon spawning, set the enemy velocity to be hurtling at the player's position at the time of spawning" and such.

I currently have logic that drives this outside in my game loop. Like Tutorial Doctor mentioned, there is certain code that could be placed into a class so it'd be nice to have tutorials that would break these kinds of things down to a fool like me. I'm currently on the lookout for books from here: http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list but I get the feeling these books won't have fun tutorials so it'd be nice if there game-centric ones out there.

This topic is closed to new replies.

Advertisement