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

Author Topic: Use image.getPixelsPtr for collision detection for slopes/stairs  (Read 2581 times)

0 Members and 1 Guest are viewing this topic.

Qluxzz

  • Guest
I have used this method only to experiment. I use this to check if the pixel the character is on is transparent or not. I know I can make collision detection easier but this method works great for stairs or slopes.

Is it a good idea to use this method?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10997
    • View Profile
    • development blog
    • Email
Re: Use image.getPixelsPtr for collision detection for slopes/stairs
« Reply #1 on: July 10, 2013, 01:16:07 am »
It really depends on what and how you do things exactly. Working directly with pixel data can be a bit slow and if you have to upload the data often to the GPU, you'll most definitely run into a bottleneck. ;)

So how are you doing things and what are you doing exactly?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

fallahn

  • Hero Member
  • *****
  • Posts: 504
  • Buns.
    • View Profile
    • Trederia
Re: Use image.getPixelsPtr for collision detection for slopes/stairs
« Reply #2 on: July 10, 2013, 09:29:24 am »
I've found that this is a good reference for platform physics in general http://info.sonicretro.org/Sonic_Physics_Guide and a good starting point for setting up collision detection. By its nature we also know the technique works well on low end hardware :-)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10997
    • View Profile
    • development blog
    • Email
AW: Re: Use image.getPixelsPtr for collision detection for slopes/stairs
« Reply #3 on: July 10, 2013, 12:50:13 pm »
I've found that this is a good reference for platform physics in general http://info.sonicretro.org/Sonic_Physics_Guide and a good starting point for setting up collision detection. By its nature we also know the technique works well on low end hardware :-)
Yes and no.
In the days of Sonic the code interfaces between video memory and code where quite different and next to that one was dealing with different resolutions (VGA vs 1080p).
Some parts might still be informative and useful, I'd tale everything with a grain of salt. In the articles a lot of stuff evolves around pixels, which made a lot of sense when you could count them on the screen. Now you might want to introduce a separation of visual data and logic data, thus abstracting the pure pixels away from the collision detection.

There are many techniques for collision checks and I don't feel like explaining them in detail. You could look at features that Box2D provide, since it haa many variations implemented.

On the other side you could potentially simply 'scale' everything. So you'd still be able to use 'scaled pixels' and you'd keep the pixelated effect. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/