#include "Inc\LoadBitmap.bi" #include "vbcompat.bi" #include "fbgfx.bi" declare Sub LoadGraphics() declare Sub RenderMap() declare sub logp(txt as String) Const as Integer ScreenX = 800 '1280 Const as Integer ScreenY = 600 '800 ScreenRes ScreenX, ScreenY, 32 const as UInteger MapX = 101, MapY = 101 dim shared as any ptr map(0 to MapY, 0 to MapX) const as Integer TileX = 600, TileY = 420 Dim shared as Integer ScrollX = 0, ScrollY = 0 Dim figur As Any Ptr = LoadBitmap("data\figur.bmp") Dim as Double curTime, prevTime, deltaTime, prevTimeFPS dim as Integer FPS, FPScnt Const as Integer RasterX = 40 '75 Const as Integer RasterY = 20 '70 Dim Taste as String LoadGraphics() curTime = timer() prevTime = curTime prevTimeFPS = curTime Do Until Taste = Chr(27) Or Taste = Chr (255, 107) prevTime = curTime curTime = Timer() deltaTime = curTime - prevTime if (curTime - prevTimeFPS >= 1.0) then prevTimeFPS = curTime FPS = FPScnt FPScnt = 0 else FPScnt += 1 end if Taste = InKey() /' if Taste = chr(255,72) then 'Oben if (ScrollY > 0) then ScrollY -= 1 elseif Taste = chr(255,75) then 'Links if (ScrollX > 0) then ScrollX -= 1 elseif Taste = chr(255,77) then 'Rechts if (ScrollX*RasterX+ScreenX < (MapX+1)*TileX) then ScrollX += 1 elseif Taste = chr(255,80) then 'Unten if (ScrollY*RasterY+ScreenY < (MapY+1)*TileY) then ScrollY += 1 end if '/ if MultiKey(fb.SC_LEFT) then if (ScrollX > 0) then ScrollX -= 1 end if if MultiKey(fb.SC_UP) then if (ScrollY > 0) then ScrollY -= 1 end if if MultiKey(fb.SC_RIGHT) then if (ScrollX*RasterX+ScreenX < (MapX+1)*TileX) then ScrollX += 1 end if if MultiKey(fb.SC_DOWN) then if (ScrollY*RasterY+ScreenY < (MapY+1)*TileY) then ScrollY += 1 end if ScreenLock RenderMap() Put (100,100), figur, Trans locate 1,1: print FPS; ScreenUnlock Sleep 5, 1 Loop for q as integer = 0 to MapY for w as Integer = 0 to MapX if (map(q,w) <> 0) then ImageDestroy(map(q,w)) next next Sub RenderMap() for q as integer = 0 to MapY for w as Integer = 0 to MapX if ((q+1)*TileX > ScrollX*RasterX andalso q*TileX < ScrollX*RasterX+ScreenX andalso (w+1)*TileY > ScrollY*RasterY andalso w*TileY < ScrollY*RasterY+ScreenY) then if (map(q,w) <> 0) then Put (q*TileX - ScrollX*RasterX, w*TileY - ScrollY*RasterY), map(q,w), Pset else line (q*TileX - ScrollX*RasterX, w*TileY - ScrollY*RasterY)-((q+1)*TileX - ScrollX*RasterX -1, (w+1)*TileY - ScrollY*RasterY-1), 0, BF line (q*TileX - ScrollX*RasterX, w*TileY - ScrollY*RasterY)-((q+1)*TileX - ScrollX*RasterX -1, (w+1)*TileY - ScrollY*RasterY-1), &HFF0000, B line (q*TileX - ScrollX*RasterX, w*TileY - ScrollY*RasterY)-((q+1)*TileX - ScrollX*RasterX -1, (w+1)*TileY - ScrollY*RasterY-1), &HFF0000 line (q*TileX - ScrollX*RasterX, (w+1)*TileY - ScrollY*RasterY-1)-((q+1)*TileX - ScrollX*RasterX -1, w*TileY - ScrollY*RasterY), &HFF0000 draw string (q*TileX - ScrollX*RasterX + TileX/2, w*TileY - ScrollY*RasterY + TileY/3), "(" + str(q) + ", " + str(w) + ")", &HFFAAAA end if end if next next end sub Sub LoadGraphics() for q as integer = 0 to MapY for w as Integer = 0 to MapX map(q,w) = 0 if FileExists("data\map\"+str(q)+","+str(w)+".bmp") then map(q,w) = ImageCreate(TileX, TileY) bload "data\map\"+str(q)+","+str(w)+".bmp", map(q,w) logp("loading "+str(q)+","+str(w)) end if next next end sub sub logp(txt as String) dim fileNo As Integer = FreeFile open cons for output as #fileNo print #fileNo, txt close #fileNo end sub