Collisions In Functions

Blitz3D Forums/Blitz3D Programming/Collisions In Functions

Uh-hum!, you see, you checked for collisions before your loop even began. The correct method is to check for collisions each loop. Soooo...

Change this:

;---------- 
;Collisions 
;---------- 
Collisions pl,ro,2,3 
;---- 
;Loop 
;---- 
While exists=1 

PointEntity cam,player 
player_control() 
If KeyDown(1) Then exists=0 
RenderWorld 

Flip 

Wend 

FreeImage load_screen 
FreeEntity blue_room 
End 


to something along this line:

;---- 
;Loop 
;---- 
While exists=1 

PointEntity cam,player 
player_control() 
If KeyDown(1) Then exists=0 
;---------- 
;Collisions 
;---------- 
Collisions pl,ro,2,3 

UpdateWorld
RenderWorld
Flip 

;CountCollisions
;ClearCollisions

Wend 

FreeImage load_screen 
FreeEntity blue_room 
End 



(I believe you have to call collisions before updateworld (I'm at work right now and my memory stinks) and then countcollisions or clearcollisions if necessary)