spritecollision by "touch" instd overlap? doku err

Just starting out? Need help? Post your questions and find answers here.
SirCus
User
User
Posts: 12
Joined: Sat May 10, 2003 7:29 pm
Location: Germany
Contact:

spritecollision by "touch" instd overlap? doku err

Post by SirCus »

Hi everyone...

I think there is an error in the doc. ..or I misunderstand something (or I am unable to detect my mistakes...)

In the documentation you can read SpriteCollision() shows a collision of the sprites that OVERLAP.
This seems to be wrong. Just check my little Bomberman "pre"-code.
SpriteCollision() alerts a collision even if the sprites are "in touch", they dont overlap.

my ressource site:
de.geocities.com/mfurt2002
Image

its german, but you see the blue player does not "overlap" the wall. in the left upper corner, anyhow you see a collision alerted by SpriteCollision()

(the current code available for download shows also the x and y coordinates of the Wall in question)

Code: Select all

If KeyboardPushed(#PB_Key_s) ;move player 1 pixel down
    ResetList(Walls()) 
   While NextElement(Walls())      ; check all walls
        If Walls.Object()\Type=0   ;  0 are solid (brown) walls, 1= Grass 
    If SpriteCollision(30,PlayerAx,PlayerAy,Walls.Object()\bitmap, Walls.Object()\ObjectX, Walls.Object()\ObjectY) 
     StartDrawing(ScreenOutput()) 
       DrawText("KollisionDown "+Str(Walls.Object()\ObjectX)+Str(Walls.Object()\ObjectY)) 
       StopDrawing() 
       MoveA=1 
      
     EndIf 
   EndIf 
      
Wend 
    If MoveA=0 
      PlayerAy+1 
      EndIf 
    MoveA=0 
    
   EndIf 
at the moment, I just verify for collision for moving blue player downwards. if so, you cant move down. ..just play around with my code. even if you are between(!) 2 walls, PB tells you you collide with both walls (left and right) and you cant move.
I dont overlap with one of the walls.

Walls and Players size is 50x50 pixels. If one wall is at x0:y50, it ends at the right side at x=49. Players position starts at 50:50... so it should not collide. but for any reason it does.. strange..

can you let me know if the dok or I am/is wrong?
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2139
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

SirCus, I've already discussed this with Fred. SpriteCollision() should at least overlap one pixel. So there is no error in the manual (it must be added a little note about the 1 pixel).

Fred has already your code and will investigate it further, if there is a bug in the command....
Post Reply