Platform issues...

BlitzMax Forums/BlitzMax Programming/Platform issues...

Twinprogrammer(Posted 2012) [#1]
Hello,

I've been making a map editor. It works great but I want the editor to move the map around(so you can have a map larger than the screen). The drawing works when I use SetOrigin to my map offset, but the map(The array with the map data) itself doesn't move with the tiles. How would I be able to move the map array with the tiles ?


xlsior(Posted 2012) [#2]
Use off-set variables -- instead of always drawing (0) to (screenwidth), draw (0+offset) to (screenwidth+offset)

When you scroll to the side, adjust the offset up or down


Twinprogrammer(Posted 2012) [#3]
That is what I use. It works, but I can't seem to get the map array to follow the offset. Here's a piece of code from my editor...


And the tile placing function(This is the one I need help on, tell me if something's wrong)...



Last edited 2012


Jesse(Posted 2012) [#4]
I suspect it's something like this:
Function UpdateEditor()
    'Check if the mouse is in the map boundaries
    If MouseX() > MapOffX and MouseX() < (TileWidth * MapWidth) + MapOffX
        If MouseY() > MapOffY And MouseY() < (TileHeight * MapHeight) + MapOffY
        
            If MouseDown(1)
                Map[(MapOffX+MouseX()) / TileWidth, (MapOffY+MouseY()) / TileHeight] = CurrentTile
            End If
        End If
    End If 
End Function




Twinprogrammer(Posted 2012) [#5]
I tried that too. If the map offset is not 0, I get an index out of range exception. Any other suggestions ?

Last edited 2012


Chalky(Posted 2012) [#6]
A few things to check:

Is your array big enough to allow for the required increase in offsets?

When you increase/decrease MapOffX/MapOffY do you check that MapOffX/MapOffY + Tile-Width/Height-Of-Screen does not fall outside the array boundaries?

Does your code assume base 0 or base 1?


TomToad(Posted 2012) [#7]
Remember that SetOrigin adds the offset to the images, so that SetOrigin 10,10 will draw an image at 10,10 with DrawImage,Image,0,0. So to scroll the map properly, you need to use a negative origin. Also be sure to subtract the origin from the mouse coordinates to get the correct position on the map. Here is an example.

Note that this is not the only way of doing things and might even not be the most efficient.


Twinprogrammer(Posted 2012) [#8]
Cool it works ! Now my editor is complete. Thanks for the help everybody !

Last edited 2012