GLBasic forum

Main forum => GLBasic - en => Topic started by: MrPlow on 2014-Jul-15

Title: Some phones and collision detection
Post by: MrPlow on 2014-Jul-15
Hi

I had a user contact about their phone wont allow for collision detection - has this happened on other phones too.
Is there a fix for it? I think both use Sprcoll.

The Phone in question is a Samsung Galaxy Express Go Phone.

I got them to try my other games and its the same...so it must be problem with those samsungs?

Title: Re: Some phones and collision detection
Post by: spacefractal on 2014-Jul-15
Im did heard about the same for few years ago, im do uses ANIMCOLL for karmamiwa as well. Howover im do uses a special collision map using two colors (using a color and a transparency), not doing that on the normal image. You could try do the same which such of a map:
http://www.dropbox.com/s/utskqxpc2t78hg5/tilesset_2.png

the image its touch with is just a 1x1 "mouse col" image (which is how im could mirror and flipping the tiles. Im just calculate the mouse col pos before checking).

This is what im did when im using landscape collision in Karma Miwa. All enimies collision with the bird is just using a BOX collision.

im have a Samsung tab2 and seen the game on a Samsung s4 to, which im have not see the ANIMCOLL issue in Karma Miwa (using the above image). Howover you can not cover all Androids phones if they have a bad opengl implentation.

Title: Re: Some phones and collision detection
Post by: MrPlow on 2014-Jul-15
Thanks SF,

If the issue is not a boxcoll problem I could do a smaller boxcoll (within sprite bounds) to fix the sprcoll issue.
That way sprcoll will work for majority and other problem phones will have slightly less accurate hitboxes.

If boxcoll is also the problem, I will prob have to use the x,y,w,h of the items and do a manual if x>xx and x<xx to replicate the boxcoll. Maybe within a function?

Title: Re: Some phones and collision detection
Post by: erico on 2014-Jul-15
That replicant (tyrel corp?) of box coll is what I´m using in my game from the very start, since the collisions needed are quite simple.
I think I also tested the game on that phone without trouble IIRC.
Title: Re: Some phones and collision detection
Post by: spacefractal on 2014-Jul-15
Boxcol is just a simple if math, nothing checking on the images it's self.

Some devices might been fuzzy, but have not seen that in my game. In my case I'm just used a 1x1 pixel check against a special sprite coll sheet when I'm do pixel check on the game landscape.
Title: Re: Some phones and collision detection
Post by: spacefractal on 2014-Jul-16
Also alternative, you could do command test rutine with sprite col for checking it's works correctly or not. If its not, you could revert to a lesser precision boxcol or warn the user.
Title: Re: Some phones and collision detection
Post by: MrPlow on 2014-Jul-16
Hmmm, thats good idea - I could flag at the start if sprcoll is working or not?

Draw 2 sprites that overlap then run

sprcoll = true then usesprcoll = true
else
use sprcoll = false

Then use usesprcoll in collision code.
if usesprcoll = true
sprcoll stuff
else
boxcoll stuff
endif

Something like that...
Title: Re: Some phones and collision detection
Post by: spacefractal on 2014-Jul-16
you could impose a function to handle that. So its automatic revert to boxcol in that functions. This is why im uses functions so much as im do.

Also you could also change the col image used to something like that one im did, using 2 colors (one purple, the other transparency, and this was used against a 1x1px source image).

You also dont need to draw the graphics first directly for collision checking. You just need to make sure they are loaded first.
Title: Re: Some phones and collision detection
Post by: MrPlow on 2014-Jul-17
Thanks SF,

Another good idea - I will do that custom function for reverting to boxcoll - sounds good!

I am not sure of the benefits for the 2 colour thing and the 1x1 image? is that for pixel perfect sprite collisions?
Or just your way of testing sprcoll is working for the device? 

my collision function:
Code (glbasic) Select
FUNCTION newcoll:id1%,x1%,y1%,w1%,h1%,id2%,x2%,y2%,w2%,h2%
IF usesprcoll=TRUE //set on startup test for sprcoll
IF BOXCOLL(x1,y1,w1,h1,x2,y2,w2,h2) //reduce number of sprcoll checks
IF SPRCOLL(id1,x1,y1,id2,x2,y2) THEN RETURN TRUE
ENDIF
ELSE
IF BOXCOLL(x1,y1,w1,h1,x2,y2,w2,h2) THEN RETURN TRUE
ENDIF
RETURN FALSE
ENDFUNCTION
Title: Re: Some phones and collision detection
Post by: spacefractal on 2014-Jul-17
Yes. Howover im did used ANIMCOLL (if that does some different).

For my case im used used a 1x1 pixel check against the purple image tileset for collisions. Im not sure its works on all devices, but did on those tested. Im did that because im diddent trust the command on the colorful images.
Title: Re: Some phones and collision detection
Post by: Kitty Hello on 2014-Aug-29
SPRCOLL does the BOXCOLL internally.
Title: Re: Some phones and collision detection
Post by: spacefractal on 2014-Aug-29
its just been more controlable when the game could checks if its possible to do a pixel check or not. Hence this was a idea for checking. This is something you cannot fix and can been limits on some phones.