Allegro.cc - Online Community

Allegro.cc Forums » Allegro.cc Comments » don't abandon me

This thread is locked; no one can reply to it. rss feed Print
don't abandon me
Loki66
Member #17,089
May 2019

Hello to all
nobody answers my threads (see problems with collision algorithm)
I want to learn and I would like to contribute to this site.
Don't abandon me

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Loki66, as you may have noticed, there aren't many people left on this site to answer your question.

I've seen it, but collision detection can be quite the involved discussion.

I was going to post my solution, but it doesn't always work. Circle circle collision can be very complicated. Of course a simple overlap check will work for low velocities, but not for high velocity. I have the opposite problem, my intercept based detection algorithm works well for high velocity, but not low velocity.

You can view my intercept library Merlin here :

https://github.com/EdgarReynaldo/Merlin

EDIT
The main intercept calculation is done in Intercept.cpp :
https://github.com/EdgarReynaldo/Merlin/blob/master/src/Intercept.cpp

Also, as I said, it can be a very involved discussion.

May I ask, what is your native language?

jmasterx
Member #11,410
October 2009

I'd guess Italian

Mark Oates
Member #1,146
March 2001
avatar

Circle circle is not very intuitive to grasp at first.

The best solution I know of requires subdividing the frame's timestep (usually a frame's timestep is 1/60 per second). The technique involves calculating all the collision times for all of the circles in that timeframe, finding the smallest sub-step in that frame, moving time forward up to the sub-step and changing the trajectories of those two colliding circles.

At that point, you may have some "remainder" time in your frame. Rinse and repeat until you have used the entire 1/60 timestep.

That accounts for all circle sizes, all velocities, can handle all the multiple sub-collisions and reactions that can occur within a frame, and is actually quite performant! :)

I could go into the math involved in "calculating all the collision times for all of the circles in that timeframe" if anybody's interested. It's actually a really fun algo to implement. :)

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

In my Merlin library I used a collision table. (N x N-1)/2 pairs of possible collisions. When you calculate an intercept it never changes unless the object's velocity or acceleration change, so no need to recalculate it. Simply sort the collision times ascending on time and apply in order. Each time a collision occurs, you need to recheck both objects entries in the collision table, resort, advance time, etc....

BitCruncher
Member #11,279
August 2009
avatar

This kinda begs the (probably already asked) question: Where the heck is everybody? I guess they just moved on? I remember when this place was happening :-/.

Mark Oates
Member #1,146
March 2001
avatar

They're here.

I wouldn't be surprised if most of them are reading this right now.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Onewing
Member #6,152
August 2005
avatar

In the shadows, they wait, growing stronger, to rise yet again.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Mark Oates
Member #1,146
March 2001
avatar

Fuk yuh

Onewing in the house.

Bam, what you been up to?

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Rodolfo Lam
Member #16,045
August 2015

From time to time you can see people in the online users tab. They just don’t talk or prefer not to.

Loki66
Member #17,089
May 2019

Hi Edgar Reynaldo, I'm italian.

I tried to compile your Merlin projects, but it gives me errors because it can't find allegro.h in *.hpp header
#include "allegro5/allegro.h"
I tried to modify include
#include <allegro5/allegro.h>
but he does not find it the same
in the * .cpp source files there is no problem. Why?

I found a site that looks interesting:
https://www.toptal.com/game/video-game-physics-part-ii-collision-detection-for-solid-objects

Thank you all for your help

jmasterx
Member #11,410
October 2009

Loki66 said:

Hi Edgar Reynaldo, I'm italian.

No weigh! :o

Mark Oates
Member #1,146
March 2001
avatar

Wow Loki66, that is one killer tutorial! Nice find! And thanks for sharing. :)

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Mark Oates
Member #1,146
March 2001
avatar

He doesn't weigh anything?!

Weight a minute! 🤔

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Loki66
Member #17,089
May 2019

Hello to all
thanks Mark Oates, the tutorial is divided on three web pages.
What is interesting for collisions is towards the end of page 2 where there is the collision algorithm:
Continuous Collision Detection.

Edgar my English is not good, I also started using visual basic in 2018 and
C ++ in early 2019. I'm a beginner!
I thank you for the patience you have

jmasterx you guessed my nationality, good boy

I would like to ask SiegeLord if it is possible to have the mouse coordinates, event.mouse.dx and event.mouse.dy float format.
It would be great for games like "air hockey", the vectors created by moving the mouse would be accurate

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

bamccaig
Member #7,536
July 2006
avatar

Bam, what you been up to?

Mostly avoiding hard work, consuming mind altering substances, and fearing impending doom. :-/ Meanwhile, my wife keeps steering us toward a normal life so I'm probably going to end up knocking her up within a single gesture of available "receptivity" and then wish to goodness sakes I could still afford, let alone be socially allowed to be, fucking rekt.

Cannabis has been legal in Canada for a year now. Shouldn't you be baked right now too?! >:(

Append:

My post was pretty derailey, but in my defense also pretty baited. Let me see if I can contribute something:

If you want to build it you'll need to edit the .cbp projects to change the include and linker search directories to find allegro.

I feel like this is a major failing of any IDE. There needs to be a shared configuration, and it needs to know of "environmental variables" and help the user to figure those out. To me editing a CBP would be like editing the Makefile. If I need to edit the Makefile then you fucked up. I might need to override some settings in my environment, for example, but I shouldn't need to edit the Makefile.

I think that's mostly a symptom of Windows, but perhaps it has contaminated GUI's in general. I avoid GUI's. Good commands cannot be beaten. :)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Loki66
Member #17,089
May 2019

Hello to all
I made an algorithm from an equation I found on this site:
https://www.toptal.com/game/video-game-physics-part-ii-collision-detection-for-solid-objects

Attached there is a "word" file in which there is the algorithm and a folder with the program in which two circles move and collide (02 Algoritmi.rar).

If anyone wants to try it, can you tell me if it's ok or not?

Edgar Reynaldo, I ran your projects and read them, but I don't know C ++ enough to understand your program.

We don't kill this site

Go to: