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

Author Topic: How To Do Collisions In SFML  (Read 7443 times)

0 Members and 1 Guest are viewing this topic.

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
How To Do Collisions In SFML
« on: January 09, 2011, 02:44:07 pm »
Hello everyone, i been looking for a tutorial on collisions in sfml as i need it to help with my first game but i can not find any can anything that helps. can anyone help me do some collisions, basically i want it if i hit a object then score changes.

Question one:Anyone Know of a good sfml 'video' tutorial site
Question two:Can anyone help me with my Collisions.


Thanks in Advanced :D

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
How To Do Collisions In SFML
« Reply #1 on: January 09, 2011, 03:27:07 pm »
I'm sure the wiki can help you.

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
How To Do Collisions In SFML
« Reply #2 on: January 09, 2011, 03:48:02 pm »
Yeah i saw that collision thing in there but i didn't really understand it too well

I'm trying to make a basic game where u need to run away from a shape(u have reversed controls eg.w make u go down) and u sue w a s d and another person uses up down left right keys, and once they touch u then u have normal controls and they have reversed control and u need to get them

i would have a Boolean and if it was true i have normal control and other person has reversed and vice versa



lame i know, buy hey, its a start



and i wanna know if there is a simple collision code to do this easily


I'm kinda n00b at SFML i started it yesterday, ha ha


but i had a good knowledge of Visual basic and it seems that things work the same just with different code

does anyone know like a simple line of code the with make a collision?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
How To Do Collisions In SFML
« Reply #3 on: January 10, 2011, 02:15:23 pm »
Quote from: "nevets_19"
but i had a good knowledge of Visual basic and it seems that things work the same just with different code
That's a huge misbelief. C++ is definitely quite different, you should learn it from beginning. Even if some concepts look similar, you shouldn't underestimate the differences. And a library like SFML requires basic knowledge in C++.

For your collision, you might use a simple rectangular or circular collision detection. Just model the shapes as rects/circles and check whether they collide.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
How To Do Collisions In SFML
« Reply #4 on: January 11, 2011, 05:48:20 am »
hmm, i did start by using c++ just a simple console thing with cout and stuff, i knew how to display messages, make integers, do if statements and randomize but thats about it, then i went to GLUT but that seemed weird cause it was annoying just to make and a shape and get it to move, however i did understand how to make a shape in that, then i read the u shouldn't use glut for making game u should use allegro, SFML, or SDL so i looked into SFML and here i am



P.S i did visual basic before any of this, and i tryed to make a top down game in it, fail, its just not meant for making games.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
How To Do Collisions In SFML
« Reply #5 on: January 11, 2011, 01:05:59 pm »
I think SFML is a good way to start game programming. It offers a huge spectrum of functionality and is really easy to use (much easier than SDL, in my opinion – already because it's C++ and not C). It also abstracts OpenGL where you have to write more code to achieve the same thing (but of course you are more flexible).

However, in spite of its simplicity, SFML does still require some knowledge in C++. At least all the procedural things (if, loops, functions) and the basics of classes should be known well. Otherwise, you have to lookup language features all the time. And of course, the more you know about C++, the better. Concepts like RAII are extremely useful, for example.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
How To Do Collisions In SFML
« Reply #6 on: January 11, 2011, 05:50:51 pm »
hmm, yeah i didn't really bother learning C++ too much because i didn't feel like i wasn't achieving anything so i looked into glut which lead me to sfml and this seems to be a simple way to begin game making, as i wanna be a game maker in the future

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
How To Do Collisions In SFML
« Reply #7 on: January 11, 2011, 10:23:15 pm »
Just make sure you have a good C++ book (like the primer) in which you read from time to time, apart from only using SFML. ;)

As a game programmer, you must have solid knowledge about the language you work with. At least if you don't plan to make your life unnecessarily hard.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
How To Do Collisions In SFML
« Reply #8 on: January 12, 2011, 04:18:39 pm »
hmmm, i'll looks for some tutorials then

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
How To Do Collisions In SFML
« Reply #9 on: January 12, 2011, 05:43:11 pm »
If you have the possibility to get a book (e.g. from a library, when you don't want to buy it), you should prefer it over tutorials. Most of the tutorials cover only the surface of the language, leaving severe knowledge gaps. But even at books you have to be careful, a lot of them aren't too good either ;)

The C++ primer is a good choice, or Thinking in C++, which is also available as e-book for free. So this seems to be ideal for you :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
How To Do Collisions In SFML
« Reply #10 on: January 13, 2011, 07:41:18 am »
got them, gonna take a look thanks for recommending them to me

 

anything