This post is a portion of my mini-series on Object Oriented Game Development using the Allegro 5 library. You can see all of the posts by going to http://fixbyproximity.com and clicking the “OOP Game Development” button at the top of this site.
Full Game Source Here
Videos in the Series:
- Object Oriented Game Development – Intro
- Object Oriented Game Development – Part 1
- Object Oriented Game Development – Part 2
- Object Oriented Game Development – Part 3
- Object Oriented Game Development – Part 4
- Object Oriented Game Development – Part 5
- Object Oriented Game Development – Part 6
- Object Oriented Game Development – Part 7
- Object Oriented Game Development – Part 8
Thank you!
extremely useful, much appreciated.
Hey, this series is the best online about C++ and OO Game Development.
I wish Allegro had an official OO version library also, because I have to write al_create_display() and so..
I enjoyed it a lot, it refreshed me both in C++ and Allegro because I’ve been programming in C# for two years.
Thank you Sir, its a really super useful tutorial, in fact its one of the best available online !
Happy Birthday! I’ve gone through all of your 2-D development courses in the past day and now I’m chugging through these. I guess you could say I’m addicted. Just a quick question for you, what is the advantage of checking for a collision with a pointer? Why not just pass the object itself?
Hey Philip, let me answer that for you! There are two big reasons to pass by pointer. The first is that when you pass an object to a function, it is passed by value, meaning any changes you make to the object in the function will NOT be reflected in the object itself. This makes it impossible for functions to affect anything outside of their scope. By using a pointer, you can change the object anywhere it rests in memory.
The second benefit is that pointers are only 4 bytes big in traditional 32-bit operating systems, making them much smaller than objects. Note that a single int is 4 bytes big, and when you have a dozen of them in an object, sending a pointer instead of the entire object is much faster.
Hope that helps!
Thanks Philip!
The reason you want to pass it in as a pointer, and I may be wrong about this, is if you pass it a non-pointer class, it makes a whole new object, thus taking up more memory. You want to use pointers because it points to the “memory address” of the object.
A better approach rather than using a pointer is to reference the object. Effectively you are passing the object by-reference rather than by-value.
bool isCollidingByAABB( AABB& _object ) ;
This removes the ‘pointer symbology’ that can cause confusion, particularly if dereferencing is required, and provides greater safety at compile time.
thanks ,men, rly u precised me how works public funtions with obiects variables
i mean
“loatSetX(float x) { GameObject::x = x}”
All parts of tutotial was awesome
I cannot begin to tell you how amazing these tutorials have been, I just finished the regular 2D tutorials and I have such a good understanding of not just the allegro 5 library, but also the mindset/approach to writing games. I am looking forward to these tutorials too, I already know some OOP but I am eager to see how to utilize efficiently for games. My only question is:
Why do you use Init functions when you could just have Constructors with parameters?
Can someone write what exactly functions CheckCollisions and Collided do ? Because I can’t understand as it is said too fast for me and english is not my native language. I will be very greatful