Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML create a collision  (Read 1301 times)

0 Members and 1 Guest are viewing this topic.

Kneggi

  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML create a collision
« on: October 12, 2015, 01:49:55 pm »
Hello there,

I feel really noobish right now. First of all I began with SFML + C# (Visual Studio) arround 1 1/2 month ago. I couldn´t find any thread about this and that´s becouse I need your help.

I am trying to create a Collision between two rectangle shapes. But i have no clue how to and thats becouse ill opened this thread.

I have built a "Pong" game. Now i want to built a collision between the window and the mooving rectangles.

Really could Need your help.



eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML create a collision
« Reply #1 on: October 12, 2015, 02:38:40 pm »
Collision detection and reaction are not something bound to SFML or a programming language. If you just enter "collision detection" into Google or the forum search you'll get tons of results.
That way you can learn how it works and what is needed to implement it.

If you have a specific question as away.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Satus

  • Guest
Re: SFML create a collision
« Reply #2 on: October 12, 2015, 04:31:14 pm »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML create a collision
« Reply #3 on: October 12, 2015, 05:08:06 pm »
Hello there,
Hi.

I have built a "Pong" game. Now i want to built a collision between the window and the mooving rectangles.
If this is the paddle, just clamp the position so that if it's past the position it should be, change it to the position it should be (e.g. if it's too high, place it so that it's as high as it can be without leaving the window).
If it's the ball, same thing except you'll also need to change the direction of the ball.

As for collision between a paddle and a ball, you should be able to find it using Google (AABB collision).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything