#Include "Windows.bi" #Include "LoadImgFile.bi" ScreenRes 1024, 768, 32 Declare Sub Load() Declare Sub LoadRes() Declare Sub Save(LevelNumber as Integer) Declare Sub G() Declare Sub Control() Declare Sub EditControl() Dim Shared as Byte World(0 to 63, 0 to 63) Dim Shared as Integer XPos Dim Shared as Integer YPos Dim Shared as Byte Auswahl Dim Shared as Integer lvlnr 'Res Dim Shared as ANY PTR massive Dim Shared as ANY PTR Background Dim Shared as ANY PTR crystal Dim Shared as ANY PTR earth Dim Shared as ANY PTR Stone Dim Shared as ANY PTR StairDown Dim Shared as ANY PTR StairUp Dim Shared as ANY PTR Block Dim Shared as ANY PTR Pickaxe Dim Shared as ANY PTR BCrystal Dim Shared as ANY PTR CrystalEarth Dim Shared as ANY PTR BCrystalEarth Dim Shared as ANY PTR DeadEarth Dim Shared as ANY PTR Barrel Dim Shared as ANY PTR TNT Load() LoadRes() While(NOT Multikey(&h01)) Control() EditControl() ScreenLock G() ScreenUnlock Sleep 10 Wend Sub Save(LevelNumber as Integer) Dim as Integer File Dim as Integer a, b File = FreeFile If Open("lvl\Level" & STR(LevelNumber) & ".dat" For Output as #File) = 0 then For a = 0 to 63 For b = 0 to 63 Print #File, World(a, b) Next b Next a Close #File Else MessageBox(0, "Could not open file lvl\Level" & STR(LevelNumber) & ".dat", "Error", MB_ICONEXCLAMATION Or MB_OK Or MB_SETFOREGROUND) Endif MessageBox(0, "Saved!", "Saved!", MB_ICONINFORMATION Or MB_OK Or MB_SETFOREGROUND) End Sub Sub G() Dim as Integer a, b 'Hintergrund For a = 0 to 1024 - 64 Step 64 For b = 0 to 768 - 64 Step 64 Put(a, b), Background, PSet Next b Next a 'Vordergrund For a = 0 to 15 For b = 0 to 11 If XPos + a >= 0 And XPos + a <= 63 And _ YPos + b >= 0 And YPos + b <= 63 then If World(XPos + a, YPos + b) = 0 then Put(a * 64, b * 64), earth , PSet If World(XPos + a, YPos + b) = 2 then Put(a * 64, b * 64), Stone , ALPHA, 255 If World(XPos + a, YPos + b) = 3 then Put(a * 64, b * 64), crystal , ALPHA, 255 If World(XPos + a, YPos + b) = 4 then Put(a * 64, b * 64), StairUp , ALPHA, 255 If World(XPos + a, YPos + b) = 5 then Put(a * 64, b * 64), StairDown , ALPHA, 255 If World(XPos + a, YPos + b) = 6 then Put(a * 64, b * 64), massive , PSet If World(XPos + a, YPos + b) = 7 then Put(a * 64, b * 64), Block , ALPHA, 255 If World(XPos + a, YPos + b) = 8 then Put(a * 64, b * 64), Pickaxe , ALPHA, 255 If World(XPos + a, YPos + b) = 9 then Put(a * 64, b * 64), BCrystal , ALPHA, 255 If World(XPos + a, YPos + b) = 10 then Put(a * 64, b * 64), CrystalEarth , PSet If World(XPos + a, YPos + b) = 11 then Put(a * 64, b * 64), BCrystalEarth , PSet If World(XPos + a, YPos + b) = 12 then Put(a * 64, b * 64), DeadEarth , PSet If World(XPos + a, YPos + b) = 13 then Put(a * 64, b * 64), Barrel , ALPHA, 255 If World(XPos + a, YPos + b) = 14 then Put(a * 64, b * 64), TNT , ALPHA, 255 Else Put(a * 64, b * 64), massive, PSet Endif Next b Next a End Sub Sub Load() Dim as Integer File Dim as Integer a, b Dim as Integer LevelNumber Input "Input levelnumber: ", LevelNumber lvlnr = LevelNumber File = Freefile If Open("lvl\Level" & STR(LevelNumber) & ".dat" For Input as #File) = 0 then For a = 0 to 63 For b = 0 to 63 Input #File, World(a, b) Next b Next a Close #File Else File = FreeFile If Open("lvl\Level" & STR(LevelNumber) & ".dat" For Output as #File) = 0 then Close #File Else MessageBox(0, "Could not open file lvl\Level" & STR(LevelNumber) & ".dat", "Error", MB_ICONEXCLAMATION Or MB_OK Or MB_SETFOREGROUND) End 0 Endif Endif End Sub Sub LoadRes() Background = LoadImgFile("res\map\background.bmp") crystal = LoadImgFile("res\map\crystal.bmp") earth = LoadImgFile("res\map\earth.bmp") massive = LoadImgFile("res\map\massive.bmp") Stone = LoadImgFile("res\map\stone.bmp") StairDown = LoadImgFile("res\map\stairdown.bmp") StairUp = LoadImgFile("res\map\stairup.bmp") Block = LoadImgFile("res\map\block.bmp") Pickaxe = LoadImgFile("res\map\pickaxe.bmp") BCrystal = LoadImgFile("res\map\bcrystal.bmp") CrystalEarth = LoadImgFile("res\map\crystalearth.bmp") BCrystalEarth = LoadImgFile("res\map\bcrystalearth.bmp") DeadEarth = LoadImgFile("res\map\deadearth.bmp") Barrel = LoadImgFile("res\map\barrel.bmp") TNT = LoadImgFile("res\map\tnt.bmp") End Sub Sub Control() Dim as Integer a If Multikey(&h11) then YPos -= 1 If Multikey(&h1F) then YPos += 1 If Multikey(&h1E) then XPos -= 1 If Multikey(&h20) then XPos += 1 For a = 2 to 10 If Multikey(a) then Auswahl = a - 1 Next a If Multikey(&h0B) then Auswahl = 0 If Multikey(&h12) then Auswahl = 10 'E If Multikey(&h13) then Auswahl = 11 'R If Multikey(&h14) then Auswahl = 12 'T If Multikey(&h15) then Auswahl = 13 'Z If Multikey(&h16) then Auswahl = 14 'U If Multikey(&h39) then Save(lvlnr) End Sub Sub EditControl() Dim as Integer MX, MY, MB GetMouse MX, MY,, MB If MB = 1 then If Int(MX / 64) + XPos >= 0 And Int(MX / 64) + XPos <= 63 And _ Int(MY / 64) + YPos >= 0 And Int(MY / 64) + YPos <= 63 then World(Int(MX / 64) + XPos, Int(MY / 64) + YPos) = Auswahl Endif Endif End Sub