SFML community forums

Help => General => Topic started by: MarbleXeno on July 24, 2020, 02:18:06 pm

Title: Idea for Collision
Post by: MarbleXeno on July 24, 2020, 02:18:06 pm
Hello awesome people of the Internet, I'm learning C++ and SFML, and now I have a problem. I've created collision detection script which return bool if colliding, now I wan't to make my player stop, when colliding, i've created PlayerCollision script, and i don't know how to make my player stop when colliding with primitive shape, i can't find good tutorial, could someone help me?
Title: Re: Idea for Collision
Post by: Stauricus on July 24, 2020, 03:04:34 pm
well... the logic is simple:...
BEFORE the player move, test if he is going to collide with something. if true, the player don't move. if false, he moves.

so you don't move the player right from the start. you first test for collisions.
Title: Re: Idea for Collision
Post by: MarbleXeno on July 24, 2020, 03:33:35 pm
Okay, but how i can later implement a gravity to that, you know, player needs to move when standing on the platform. Maybe something with a velocity?
Title: Re: Idea for Collision
Post by: Stauricus on July 24, 2020, 03:55:16 pm
this covers everything you want, i guess:
https://gamedevelopment.tutsplus.com/series/basic-2d-platformer-physics--cms-998
Title: Re: Idea for Collision
Post by: MarbleXeno on July 24, 2020, 07:18:11 pm
okay thanks, i'll look at this.