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

Author Topic: [Solved]Collision between char array and sprite?  (Read 1395 times)

0 Members and 1 Guest are viewing this topic.

Chili

  • Guest
[Solved]Collision between char array and sprite?
« on: October 27, 2013, 06:59:50 pm »
So far I've been using the bounding rectangle of the sprites to check against my char array which looks good enough since most of the sprites are quite rectangular, this of courses causes a problem when trying to do collision between more oblong sprites. Is there a somewhat easy way to fix this or would I have to set up an char array for each sprite and use it in combination with transformPoint(x,y) to check if it's a valid pixel or not?
« Last Edit: October 28, 2013, 07:13:00 am by Chili »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Collision between char array and sprite?
« Reply #1 on: October 27, 2013, 10:02:03 pm »
I'm honestly not sure what this char array is and what it means to collide with it, but try looking at the code here: https://github.com/SFML/SFML/wiki/Source:-Simple-Collision-Detection-for-SFML-2 You should be able to figure out how to implement whatever level of collision you feel you need from that.

Chili

  • Guest
Re: Collision between char array and sprite?
« Reply #2 on: October 28, 2013, 07:12:38 am »
I'm honestly not sure what this char array is and what it means to collide with it, but try looking at the code here: https://github.com/SFML/SFML/wiki/Source:-Simple-Collision-Detection-for-SFML-2 You should be able to figure out how to implement whatever level of collision you feel you need from that.
The char array consist of 0's(if empty pixel) and 1's(if alpha > 0) and it represent a destructible image. Thanks for the link, discarded the idea of doing sprite intersection since I didn't see any way to retrieve the specific cord that caused the collision.