Hi!
Ja kann man nicht viel zu sagen, außer das man natürlich die Tiles
via LoadAnimImage, und die Map aus einer Mapdatei laden sollte.
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN]
AppTitle "Tilemap - Example" Graphics 640, 480, 32, 2
Const vCount = 640/16+1 Const hCount = 480/16+1
tileSet = CreateImage(16, 16, 4) SetBuffer ImageBuffer(tileSet, 0) Color 255, 0, 0 : Rect 0, 0, 16, 16, 1 SetBuffer ImageBuffer(tileSet, 1) Color 0, 255, 0 : Rect 0, 0, 16, 16, 1 SetBuffer ImageBuffer(tileSet, 2) Color 0, 0, 255 : Rect 0, 0, 16, 16, 1 SetBuffer ImageBuffer(tileSet, 3) Color 255, 255, 0 : Rect 0, 0, 16, 16, 1
SetBuffer BackBuffer()
Const mapWidth =79 Const mapHeight=49 Dim tileMap(mapWidth, mapheight)
For x=0 To mapWidth For y=0 To mapHeight tileMap(x, y)=Rnd(3) Next Next
While Not KeyDown(1) If KeyDown(203) Then xScroll=xScroll-1 If KeyDown(205) Then xScroll=xScroll+1 If KeyDown(200) Then yScroll=yScroll-1 If KeyDown(208) Then yScroll=yScroll+1 If xScroll<0 Then xScroll=0 If yScroll<0 Then yScroll=0 If (xScroll/16)-(xScroll Mod 16)>0 Then If xScroll>(mapWidth-vCount)*16 Then xScroll=(mapWidth-vCount)*16 Else If xScroll>(mapWidth-vCount-1)*16 Then xScroll=(mapWidth-vCount-1)*16 EndIf If (yScroll/16)-(yScroll Mod 16)>0 Then If yScroll>(mapHeight-hCount)*16 Then yScroll=(mapHeight-hCount)*16 Else If yScroll>(mapHeight-hCount-1)*16 Then yScroll=(mapHeight-hCount-1)*16 EndIf
xStart=xScroll / 16 yStart=yScroll / 16 xOffset=xScroll Mod 16 yOffset=yScroll Mod 16 If xOffset>0 Then If yOffset>0 Then For x=0 To vCount For y=0 To hCount DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart) Next Next Else For x=0 To vCount For y=0 To hCount-1 DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart) Next Next EndIf Else If yOffset>0 Then For x=0 To vCount-1 For y=0 To hCount DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart) Next Next Else For x=0 To vCount-1 For y=0 To hCount-1 DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart) Next Next EndIf EndIf
Flip Wend
End
mfg olli
|