collideMap() only in the main loop scope?
- 
					
					
					
					
 I couldn't find the problem, why my collision boxes had no effect. Then I realized, that calling collideMap(sprite)outside of my function, namely in the main loop, make them work. Did you make the same experience? If not I maybe have to change the order of function calls, or dig where the real problem lies in my code.Its a long time ago, I tried something with map collision, and the last time, I postponed the project, so I am a newbie to map collisions and this could be very obvious to you. This pseudo code worked: the collision boxes worked loadMap("level1") // a map with collision boxes I draw in the map editor // sprites[] is a global array of sprites // players is a global int with the number of sprites/players loop updateSprites() drawMap() for i = 0 to players loop collideMap(sprites[i]) repeat drawSprites() repeatThe following code caused the collision borders to be ignored. loadMap("level1") // a map with collision boxes I draw in the map editor // sprites[] is a global array of sprites // players is a global int with the number of sprites/players loop updateSprites() drawMap() for i = 0 to players loop updatePlayers(i) repeat drawSprites() repeat function updatePlayers(player) collideMap(sprites[i]) return void
- 
					
					
					
					
 Gosh! it works now! After putting the function back in. So, sorry. But no clue, yet why. 
 I get some coffee.
- 
					
					
					
					
 Oh, I just found out how to make it fail again. 
 If I do agetSpriteLocation()before thecollideMap()call, the collision box have no effect and the sprite can walk through the boxes.This inhibits the collision boxes: pos = getSpriteLocation(sprite) collideMap(sprite) // do some clamping of the coordinates setSpriteLocation(sprite)This works: collideMap(sprite) pos = getSpriteLocation(sprite) // do some clamping of the coordinates setSpriteLocation(sprite)I think I just have to study these commands a bit more and read more example code. 
- 
					
					
					
					
 @spikey i usually drawmap() then updatesprites() the sprite location i put at the top of the loop so that shouldn't effect the collision not in my experience anyway maybe because the sprites are getting updated before the map 
- 
					
					
					
					
 @waldron i appreciate that guidance. I will do it like this. 
 
			
		