
-----------------------------------
TokenHerbz
Fri Mar 03, 2006 3:08 am

Working with big maps...
-----------------------------------
Normally when i am useing maps, ill screenshot them so there much faster to reload...

But, how do i make a big map fast especially when you want to move it?
if you screen shot it, and move the map, theres no variable and crash, without screenshot, its so slow and laggish...   I need some opinions, Heres my example:


setscreen ("Graphics:max;max,offscreenonly")

%%%Variables
var TileSize := 10
var TileRow, TileColumn : int := 100
var file : int
var TileLoc : array 1 .. TileRow, 1 .. TileColumn of int
var mapx, mapy : int := 0
var Scroll_Rate : int := 5
var ScreenShot : int

open : file, "map1.txt", get
for x : 1 .. upper (TileLoc, 1)
    for y : 1 .. upper (TileLoc, 2)
        get : file, TileLoc (x, y)
    end for
end for
close : file
proc draw_map (leftx, bottomy : int, tile : array 1 .. *, 1 .. * of int)
    cls
    for x : 1 .. upper (tile, 1)
        for y : 1 .. upper (tile, 2)
            if tile (x, y) = 0 then     %%borders
                Draw.FillBox (x * TileSize + leftx, y * TileSize + bottomy, (x + 1) * TileSize + leftx, (y + 1) * TileSize + bottomy, black)
            elsif tile (x, y) = 1 then  %%grass
                Draw.FillBox (x * TileSize + leftx, y * TileSize + bottomy, (x + 1) * TileSize + leftx, (y + 1) * TileSize + bottomy, green)
            elsif tile (x, y) = 2 then  %%cliff
                Draw.FillBox (x * TileSize + leftx, y * TileSize + bottomy, (x + 1) * TileSize + leftx, (y + 1) * TileSize + bottomy, gray)
            elsif tile (x, y) = 9 then  %%Minerals
                Draw.FillBox (x * TileSize + leftx, y * TileSize + bottomy, (x + 1) * TileSize + leftx, (y + 1) * TileSize + bottomy, blue)
            end if
        end for
    end for
end draw_map

%%Main program
draw_map (-20, -20, TileLoc)
loop
    var mx, my, mb : int        %%Mouse variables
    Mouse.Where (mx, my, mb)    %%Detects the mouse
    if my >= maxy - 40 then     %%moves map up with mouse
        mapy -= Scroll_Rate
        draw_map (mapx, mapy, TileLoc)
    elsif my = maxx - 40 then     %%moves map right with mouse
        mapx -= Scroll_Rate
        draw_map (mapx, mapy, TileLoc)
    elsif mx  (maxx, maxy)) and store that in ScreenShot.
- now, in your loop, remove all calls to draw_map(), and instead have a single call drawing ScreenShot at (mapx, mapy) outside of the if-structure.

Add in the necassary View.Updates, delays, and cls and you're good to go.

-----------------------------------
TokenHerbz
Fri Mar 03, 2006 10:51 am


-----------------------------------
Delos i attempted this, when i move the cursor to the right, that map is supposed to move to the left, thus revealing more of the map (like in Brood War) .   thats when i get errors...

-----------------------------------
Delos
Fri Mar 03, 2006 11:13 am


-----------------------------------
Code please...(I've tried it and it works, so perhaps you're doing something wrong.)

-----------------------------------
TokenHerbz
Fri Mar 03, 2006 11:22 am


-----------------------------------
i get errors when i move the screen to a direction greater then the max

-----------------------------------
Delos
Fri Mar 03, 2006 5:41 pm


-----------------------------------
Ok, I'll try be a little clearer this time:

I've editted your code and got it to work, doing exactly what you wanted it to.  Now, to be able to help you do the same, we would need you to post your updated code.

Your saying something to the effect of:

...to a direction greater then 
is really hard to work off.  Max-what?  'maxx', 'maxy', the edge of your screen, the size of your map?  See what I mean.
Posting code, along with a description of your errors, why you think you're getting them, and other relevant info makes helping you so much easier.
