Collisions with rotated sprites
Collisions with rotated sprites
Is it possible to use SpriteCollision or SpritePixelCollision with a rotated sprite?
Thanks,
KeithTX
Thanks,
KeithTX
Re: Collisions with rotated sprites
Okay, I'll assume that's a no then.
-Keith
-Keith
-
- User
- Posts: 62
- Joined: Tue Mar 18, 2014 4:25 pm
- Location: Bogotá, Colombia
Re: Collisions with rotated sprites
Instead of assuming, why dont you try it yourself?.
It isnt that difficult to load an sprite, rotate it and check for a collision with some other sprite.
Havent tried it myself but I am guessing that it works fine
It isnt that difficult to load an sprite, rotate it and check for a collision with some other sprite.
Havent tried it myself but I am guessing that it works fine
-
- Enthusiast
- Posts: 334
- Joined: Mon Feb 04, 2013 5:28 pm
Re: Collisions with rotated sprites
I agree but it should be specified in the docs, else you have to assume or try.juankprada wrote:Instead of assuming, why dont you try it yourself?.
Neither did I but based on an extrapolating hunch I would bet it doesn't work.juankprada wrote: Havent tried it myself but I am guessing that it works fine
The OP will let us know for sure.
Re: Collisions with rotated sprites
I have not tried myself also, but here my two cents on the subject.
SpriteCollision compares the rectangular areas around the sprites and would not rotate with the sprite. If the sprite is box shape, rotating may not make much a different.
SpritePixelCollision compares the pixels, so it should work even with a rotate sprite.
SpriteCollision compares the rectangular areas around the sprites and would not rotate with the sprite. If the sprite is box shape, rotating may not make much a different.
SpritePixelCollision compares the pixels, so it should work even with a rotate sprite.
Re: Collisions with rotated sprites
juankprada: Instead of assuming I didn't try, try asking if I tried.
I did try, and no it doesn't work. Perhaps I should have asked "Is there a way to use SpriteCollision or SpritePixelCollision with a rotated sprite", I take the blame for that.
PureBasic creates the mask (be it rectangle or pixel based) when a sprite is loaded, and doesn't seem to update it if the sprite is rotated. I would venture to guess the same is true if a sprite is transformed, though I didn't try that.
-Keith
I did try, and no it doesn't work. Perhaps I should have asked "Is there a way to use SpriteCollision or SpritePixelCollision with a rotated sprite", I take the blame for that.
PureBasic creates the mask (be it rectangle or pixel based) when a sprite is loaded, and doesn't seem to update it if the sprite is rotated. I would venture to guess the same is true if a sprite is transformed, though I didn't try that.
-Keith
-
- Enthusiast
- Posts: 334
- Joined: Mon Feb 04, 2013 5:28 pm
Re: Collisions with rotated sprites
Yes, you should have said that.KeithTX wrote: PureBasic creates the mask (be it rectangle or pixel based) when a sprite is loaded, and doesn't seem to update it if the sprite is rotated. I would venture to guess the same is true if a sprite is transformed, though I didn't try that.
But thank you for reporting back the result of your test.
I just knew it, yeeeeeeeeeeeeah, and without trying ! The power of the extrapolating hunch !
My sprite library does it *giggle*
Maybe you can ask for it in the requests forum
Re: Collisions with rotated sprites
I applaud your extrapolating hunch.DontTalkToMe wrote:KeithTX wrote: I just knew it, yeeeeeeeeeeeeah, and without trying ! The power of the extrapolating hunch !
I thought about extending my pb sprite animation code to handle collisions, but I think I'll just go back to C and the AGK2 lib for now.
Keith
-
- User
- Posts: 62
- Joined: Tue Mar 18, 2014 4:25 pm
- Location: Bogotá, Colombia
Re: Collisions with rotated sprites
Is your sprite library available somewhere?DontTalkToMe wrote: My sprite library does it *giggle*
-
- Enthusiast
- Posts: 494
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: Collisions with rotated sprites
Hi KeithTX,
I have mad a little PB test code and it looks like that sprite collison is not working with rotated sprite. It is not easy to programming a (Pixel-) Sprite collision of rotated sprite. Why i know that? Because my mp3d engine has a self made sprite engine with rotate sprites (and parent kid funktion) collision check.
P.S. If you have a good rotate sprite collison check i will have a look on it. I am searching for good codes to integrated them in mp3d..
Greetings Michael
PB testcode for rotate sprites collision check
Example of mp3d
I have mad a little PB test code and it looks like that sprite collison is not working with rotated sprite. It is not easy to programming a (Pixel-) Sprite collision of rotated sprite. Why i know that? Because my mp3d engine has a self made sprite engine with rotate sprites (and parent kid funktion) collision check.
P.S. If you have a good rotate sprite collison check i will have a look on it. I am searching for good codes to integrated them in mp3d..
Greetings Michael
PB testcode for rotate sprites collision check
Code: Select all
If InitMouse() =0 Or InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Sprite system can't be initialized", 0)
End
EndIf
#Window = 0
If OpenWindow(#Window, 50, 200, 800, 600,"Sprite test",#PB_Window_SystemMenu | #PB_Window_SizeGadget)
If OpenWindowedScreen(WindowID(#Window), 0, 0, WindowWidth(#Window), WindowHeight(#Window))
LoadSprite(0, "Data/PureBasic.bmp", #PB_Sprite_PixelCollision)
CopySprite(0,1,#PB_Sprite_PixelCollision)
Repeat
Event = WindowEvent()
ExamineMouse()
x = MouseX() ; Returns actual x pos of our mouse
y = MouseY()
; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
FlipBuffers()
ClearScreen(RGB(0,0,0))
winkel.f + 1
DisplaySprite(0, x,y)
DisplaySprite(1, 200, 300)
RotateSprite(1, winkel.f,#PB_Absolute)
Debug SpritePixelCollision(0, x, y, 1, 200, 300)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Else
MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0)
EndIf
EndIf
End
Example of mp3d
Working on - MP3D Library - PB 5.73 version ready for download