Move to 330,316, at that point the upperleft corner of the screen is arround 0,0. What happens is that you can move 64px arround the 0,0 instead of 32. Just keep an eye on the red X Y counters, and move up from 330,316. You will see it allows you to move 64px without moving the grid!!. it should have moved!! It has todo with some math in the RENDER LAYER function and a division by 0 so i guess, i have no clue really and totaly lost it after a long day of debugging... its driving me crazy by now. Everything else works so dont bother checking other functions.
SuperStrict Graphics 800, 600 Global SyncWait:Int = True Global DEBUG:Int = False Global UPDATE_FREQUENCY:Int = 50 Global update_time:Float = 1000 / UPDATE_FREQUENCY Global UPS:TTicker = New TTicker Global FPS:TTicker = New TTicker Global MapW:Int = 19, MapH:Int = 18, MapL:Int = 9 'create player Global player:TPlayer = New TPlayer player.x = 0 player.y = 0 player.z = 1 player.maxspeed = 5 Local execution_time:Float = 0 Local t:Int = MilliSecs() While Not KeyHit(KEY_ESCAPE) execution_time:+(MilliSecs() - t) t = MilliSecs() While execution_time >= update_time UPS.Update() Update() execution_time:- update_time Wend FPS.Update() Render(execution_time / update_time) Wend End Function Update() 'debug tools If KeyHit(KEY_MINUS) And KeyDown(KEY_LSHIFT) And KeyDown(KEY_LCONTROL) player.maxspeed:-0.5 End If If KeyHit(KEY_EQUALS) And KeyDown(KEY_LSHIFT) And KeyDown(KEY_LCONTROL) player.maxspeed:+0.5 End If 'angle If KeyDown(KEY_UP) And KeyDown(KEY_LEFT) player.angle = 135 Else If KeyDown(KEY_UP) And KeyDown(KEY_RIGHT) player.angle = 45 Else If KeyDown(KEY_DOWN) And KeyDown(KEY_LEFT) player.angle = 225 Else If KeyDown(KEY_DOWN) And KeyDown(KEY_RIGHT) player.angle = 315 Else If KeyDown(KEY_UP) player.angle = 90 Else If KeyDown(KEY_DOWN) player.angle = 270 Else If KeyDown(KEY_LEFT) player.angle = 180 Else If KeyDown(KEY_RIGHT) player.angle = 0 End If 'speed If KeyDown(KEY_UP) And KeyDown(KEY_LEFT) player.speed = player.speed + 0.5 Else If KeyDown(KEY_UP) And KeyDown(KEY_RIGHT) player.speed = player.speed + 0.5 Else If KeyDown(KEY_DOWN) And KeyDown(KEY_LEFT) player.speed = player.speed + 0.5 Else If KeyDown(KEY_DOWN) And KeyDown(KEY_RIGHT) player.speed = player.speed + 0.5 Else If KeyDown(KEY_UP) player.speed = player.speed + 0.5 Else If KeyDown(KEY_DOWN) player.speed = player.speed + 0.5 Else If KeyDown(KEY_LEFT) player.speed = player.speed + 0.5 Else If KeyDown(KEY_RIGHT) player.speed = player.speed + 0.5 Else player.speed = player.speed / 3 End If 'limit speed If player.speed < 0.5 player.speed = 0 If player.speed > player.maxspeed player.speed = player.maxspeed player.oldx = player.x player.oldy = player.y player.x = player.x + Cos(player.angle) * (player.speed * 32) / (1000.0 / Float(update_time)) player.y = player.y - Sin(player.angle) * (player.speed * 32) / (1000.0 / Float(update_time)) End Function Function Render(tween:Float) 'Local tX:Int = Int(player.x * tween + player.oldx * (1.0 - tween)) 'Local tY:Int = Int(player.y * tween + player.oldy * (1.0 - tween)) Cls() SetOrigin(0 - player.x + ((MapW * 32) / 2), 0 - player.y + ((MapH * 32) / 2)) 'Draw zone For Local layer:Int = 1 To 9 RenderLayer(player.x, player.y, player.z, layer) Next SetOrigin(0,0) DrawGrid() SetColor 255,0,0 'FPS DrawText "DEBUG MODE", 10, 10 DrawText "UPS: " + UPS.count, 10, 25 DrawText "FPS: " + FPS.count, 10, 40 DrawText "Speed: " + player.speed + " of " + player.maxspeed, 10, 60 DrawText "x: " + player.x, 10, 75 DrawText "y: " + player.y, 10, 90 SetColor 255,255,255 'Delay(10) Flip SyncWait End Function '============================================================================================ 'RenderLayer Function RenderLayer(x:Int, y:Int, mZ:Int, layer:Int, modes:Int = 0) Local vY:Int Local vX:Int Local tile:Int 'calculate relative top/left edge Local oX:Int = x - ((MapW * 32) / 2) Local oY:Int = y - ((MapH * 32) / 2) DrawRect(0, 0, 32, 32) For vY = 0 To MapH - 1 For vX = 0 To MapW - 1 Local tX:Int = vX + (oX / 32) Local tY:Int = vY + (oY / 32) Local mX:Int = 0 Local mY:Int = 0 'translate position to world zone While tX < 0 tX:+MapW mX:-1 Wend While tY < 0 tY:+MapH mY:-1 Wend While tX > MapW - 1 tX:-MapW mX:+1 Wend While tY > MapH - 1 tY:-MapH mY:+1 Wend 'Set zone Local zone:String = "x" + mX + "y" + mY + "z" + mZ 'Draw tile Local x:Int = oX + (vX * 32) Local y:Int = oY + (vY * 32) DrawText(tx, x+5, y+5) DrawText(ty, x+5, y+15) Next Next End Function '============================================================================================ Function DrawGrid() Local x:Int Local y:Int For x = 0 To MapW DrawLine(x * 32, 0, x * 32, MapH * 32) Next For y = 0 To MapH DrawLine(0, y * 32, MapW * 32, y * 32) Next End Function Type TPlayer Field name:String Field x:Int Field y:Int Field z:Int Field oldx:Float Field oldy:Float Field vx:Float Field vy:Float Field layer:Int = 5 Field speed:Float Field maxspeed:Float = 1 Field angle:Int End Type Type TTicker Field count:Int Field timeout:Float = 1 Field timer:Float Field counter:Int Method update() If Self.timer < MilliSecs() Self.timer = MilliSecs() + (Self.timeout * 1000) Self.count = Self.counter Self.counter = 0 Else Self.counter:+1 End If End Method End Type