Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualwarnexus

Posted 12 April 2013 - 12:44 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?


#3warnexus

Posted 12 April 2013 - 12:43 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?


#2warnexus

Posted 12 April 2013 - 12:41 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.


#1warnexus

Posted 12 April 2013 - 12:39 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.


PARTNERS