It is currently Sat Jul 11, 2020 7:14 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Collisions with rotated sprites
PostPosted: Mon Sep 14, 2015 1:38 am 
Offline
New User
New User

Joined: Mon Sep 14, 2015 1:35 am
Posts: 4
Is it possible to use SpriteCollision or SpritePixelCollision with a rotated sprite?

Thanks,
KeithTX


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Wed Sep 16, 2015 9:00 pm 
Offline
New User
New User

Joined: Mon Sep 14, 2015 1:35 am
Posts: 4
Okay, I'll assume that's a no then.

-Keith


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Wed Sep 16, 2015 10:38 pm 
Offline
User
User

Joined: Tue Mar 18, 2014 4:25 pm
Posts: 62
Location: Bogotá, Colombia
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Wed Sep 16, 2015 11:48 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 04, 2013 5:28 pm
Posts: 333
juankprada wrote:
Instead of assuming, why dont you try it yourself?.


I agree but it should be specified in the docs, else you have to assume or try.

juankprada wrote:
Havent tried it myself but I am guessing that it works fine


Neither did I but based on an extrapolating hunch I would bet it doesn't work.

The OP will let us know for sure. :D


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Thu Sep 17, 2015 12:07 am 
Offline
User
User

Joined: Mon Sep 03, 2012 8:52 pm
Posts: 82
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Fri Sep 18, 2015 9:00 pm 
Offline
New User
New User

Joined: Mon Sep 14, 2015 1:35 am
Posts: 4
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Fri Sep 18, 2015 10:38 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 04, 2013 5:28 pm
Posts: 333
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.


Yes, you should have said that. :wink:

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 ! :wink:

My sprite library does it *giggle* :mrgreen:

Maybe you can ask for it in the requests forum


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Sat Sep 19, 2015 12:52 am 
Offline
New User
New User

Joined: Mon Sep 14, 2015 1:35 am
Posts: 4
DontTalkToMe wrote:
KeithTX wrote:
I just knew it, yeeeeeeeeeeeeah, and without trying ! The power of the extrapolating hunch ! :wink:


I applaud your 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


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Thu Sep 24, 2015 1:43 am 
Offline
User
User

Joined: Tue Mar 18, 2014 4:25 pm
Posts: 62
Location: Bogotá, Colombia
DontTalkToMe wrote:
My sprite library does it *giggle* :mrgreen:


Is your sprite library available somewhere?


Top
 Profile  
Reply with quote  
 Post subject: Re: Collisions with rotated sprites
PostPosted: Fri Oct 16, 2015 9:02 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Oct 11, 2008 9:07 pm
Posts: 416
Location: Germany, Berlin > member German forum
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
Code:
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
Image

_________________
Working on - MP3D Library -


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye