Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMoonkis

Posted 12 April 2013 - 12:52 PM

The way I done my collision in Java was to bound each object that requires collision detection to be bounded by a Rectangle object(which is built into the Java language) and you can use the built in intersects method to see if these rectangles overlapped. This type of bounding box or bounding rectangle collision works well for circle, oval or rectangle shaped objects which would pretty much work with the objects you have in the picture above. Your code looks like OOP C++ so there is probably something similar for that language.

 

I am curious about your code. Why are you testing for the elements in a 2D array to be equal to 1? Is that the code to prevent the character from reaching a certain boundary?

 

Yes, SFML does have a rectangle class, but I'm quite new to collision detection and I didn't quite know what to do with the tiles, seeing as a tile is just a number I can't attach any additional information, such as a bounding box, and really seeing as the map is 1000x1000 I think maybe that many bounding-boxes would be a bit to much?

I'm testing against 1 seeing as that is the walkable tile.


#1Moonkis

Posted 12 April 2013 - 12:52 PM

The way I done my collision in Java was to bound each object that requires collision detection to be bounded by a Rectangle object(which is built into the Java language) and you can use the built in intersects method to see if these rectangles overlapped. This type of bounding box or bounding rectangle collision works well for circle, oval or rectangle shaped objects which would pretty much work with the objects you have in the picture above. Your code looks like OOP C++ so there is probably something similar for that language.

 

I am curious about your code. Why are you testing for the elements in a 2D array to be equal to 1? Is that the code to prevent the character from reaching a certain boundary?

 

Yes, SFML does have a rectangle class, but I'm quite new to collision detection and I didn't quite know what to do with the tiles, seeing as a tile is just a number I can't attach any additional information, such as a bounding box, and really seeing as the map is 1000x1000 I think maybe that many bounding-boxes would be a bit to much?


PARTNERS