This post is a portion of Part 8 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.
- 8.0 – Structured Sprites
- 8.1 – Our Sprite Struct
- 8.2 – Sprite Struct Demo
- 8.3 – Sprite Struct Gravity Demo
In this last video of Part 8, we are going to look at taking our Sprite Demo’s a step further. We will program an application that moves sprites around the screen while simulating a gravitation pull. What I mean by that is that each object will be attracted to every other object. The result will be sprites that all move relative to each other. It is pretty neat!
Full source can be found here.
Can u give me “space-core.png” file.
Thank U
😀
I mention where to find it in the videos. I cannot give it to you as it is not mine to give. Go to the website I show in the video and get it from there.
Ok, thank u 😀
Freaking neat!
Hello mike, how about you add more notes in the source file , although your videos are pretty cool, but sometimes when i just wanna save some time and skip the video, just read the code, i find it weird without enough notes, thank you very much….
I would prefer not to double up on work. The source code is meant to assist with the video learning, not the other way around. I would recommend not skipping the videos if you are having a hard time understanding the code without notes.
Wow, what a great tutorial! Thanks a bunch, kind believe I have actually just coded and compiled something like this 😀
Hi Mike, loving the series! It’s really helping with my Procedural Programming course!
My question is how would I go about implementing this into a platformer? So that a character will jump naturally with gravitational affects.
Hey Mike, the “FPS” count being shown on the screen in the downloadable code is instead a “TEPS” (Timer Events Per Second) count because it is incremented inside the processing of the timer event and not where the frames are being drawn. The current logic WILL fail to translate to the count of “FPS” under high load (or on a computer with very limited graphics processing) because of this flaw.
I’m very happy with the tutorials that you are doing and I look forward to finishing them as I update and complete the final project from my game programming class 5 years ago. Thanks for your time and effort!
Your comment has been updated with the clearer information. Sorry for the miscommunication. You are correct. I am using the term “FPS” incorrectly, as my intention is to show update frames, not actual rendering frames. I just opted to use the term “FPS”.
Thanks for the comment
Sorry I am having trouble finding the video where you mention the web site where to get space-core.png I must be missing, I did see it once.
Sorry
Franco
hello mike first of all thank you for those tutorials ..but can u please tell me how to use mouse and keyboard inputs at the same time!
Hello Mike, thank you for the tutorials. I found that the number of sprites will cause the display never be drawn if the number is larger than about 250. I think it is due to the cost of AttractParticles(…). If this function take more than 1.0/60 seconds, the event queue will filled by ALLEGRO_EVENT_TIMER. Then, al_is_event_queue_empty(event_queue) will never return true, so it will never render the display.
I try to modify the code as follows:
if(render == false) {
AttractParticles(orbs, numSprites);
for(int i = 0;i < numSprites;i++)
UpdateSprites(orbs[i]);
render = true;
}
It can render the display with low FPS when the number of sprites is large.
I benefit from your tutorials a lot. Thank you very much!