RPG GAME - Movement not working as expected.

BlitzPlus Forums/BlitzPlus Programming/RPG GAME - Movement not working as expected.

Imperium(Posted 2013) [#1]
This code works but not as expected. You can move around until you reach the end of the map, however the camera only tracks the player you're moving right or down. It won't trigger unless you move all the way to the left when the program starts. There is no actual camera the function Fmovemap() handles this. I'm not sure why it is bugged either my logic is wrong or I have a X,Y,+, or - in the wrong place?







UUICEO(Posted 2013) [#2]
It's been a while since this was posted so not sure if you ever fixed your problem but I think I found your problem if you didn't. Here is the corrected function that was causing your problem:

Function Fmovemap()
	
	If KeyDown(200) And chard <> 1 Then

		If yoffset > tilel Then 
			yoffset = yoffset - 1
		Else
			charu = 1
		End If
	
	Else If KeyDown(208) And charu <> 1 Then

		If yoffset < ((tilel*mapsizeY)-screeny+tilel) Then 
			yoffset = yoffset + 1
		Else
			chard = 1
		End If
		
	Else If KeyDown(203) And charr <> 1 Then

		If xoffset > tilew Then 
			xoffset = xoffset - 1
		Else
			charl = 1
		End If
	
		
	Else If KeyDown(205) And charl <> 1 Then

		If xoffset < ((tilew*mapsizeX)-screenx+tilew) Then 
			xoffset = xoffset + 1
		Else
			charr = 1
		End If
	End If
	

	
End Function



Imperium(Posted 2014) [#3]
Oh wow thanks. I was following a tutorial that the author admitted had errors but didn't mention where. I changed some of it and then hit this snag. I will try this out and again many thanks!