Scrolling breaks at 0,0 origin!

BlitzMax Forums/BlitzMax Programming/Scrolling breaks at 0,0 origin!

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


See the problem is related to the fact that we work below 0.

Look, if you do a division above 0, your value goes down.
6/3 = 2 (from 6 to 2) a decrease

If you do a division below zero, your value goes up.

-6/3 = -2 (from -6 to -2 ) an increase

I need it to go down! (maintain the decrease)

A solution could be to check if its a negative value, and if so, substract an extra 32px.
But it doesnt feel right...

-EDIT- doesnt work. see where in a 0 zero tile. you can check if 0 is lower then 0.

abs?*

*Disclaimer: I haven't read the code, so don't actually know if this will solve the problem, I'm just guessing.

nope. abs is not relative to this issue.

It has todo with truncating towards 0, something i need to reverse when i, below 0. Im gonne play a bit more with the floor function.

ugh.. didnt work. anyone?

-EDIT- playing arround with this made some changes, but still not fixed.
			If oX>0 tX:-1
			If oY>0 tY:-1


.

heck, i will just throw an offset in the whole application of 144000 px to prevent me from running below zero. :S i spend over 12 hours, im really pissed. stupid negative values.

I couldn't find any obvious way around it. The problem is, a negative less than 32 will give 0 when divided by 32 and so does a positive division. one way to do it's, lets say, it is moving in the positive direction, and the previous position was less than 0 and the new position is greater than 0 than add 32 to the direction being affected. the same principal applies when going the oposite direction. anyway that is the only solution I can think of.
[edited]
not quite what I thought but close. see below.

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

Global px% '********************************************
Global py% '********************************************

'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()
	Local ox% = 0 - player.x + ((MapW * 32) / 2)
	Local oy% = 0 - player.y + ((MapH * 32) / 2)
	If px >= 0 And (ox <0) player.x:+32 ox:-1       '**********************
	If px <-32 And (ox > px) player.x:-32; ox:+1    '**********************
	If py >= 0 And (oy <0) player.y:+32; oy:-1      '**********************
	If py <-32 And (oy > py) player.y:-32; oy:+1    '**********************

	SetOrigin(ox,oy ) 

	'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", 700, 10
	DrawText "UPS: " + UPS.count, 700, 25
	DrawText "FPS: " + FPS.count, 700, 40
	DrawText "Speed: " + player.speed + " of " + player.maxspeed, 700, 60
	DrawText "x: " + player.x, 700, 75
	DrawText "y: " + player.y, 700, 90
	DrawText "ox: "+ox,700,105
	DrawText "oy: "+oy,700,120
	SetColor 255,255,255
	
	'Delay(10)
	Flip SyncWait
	
	px =ox%
	py =oy%
	
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


I see your point. I tried this as well but on the render_layer level. I succeed, however, it is still a manipulation, when i applied it to the game, it wouldnt work out... yes, the grid worked, but everything else wouldn't as if it noticed the grid was manipulated.

What i did is, on top of the renderlayer()

local oldx:int=x
local oldy:int=y
if oldx>0 then x:+32
if oldy>0 then y:+32


then just before drawing i had to reset it

if oldx>0 then x:-32
if oldy>0 then y:-32


See the result, works perfect, but not in the game :S

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
	
	Local oldx:Int=x     '<<<<<<<<<<<
	Local oldy:Int=y     '<<<<<<<<<<<
	If oldx>0 Then x:+32 '<<<<<<<<<<<
	If oldy>0 Then y:+32 '<<<<<<<<<<<
	
	'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) 
			
			If oldx>0 Then x:-32 '<<<<<<<<<<<
			If oldy>0 Then y:-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


Hah, heck, after 16 hours i got it.

We noticed the problem had todo with division. The only place in the render function where a division was preformed was here:

			Local tX:Int = vX + (oX / 32) 
			Local tY:Int = vY + (oY / 32) 


I just hacked that to force a division above 0.

			Local tX:Int = vX + ((oX + 32000000) / 32) - 1000000
			Local tY:Int = vY + ((oY + 32000000) / 32) - 1000000


This way i dont manipulate the grid. w00t! and it works without issues.

ok. if i push it higher then 320000000 the game freezes. Why is that? does it have todo with a memory range?

I invented 2 new functions, basicly its a Floor and Ceil function, but you can specify the size, and it works with ints as well.

Function SuperFloor:Int(val:Int, size:Int) 
	While (val Mod size) <> 0
		val:-1
	Wend
	Return val
End Function

Function SuperCeil:Int(val:Int, size:Int) 
	While (val Mod size) <> 0
		val:+1
	Wend
	Return val
End Function

This code did some miracles in my RPG.

Ok, i now even removed this code
Local tX:Int = vX + ((oX + 32000000) / 32) - 1000000
Local tY:Int = vY + ((oY + 32000000) / 32) - 1000000


And with my new SuperFloor() function, its all solved. Amazing. All the problems are solved and i could safely remove any hacks i placed.

Hello.

Isn't there a potential speed issue with repeated use of your Floor and Ceiling functions? I was under the impression that you took quite a hit using MOD?

Goodbye.

no? maybe 1 or 2 fps :S i dunno.

Actualy, bypassing the mod function (just stripping it out) realy LOSES me FPS. when i add the floor and mod functions the FPS increases!

HMm... altough, you are right. See, when i modified the functions to this: I gained 4 FPS in preformance:

'SuperFloor
Function SuperFloor:Int(val:Int, size:Int) 
	Return val - Abs(val Mod size) 
End Function

'SuperCeil
Function SuperCeil:Int(val:Int, size:Int) 
	Return val + Abs(val Mod size) 
End Function

Here i only use the MOD function 1 time.