Page 1 of 1

Spritepixelcollision with rotatesprite()

Posted: Fri Sep 13, 2019 7:40 am
by raka
Hy Spiderbasicteam,
very nice work you done. We are still testing Spiderbasic for a little speedwaygame. (http://www.sqlmanagement.de/bs/bs.html, just a little test for car moving)

But, we found the following bug:

If you rotate a sprite, then SpritePixelCollision will not work properly after that. It seems that the mask for the test is not rotated with the sprite.

You can test it with the screen.sb Example with the Spider. If you rotate the sprite the collision is detected wrong.

We need the game for a trade fair appearance for one customer in the next month. Not buyed spiderbasic yet, but very interested.

Greetings

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Posted: Fri Sep 13, 2019 8:29 am
by Fred
Hello, you are right, the pixelcollision doesn't take rotation in account. I will update the doc to reflect this, as rotating the whole mask before doing the test will unfortunately kill the perf.

A way to solve this for you is to create 32 sprites (each with its own rotation) and use the right one. Each will have its own mask, so it should work.

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Posted: Fri Sep 13, 2019 6:29 pm
by raka
Thank you for the reply.

I do not know exactly what your implementation of the pixelcollision is, but if you are working with collision masks, an optional rotation of the collision maske would be a sufficient solution for sufficient performance in many cases.

Especially since it is actually just the rotation of ONE other sprite. This would have to be switchable via a parameter. The rotation does not have to be done every collision check, but during the rotation of the sprite. This can be performant enough depending on the application.

As I said, I do not know your implementation of the pixel collision exactly.

The solution you talk about is known, but is only of limited interest. In this case, one would have to vreate for each Sprite 36 images. If the performance is necessary a common practice, but in some cases too much effort. I think it would be more interesting for the developer to make the choice.

In addition, this excludes certain possibilities. Example:

A sprite with a tank. The user gets the possibility to create his own texture. In the solution you proposed a rather high effort, since the own texture must be placed on all 36 images, maybe automatically.

Another example:
The tank receives a texture change in the game when hit on the left side. In your suggestion, this change would have to be placed in the game (on the fly) on 36 images or (on the fly) a sprite to the right place will be superimposed.

In both examples, a rotation with collision mask might be more interesting ...

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Posted: Mon Sep 16, 2019 2:57 pm
by Fred
It makes sense, I will try to add an option to have a 'pre-rotated' sprite mask for pixel perfect collision

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Posted: Mon Sep 16, 2019 5:12 pm
by raka
Hello Fred,

Good news, very nice :-)

That's why I looked at Spiderbasic for our project. I know your very good work from Purebasic and the reliability with which you serve the community and with Spiderbasic you can rock the WWW.

In the meantime I will order a single user license.

Thanks :)

Re: Spritepixelcollision with rotatesprite()

Posted: Mon Apr 20, 2020 7:47 am
by Fred
Doc updated

Re: Spritepixelcollision with rotatesprite()

Posted: Mon Apr 20, 2020 7:55 am
by raka
Hello Fred,

can you give me a sign, where I can find it. Looking at Online Doc, but can't find it...

Greetings
Ralf