Simple Tileeditor v0.1 - No Save

Previous topic - Next topic

Amon

The following code shows you how to setup the beginings of a simple single screen tilemap editor. :)

Code (glbasic) Select
// --------------------------------- //
// Project: SSMapEditor (Single Screen Map Editor) By Amon - No Save possible
// Save Coming in Version 2
// Start: Sunday, December 27, 2009
// IDE Version: 7.203


SETCURRENTDIR("Media") // seperate media and binaries?
LOADANIM "tileset.png",0,25,25
LOADSPRITE "arrow.png",1

SETSCREEN 800,600,0


CurrentTile = 0

MAPWIDTH = 32 // MapWidth
MAPHEIGHT = 24 // MapHeight

TileWidthHeight = 25

GLOBAL MouseX, MouseY,MB1,MB2

DIM Map#[MAPWIDTH][MAPHEIGHT]

FOR x1 = 0 TO MAPWIDTH - 1
FOR y1 = 0 TO MAPHEIGHT - 1
Map[x1][y1] = RND(4)
NEXT
NEXT


WHILE KEY(01) = 0

BLACKSCREEN

FillMap()
DrawMap()

DRAWSPRITE 1,MouseX/MouseX*MouseX,MouseY/MouseY*MouseY

SHOWSCREEN
WEND

FUNCTION DrawMap:
FOR xiter = 0 TO MAPWIDTH -1
FOR yiter = 0 TO MAPHEIGHT - 1
IF Map[xiter][yiter] = 0
DRAWANIM 0,0,xiter * TileWidthHeight, yiter * TileWidthHeight
ENDIF
IF Map[xiter][yiter] = 1
DRAWANIM 0,1,xiter * TileWidthHeight, yiter * TileWidthHeight
ENDIF
IF Map[xiter][yiter] = 2
DRAWANIM 0,2,xiter * TileWidthHeight, yiter * TileWidthHeight
ENDIF
IF Map[xiter][yiter] = 3
DRAWANIM 0,3,xiter * TileWidthHeight, yiter * TileWidthHeight
ENDIF
IF Map[xiter][yiter] = 4
DRAWANIM 0,4,xiter * TileWidthHeight, yiter * TileWidthHeight
ENDIF
IF Map[xiter][yiter] = 5
DRAWANIM 0,5,xiter * TileWidthHeight, yiter * TileWidthHeight
ENDIF

NEXT
NEXT
ENDFUNCTION

FUNCTION FillMap:
IF KEY(57) = 1
CurrentTile = CurrentTile + 1
IF CurrentTile >5 THEN CurrentTile = 0
ENDIF

MOUSESTATE MouseX, MouseY, MB1, MB2

IF MB1 = 1
Map[MouseX/TileWidthHeight][MouseY/TileWidthHeight] = CurrentTile
ENDIF

ENDFUNCTION



[attachment deleted by admin]
- http://www.amon.co | Dev Tools - BlitzMax - Shiva Unlimited - Unity Pro - Carrara 8 Pro - Hexagon 2.2.5 - Blacksmith 3D Paint - FuturePaint Pro - Bryce 7 Pro.
I'm never wrong at all; I just discover 1000 ways that don't work!