FYI I managed to make a method where the world can be as big as you want with zero slowdown in my game Bosskillers, a 2D rpg. How i did it was only render what you see. Take a look at this pseudo code:
Code:Const TILE_WIDTH As Long = 32 Const TILE_HEIGHT As Long = 24 Coordinates.X = Int(-(Map.Position.X) / TILE_WIDTH) Coordinates.Y = Int(-(Map.Position.Y) / TILE_HEIGHT) 'converts your position into tile coordinates 'This here allows the world to be as gigantic as you want with zero slow down like 5000x5000 for example. Only draws what is on screen. X1 = Coordinates.X Y1 = Coordinates.Y X2 = Coordinates.X + Map.Screen_Tile_Width 'Number of tiles on screen at once for one row Y2 = Coordinates.Y + Map.Screen_Tile_Height 'Number of tiles on screen at once for one column If X2 <= 0 Then X2 = 0 If Y2 <= 0 Then Y2 = 0 If Y2 >= Map.Height - 1 Then Y2 = Map.Height - 1 If X2 >= Map.Width - 1 Then X2 = Map.Width - 1 If X1 <= 0 Then X1 = 0 If Y1 <= 0 Then Y1 = 0 If X1 >= X2 Then X1 = X2 If Y1 >= Y2 Then Y1 = Y2 For Y = Y1 To Y2 For X = X1 To X2 If Running = True Then If Not ((Map.Position.X + ((TILE_WIDTH * X) + TILE_WIDTH) < R.Left) Or (Map.Position.X + ((TILE_WIDTH * X)) > R.Right) Or (Map.Position.Y + ((TILE_HEIGHT * Y) + TILE_HEIGHT) < R.Top) Or (Map.Position.Y + ((TILE_HEIGHT * Y)) > R.Bottom)) Then Draw_Tile End If Next X Next Y





Mark Thread Resolved
Reply With Quote