isSprTile() and tiles offset
2 weeks 4 days ago #190
by ludojoey
isSprTile() and tiles offset was created by ludojoey
Me again!
I have a question regarding sprites and tile collision detection ( isSprTile() ).
Does the collision detection take the current tile offset into account?
If it does, that would be great.
However, I think it would also be useful (unless there's already another way to achieve this) to be able to explicitly specify the offset that should be used for the collision check.
In my current project, I'm using raster interrupts to implement parallax scrolling by changing the tile offsets on the fly.
When using raster interrupts, different parts of the screen may use different tile offsets.
In that situation, isSprTile() may not reliably determine the visible tile position.
This can lead to collisions being detected when, visually, there isn't one, or conversely, missing collisions that are clearly visible on screen.
Would it be possible to provide a version of the function where the tile offset (or scroll position) is passed explicitly as a parameter?
I hope I'm explaining this clearly. If not, please let me know and I'll try to explain it better.
I have a question regarding sprites and tile collision detection ( isSprTile() ).
Does the collision detection take the current tile offset into account?
If it does, that would be great.
However, I think it would also be useful (unless there's already another way to achieve this) to be able to explicitly specify the offset that should be used for the collision check.
In my current project, I'm using raster interrupts to implement parallax scrolling by changing the tile offsets on the fly.
When using raster interrupts, different parts of the screen may use different tile offsets.
In that situation, isSprTile() may not reliably determine the visible tile position.
This can lead to collisions being detected when, visually, there isn't one, or conversely, missing collisions that are clearly visible on screen.
Would it be possible to provide a version of the function where the tile offset (or scroll position) is passed explicitly as a parameter?
I hope I'm explaining this clearly. If not, please let me know and I'll try to explain it better.
Please Log in or Create an account to join the conversation.
2 weeks 4 days ago - 2 weeks 4 days ago #191
by Franck
Replied by Franck on topic isSprTile() and tiles offset
Yes, currently the scrolling offsets are being taken into account for the test. Which means whenever the test occurs it looks at the scrolling register at that very moment to compute the collision, and as you mention the scrolling registers values can be different at that moment if raster interrupts are modifying them.
Well spotted !
I will see if I can add optionnal parameters as suggested.
Meanwhile you may want to use the isSprBox() or other solutions as a workaround.
Edit:
Looking at the code I realize the sprite collision position is wrong by one lowres pixel in each direction (due to a small hardware revision that was not propagated to the cpu code). Not a big deal, but I will correct for the next release.
Well spotted !
I will see if I can add optionnal parameters as suggested.
Meanwhile you may want to use the isSprBox() or other solutions as a workaround.
Edit:
Looking at the code I realize the sprite collision position is wrong by one lowres pixel in each direction (due to a small hardware revision that was not propagated to the cpu code). Not a big deal, but I will correct for the next release.
Last edit: 2 weeks 4 days ago by Franck.
Please Log in or Create an account to join the conversation.
2 weeks 4 days ago #192
by ludojoey
Replied by ludojoey on topic isSprTile() and tiles offset
Well, I tried, just after the vBlank(), setting the offset register to the "correct" value and just after calling the isSprTile().
Unfortunately, it doesn't seem working, as if the value I just set before calling isSprTile was ignored...
Unfortunately, it doesn't seem working, as if the value I just set before calling isSprTile was ignored...
Please Log in or Create an account to join the conversation.
2 weeks 4 days ago #193
by Franck
Replied by Franck on topic isSprTile() and tiles offset
I will do a small test tomorrow and get back to you.
The following user(s) said Thank You: ludojoey
Please Log in or Create an account to join the conversation.
2 weeks 3 days ago - 2 weeks 3 days ago #194
by Franck
Replied by Franck on topic isSprTile() and tiles offset
Here is a small example that shows sprite vs tile collision. Use cursors to change tile scrolling offsets.
The sprite collision box has been edited with SpritEd.
This at least validates that the underlying collision mecanism correctly takes the offsets into account.
Edit: forgot to tell to move the sprite with the mouse.
The sprite collision box has been edited with SpritEd.
This at least validates that the underlying collision mecanism correctly takes the offsets into account.
This attachment is hidden for guests.
Please log in or register to see it.
Please log in or register to see it.
Edit: forgot to tell to move the sprite with the mouse.
Last edit: 2 weeks 3 days ago by Franck.
The following user(s) said Thank You: ludojoey
Please Log in or Create an account to join the conversation.
2 weeks 3 days ago #196
by ludojoey
Replied by ludojoey on topic isSprTile() and tiles offset
Thank you for the test program.
Yes, it works perfectly !
Well, I will try to find why in my dev, sometimes, collision is detected when, "visually" there is no.
Yes, it works perfectly !
Well, I will try to find why in my dev, sometimes, collision is detected when, "visually" there is no.
The following user(s) said Thank You: Franck
Please Log in or Create an account to join the conversation.
Time to create page: 0.182 seconds