I've scoured gamedev for around 45 minutes, but I'm unable to find a detailed approach to implementing a movement and collision system for games - specifically, when to use which process, and what to do in them.
CONTEXT: I've made around 20 2-D games, most of which are physics simulators. I have a pretty good knowledge of AWT graphics (too deep into it to start javafx). My games are usually structured like this:
function 'move' inside a particular object: move the object if the object has collided into an immovable object like the ground: escape from the immovable object change velocity accordingly if the object has collided with a movable object: the current object should retrace its path to escape collision change both velocities accordingly and move each object with their velocity ONCE call the function 'move' for each object
I'm completely uneducated in game development, and I've gotten a bit too comfortable with this flawed system because it has worked for almost every one of my games.
I've been studying a lot about game dev online, so I'm trying to make a system where every object moves freely once, then all their collisions are logged and resolved, in that order. But I'm still unsure how to resolve the collision.
This question: Collision Resolution is pretty much the same as mine, but I still can't understand when I should change positions and velocities. Should I change both at the same time on collision detection? What happens if you collide into an object, so you retrace your steps, but now you've collided with something else?
If anyone can link a more concrete question / answer, I'll be immensely grateful. I'm using vectors to store the position and velocity of each entity (player or npc), if that's helpful.
What property of an entity should I change on collision detection: velocity or position, or both? If the entity escapes the collision, but runs into a new one, should I resolve its new collision, or should I go on to solving the other collisions?