player_img overlaping tile\img - problem

Blitz3D Forums/Blitz3D Programming/player_img overlaping tile\img - problem

AvestheFox(Posted 2009) [#1]
alright, so I'm working on a 2D platformer. I have my tilesets as types:

type tile
field x#,y# ;tile position
field img,frame ;tile image setup
field typ,layer ;tile type and the layer its drawn on
end type

and my player sprite as a single image with four detector images (top,bottom,left,right)

the problem I'm having is telling the program to play the jump or fall animation when the bottom detector image is not overlapting tile\img...

I've tried setting up a flag for when the detector is overlapting the tile (overlaping=true not overlaping=false) but it seems that when using types this flag is flipped repeatedly back and forth at a really rapid pace while the detector is overlaping a tile.

solution?


Warner(Posted 2009) [#2]
This is not caused by using a Type. There could be several reasons actually, depending on your code's logic.
Suppose you have 5 tiles:

0->no overlap->flag=false
1->no overlap->flag=false
2->overlap->flag=true
3->no overlap->flag=false
4->no overlap->flag=false
result: flag=false ->incorrect


Only when tile 2 is being handled, the flag is set to true, after that, tile 3 resets the flag to false again.
In such a case, the solution would be resetting the flag to false before checking the tiles. During the test, the flag can be set to true, but not back to false:

flag=false
0->no overlap
1->no overlap
2->overlap->flag=true
3->no overlap
4->no overlap
result: flag=true ->correct




AvestheFox(Posted 2009) [#3]
thanks. and sorry for the delayed response. I dont have internet back at home so I'm using a library computer :P

I'll play around with your advise though and update on any further problems...

thanks!