Sign in to follow this  
NoodleCandy

Questions about different pieces of a game

Recommended Posts

NoodleCandy    139

Hello there,

 

I'm looking to make a small game (more of a tech demo, really). I have some experience programming in C++ and am even currently playing around with OpenFrameworks. With OF, I've learned to draw shapes, move them, and even do very simple collision detection between them. I'm very inexperienced with making games through object oriented programming though so I'm hoping you people could guide me in the right direction.

Currently in the middle of learning vectors and storing instances of an object within it and my end goal is to create a top-down 2D game where shapes will be spawned by an EnemySpawner class. These shapes will fly at the player character which will be controlled via mouse and said shapes are erased once off-screen. I have an idea of how I'll structure the classes but I'm unsure if there are tools I can learn to make some tasks easier.

 

For example, if there were 20 shapes on-screen at once, I could run a loop that will check any intersection between those shapes and the player or the edges of the screen. Is a loop really the way to go about this or could some sort of game framework abstract this away somehow? I'm talking out my ass due to inexperience but these are the kind of issues I'm wondering about.

Share this post


Link to post
Share on other sites
NoodleCandy    139

Thanks for the reply! I'm also now bookmarking your signature's tutorials ph34r.png

 

I agree with what you've said, in that I should start with baby steps. It's just I look at my brute force loop code and can't help but be disgusted. I see your point in:


Finding a framework or being told a better way to do it will be doing you a disservice.

However, that's the problem I'm facing at the minute. I'm not entirely sure how to find more efficient ways myself, though I'm about to look up tutorials on the things you've mentioned like occlusion. I suppose I was asking to skip too much when I asked about game engines, it's just that I wasn't sure if I should be using them to speed up learning. Perhaps what I should have asked for is tutorials?

Share this post


Link to post
Share on other sites
EddieV223    1839

I agree about trial and error.  However I'd like to add that using resources is also a good thing.  There are books about how to make engine components, like Logging, Resource Management, Rendering ect...

 

If you are doing 2d I would suggest reading the new SFML2 book in my signature.  They build a large framework in it. 

 

Also there are a few books about 3d engines that go in depth into the components of an engine.  Some good ones are the links below.

 

I read this one, its good for learning about each engine component seperately.

http://www.amazon.com/Game-Engine-Design-And-Implementation/dp/0763784516/ref=sr_1_3?ie=UTF8&qid=1383156729&sr=8-3&keywords=game+engine

 

I read this one too, its good for learning how to write an entire 3d engine from scratch

http://www.amazon.com/Game-Coding-Complete-Fourth-Edition/dp/1133776574/ref=sr_1_4?ie=UTF8&qid=1383156774&sr=8-4&keywords=game+engine

 

I haven't read this one but people seem to like it

http://www.amazon.com/Game-Engine-Architecture-Jason-Gregory/dp/1568814135/ref=sr_1_1?ie=UTF8&qid=1383156774&sr=8-1&keywords=game+engine

Share this post


Link to post
Share on other sites
Serapth    6671

Thanks for the reply! I'm also now bookmarking your signature's tutorials ph34r.png

 

I agree with what you've said, in that I should start with baby steps. It's just I look at my brute force loop code and can't help but be disgusted. I see your point in:

 

 


Finding a framework or being told a better way to do it will be doing you a disservice.

However, that's the problem I'm facing at the minute. I'm not entirely sure how to find more efficient ways myself, though I'm about to look up tutorials on the things you've mentioned like occlusion. I suppose I was asking to skip too much when I asked about game engines, it's just that I wasn't sure if I should be using them to speed up learning. Perhaps what I should have asked for is tutorials?

 

Again hands on is the best way to do it.  There arent actually a ton of tutorials or books about optimization, especially not aimed at the beginner level.  You can get things like Game Programming Gems, but those books are aimed more towards experienced game developers.

 

 

My suggestion to you, implement it however you can, clean your code up until you are happy with it, then create a thread here or somewhere else asking for recommendations on how to improve it.  This really is one of those things experience will teach you.

Share this post


Link to post
Share on other sites
NoodleCandy    139


If you are doing 2d I would suggest reading the new SFML2 book in my signature.  They build a large framework in it.

 

I'll be having a look at those for sure, since 2D is definitely the direction I'll be going for now until I feel comfortable.

 


Also there are a few books about 3d engines that go in depth into the components of an engine.  Some good ones are the links below.

 

Those books seem very interesting and I notice that the Game Engine Architecture book has a segment about good C++ coding practices. Hopefully these books will answer the question I originally had which was:"What the hell does a game engine even do?"

 


My suggestion to you, implement it however you can, clean your code up until you are happy with it, then create a thread here or somewhere else asking for recommendations on how to improve it.

 

Great! I'll be experimenting using your C++ with SFML and 2D Gamedev math tutorials so I hope you'll keep imparting wisdom on such things.

 

 

One thing; as I mentioned in my original post- I've been toying around with OpenFrameworks. The reason for it is that, to my understanding, it wraps a whole bunch of libraries into one which seems to be similar to what SFML does. Graphics, audio, windows, events, some math, etc. Would you have any idea if SFML does anything special that OpenFrameworks can't do? At the moment, OF provides a very easy interface to FMOD which I need for Fast Fourier Transforms. I'm hoping I could keep a portion of my code using OF.

Share this post


Link to post
Share on other sites
L. Spiro    25622

I’ve written a tutorial on a very fast quadtree structure that can be used to speed up collision tests with each other, the player, edges of the screen, etc.

Efficient Instant-Insertion Quadtrees

 

It performs extremely well even on low-end devices, but it is not a good starting point if you want to learn about quadtrees in detail, although I doubt it is too advanced to figure out if you put your mind to it.

 

A quadtree of any kind (mine or your own) would be the next step up in looking at how to get performance out of collision detection and there is plenty of material online about their concepts.

 

 

L. Spiro

Share this post


Link to post
Share on other sites
NoodleCandy    139


Efficient Instant-Insertion Quadtrees

 

Thank you for the reply but my eyes melted a little. I think I understand the premise but the implementation is something that will probably take a while to wrap my head around.

Share this post


Link to post
Share on other sites
Gureen Ryuu    162

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.

Share this post


Link to post
Share on other sites
Tutorial Doctor    2573

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. 

Share this post


Link to post
Share on other sites
NoodleCandy    139
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this