Spritepixelcollision with rotatesprite()

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
raka
Posts: 4
Joined: Fri Sep 13, 2019 7:14 am

Spritepixelcollision with rotatesprite()

Post 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
Last edited by raka on Sun Sep 15, 2019 3:27 pm, edited 1 time in total.
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Post 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.
raka
Posts: 4
Joined: Fri Sep 13, 2019 7:14 am

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Post 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 ...
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Post by Fred »

It makes sense, I will try to add an option to have a 'pre-rotated' sprite mask for pixel perfect collision
raka
Posts: 4
Joined: Fri Sep 13, 2019 7:14 am

Re: 2.21(free): spritepixelcollision with rotatesprite probl

Post 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 :)
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: Spritepixelcollision with rotatesprite()

Post by Fred »

Doc updated
raka
Posts: 4
Joined: Fri Sep 13, 2019 7:14 am

Re: Spritepixelcollision with rotatesprite()

Post 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
Post Reply