DECLARE SUB Ghostsound ()
DECLARE SUB Vierletter (LETTERX, LETTERY, ZCHNFARBE, ZCHNKETTE$)
DECLARE SUB Bombsound (wiederholung)
DECLARE SUB RedrawTimeBar (Zeit, afb, ifb)
DECLARE FUNCTION GETKEY$ ()
DECLARE SUB Clearboard ()
CLS
CONST BombFrameDelay! = .02 ' seconds per bomb animation frame (QB64PE)
DIM Feld01(256): DIM Feld07(256)
DIM Feld02(256): DIM Feld08(256)
DIM Feld03(256): DIM Feld09(256)
DIM Feld04(256): DIM Feld10(256)
DIM Feld05(256): DIM Feld11(256)
DIM Feld06(256): DIM Feld12(256)
DIM Feld13(256): DIM Editor$(50, 15)
DIM Spiel$(52, 15): DIM Bombret(256)
FOR K = 1 TO 10: KEY K, CHR$(K): NEXT K
OPEN "Levels2.trf" FOR INPUT AS #1
FOR InLevels = 1 TO 50
    FOR LevelZeilen = 1 TO 11
        INPUT #1, Editor$(InLevels, LevelZeilen)
    NEXT LevelZeilen
NEXT InLevels
CLOSE #1
SCREEN 0, 0, 0, 0
Md(1) = 7: Md(2) = 1
Nmc$(1) = "EGA.TRF": Nmc$(2) = "CGA.TRF"
Infb(1) = 1: Infb(2) = 0: df = 1
Undlin(1) = 15: Undlin(2) = 1
ON ERROR GOTO VideoErr
SCREEN Md(df)
Modus = df
GOTO Startgame
VideoErr:
df = df + 1
IF df = 3 THEN
    PRINT "Video Graphics Array          (VGA) nicht gefunden."
    PRINT "Enhanced Graphics Adapter     (EGA) nicht gefunden."
    PRINT "Color Graphics Adapter        (CGA) nicht gefunden."
    PRINT "Multi Color Graphics Adapter (MCGA) nicht gefunden."
    COLOR 14, 0
    PRINT "Es ist leider keine Grafikausgabe mglich.         "
    x$ = INPUT$(1)
    COLOR 7, 0
    END
END IF
RESUME
Startgame:
_FULLSCREEN _SQUAREPIXELS
ON ERROR GOTO 0
DIM Undrline(40)
DIM Programmer(7, 246)
LOCATE 1, 1: PRINT "Programmiert von Andreas Thiede"
FOR x = 0 TO 245
    GET (x, 0)-(x, 7), Programmer(0, x)
NEXT
CLS
LINE (0, 0)-(10, 3), 15, BF
GET (0, 0)-(10, 3), Undrline()
LINE (0, 0)-(10, 10), 0, BF
IF Modus = 1 THEN Bilddata$ = "EGAst.trf"
IF Modus = 2 THEN Bilddata$ = "CGAst.trf"
IF Modus = 1 THEN Modus = 7
IF Modus = 2 THEN Modus = 1
IF Modus = 7 THEN SCREEN 7, , 0, 1: OPEN "ega.trf" FOR INPUT AS #1
IF Modus = 1 THEN SCREEN 1: OPEN "cga.trf" FOR INPUT AS #1
FOR Gesamtbilder = 1 TO 13
    FOR Bild = 0 TO 15
        INPUT #1, Bildlinie$
        PSET (0, Bild)
        DRAW Bildlinie$
    NEXT Bild
    IF Gesamtbilder = 1 THEN GET (0, 0)-(15, 15), Feld01()
    IF Gesamtbilder = 2 THEN GET (0, 0)-(15, 15), Feld02()
    IF Gesamtbilder = 3 THEN GET (0, 0)-(15, 15), Feld03()
    IF Gesamtbilder = 4 THEN GET (0, 0)-(15, 15), Feld04()
    IF Gesamtbilder = 5 THEN GET (0, 0)-(15, 15), Feld05()
    IF Gesamtbilder = 6 THEN GET (0, 0)-(15, 15), Feld06()
    IF Gesamtbilder = 7 THEN GET (0, 0)-(15, 15), Feld07()
    IF Gesamtbilder = 8 THEN GET (0, 0)-(15, 15), Feld08()
    IF Gesamtbilder = 9 THEN GET (0, 0)-(15, 15), Feld09()
    IF Gesamtbilder = 10 THEN GET (0, 0)-(15, 15), Feld10()
    IF Gesamtbilder = 11 THEN GET (0, 0)-(15, 15), Feld11()
    IF Gesamtbilder = 12 THEN GET (0, 0)-(15, 15), Feld12()
    IF Gesamtbilder = 13 THEN GET (0, 0)-(15, 15), Feld13()
NEXT Gesamtbilder
CLOSE
IF Modus = 7 THEN SCREEN 7, , 0, 0
CLS
Newloc:
IF Modus = 7 THEN ifb = 12: afb = 10
IF Modus = 1 THEN ifb = 1: afb = 2
CLS
OPEN Bilddata$ FOR INPUT AS #6
FOR ptz = 0 TO 199
    INPUT #6, StartBild$
    PSET (0, ptz)
    DRAW StartBild$
NEXT ptz
CLOSE #6
FOR x = 1 TO 309 STEP 1
    PUT (x, 44), Undrline(), XOR
    IF x > 108 AND x < 200 THEN PSET (x - 1, 44): DRAW "c14d4"
    FOR w = 1 TO 3: NEXT w
    PUT (x, 44), Undrline(), XOR
NEXT x
MAPQ = 0: kebnc = 0
DO UNTIL MAPQ = 1 OR MAPQ = 2 OR MAPQ = 3
    MAPQ$ = INKEY$
    MAPQ = VAL(MAPQ$)
    IF knebnc < 260 THEN kebnc = kebnc + 1
    IF kebnc = 250 THEN
        FOR x = 25 TO 290: PSET (x, 150), 14: DRAW "r1": FOR w = 1 TO 5: NEXT w: NEXT x
        FOR y = 150 TO 165: PSET (290, y), 14: DRAW "r1": FOR w = 1 TO 5: NEXT w: NEXT y
        FOR x = 290 TO 25 STEP -1: PSET (x, 165), 14: DRAW "r1": FOR w = 1 TO 5: NEXT w: NEXT x
        FOR y = 165 TO 150 STEP -1: PSET (25, y), 14: DRAW "r1": FOR w = 1 TO 5: NEXT w: NEXT y
        FOR p = 35 TO 35 + 245
            PUT (p, 154), Programmer(0, p - 35), XOR
            FOR w = 1 TO 5: NEXT w
        NEXT p
    END IF
LOOP
x1 = 0: y1 = 0: x2 = 319: y2 = 199
DO UNTIL y1 = 100
    LINE (x1, y1)-(x2, y2), 0, B
    LINE (x1 - 1, y1 - 1)-(x2 + 1, y2 + 1), 0, B
    x1 = x1 + 2: y1 = y1 + 1: x2 = x2 - 2: y2 = y2 - 1
    FOR w = 1 TO 10: NEXT w
LOOP
IF MAPQ = 1 THEN GOTO spiel1
IF MAPQ = 2 THEN GOTO Editor
IF MAPQ = 3 THEN END


spiel1:
LEBEN = 3: LevelLeben = 0: Bomben = 0: Zeit = 0: Gesamtpunkte = 0
level = 1: Punkte = 0: spivx = 1: spivy = 1: spix = 1: spiy = 1
IF leveltest = 1 THEN level = savelevel
Spiel2:
IF level = 51 THEN GOTO wingame
Loda = 0: Wada = 0: Pflanz = 0
Bomben = Bomben - 2: IF Bomben < 1 THEN Bomben = 0
Punkte = Punkte - 15: IF Punkte < 1 THEN Punkte = 0
LINE (0, 0)-(289, 177), afb, B
LINE (296, 0)-(305, 177), afb, B
LINE (297, 1)-(304, 176), ifb, BF
LINE (296, 179)-(315, 191), 0, BF
LINE (296, 179)-(315, 191), afb, B
IF Modus = 7 THEN COLOR 13, 0
LOCATE 24, 1: PRINT " Leben :"; LEBEN;
IF Modus = 7 THEN COLOR 14, 0
LOCATE 25, 1: PRINT " Level :"; level;
IF Modus = 7 THEN COLOR 14, 0
LOCATE 24, 12: PRINT "Bomben :"; Bomben;
IF Modus = 7 THEN COLOR 12, 0
LOCATE 24, 25: PRINT "  Zeit :"; INT(177 - Zeit);
IF Modus = 7 THEN COLOR 12, 0
LOCATE 25, 12: PRINT "Punkte :"; Punkte;
FOR cp1 = 1 TO 50
    spso = 0
    FOR cp2 = 1 TO 11
        Spiel$(cp1, cp2) = Editor$(cp1, cp2)
        spso = spso + INSTR(Editor$(cp1, cp2), "G")
    NEXT cp2
    IF spso = 0 THEN Ziellev = cp1: EXIT FOR
NEXT cp1
IF Modus = 7 THEN COLOR 13, 0
LOCATE 25, 25: PRINT "  Ziel :"; Ziellev;
IF level = Ziellev THEN GOTO wingame
FOR Outlev1 = 1 TO 11
    FOR Outlev2 = 1 TO 18
        edx = Outlev2 * 16 - 15
        edy = Outlev1 * 16 - 15
        LINE (edx, edy)-(edx + 15, edy + 15), 0, BF
        GOSUB Setzgamesymb
    NEXT Outlev2
NEXT Outlev1
Clearboard
SOUND 1000, 5
Time1 = TIMER
IF Modus = 7 THEN COLOR 12, 0:
Spiel3:
MID$(Spiel$(level, spivy), spivx, 1) = "D"
Zeit = TIMER - Time1
PSET (297, Zeit + 1), 0: DRAW "r7"
LOCATE 24, 27: PRINT "Zeit :"; INT(177 - Zeit);
LINE (296, 0)-(305, 177), afb, B
IF INT(177 - Zeit) = 0 THEN GOTO Waterfill
IF LEBEN < 0 THEN GOTO Gameend
x$ = GETKEY$
IF x$ = CHR$(1) THEN GOTO Legbombe
IF x$ = CHR$(2) THEN Ghostsound: LEBEN = LEBEN - 1: GOTO Spiel2
IF x$ = CHR$(10) THEN GOTO Gameend
IF x$ = CHR$(13) THEN GOTO Waterfill
IF level = Ziellev THEN GOTO wingame
IF x$ = "6" THEN
    IF spivx < 18 THEN
        IF MID$(Spiel$(level, spivy), spivx + 1, 1) = "~" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivx = spivx + 1: spix = spix + 16
            PUT (spix, spiy), Feld04()
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy), spivx + 1, 1) = "C" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivx = spivx + 1: spix = spix + 16
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            GOSUB clr
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Bomben = Bomben + 1: Punkte = Punkte + 1: Zeit = Zeit - 1: RedrawTimeBar Zeit, afb, ifb
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy), spivx + 1, 1) = "A" THEN
            Ghostsound
            LEBEN = LEBEN - 1: IF LEBEN < 0 THEN GOTO Gameend
            GOTO Spiel2
        END IF
        IF MID$(Spiel$(level, spivy), spivx + 1, 1) = "J" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivx = spivx + 1: spix = spix + 16
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Punkte = Punkte + 3
            LEBEN = LEBEN + .2
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy), spivx + 1, 1) = "K" THEN
            IF spivx < 17 THEN
                IF MID$(Spiel$(level, spivy), spivx + 2, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix + 16, spiy)-(spix + 31, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx + 1) = "~"
                    spix = spix + 16: spivx = spivx + 1
                    PUT (spix, spiy), Feld04()
                    PUT (spix + 16, spiy), Feld12()
                    MID$(Spiel$(level, spivy), spivx + 1, 1) = "K"
                    SOUND 37, .5
                END IF
            END IF
        END IF
        IF MID$(Spiel$(level, spivy), spivx + 1, 1) = "B" THEN
            IF spivx < 17 THEN
                IF MID$(Spiel$(level, spivy), spivx + 2, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix + 16, spiy)-(spix + 31, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx + 1) = "~"
                    spix = spix + 16: spivx = spivx + 1
                    PUT (spix, spiy), Feld04()
                    PUT (spix + 16, spiy), Feld06()
                    MID$(Spiel$(level, spivy), spivx + 1, 1) = "E"
                    SOUND 37, .5
                END IF
            END IF
        END IF
    END IF
END IF
IF x$ = "4" THEN
    IF spivx > 1 THEN
        IF MID$(Spiel$(level, spivy), spivx - 1, 1) = "~" THEN
            MID$(Spiel$(level, spivy), spivx, 1) = "~"
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivx = spivx - 1: spix = spix - 16
            PUT (spix, spiy), Feld04()
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy), spivx - 1, 1) = "C" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivx = spivx - 1: spix = spix - 16
            GOSUB clr
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Bomben = Bomben + 1: Punkte = Punkte + 1: Zeit = Zeit - 1: RedrawTimeBar Zeit, afb, ifb
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy), spivx - 1, 1) = "A" THEN
            Ghostsound
            LEBEN = LEBEN - 1: IF LEBEN < 0 THEN GOTO Gameend
            GOTO Spiel2
        END IF
        IF MID$(Spiel$(level, spivy), spivx - 1, 1) = "J" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivx = spivx - 1: spix = spix - 16
            GOSUB clr
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Punkte = Punkte + 3
            LEBEN = LEBEN + .2
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy), spivx - 1, 1) = "K" THEN
            IF spivx > 2 THEN
                IF MID$(Spiel$(level, spivy), spivx - 2, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix - 16, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx - 1) = "~"
                    spix = spix - 16: spivx = spivx - 1
                    PUT (spix, spiy), Feld04()
                    PUT (spix - 16, spiy), Feld12()
                    MID$(Spiel$(level, spivy), spivx - 1, 1) = "K"
                    SOUND 37, .5
                END IF
            END IF
        END IF
        IF MID$(Spiel$(level, spivy), spivx - 1, 1) = "B" THEN
            IF spivx > 2 THEN
                IF MID$(Spiel$(level, spivy), spivx - 2, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix - 16, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx - 1) = "~"
                    spix = spix - 16: spivx = spivx - 1
                    PUT (spix, spiy), Feld04()
                    PUT (spix - 16, spiy), Feld06()
                    MID$(Spiel$(level, spivy), spivx - 1, 1) = "E"
                    SOUND 37, .5
                END IF
            END IF
        END IF
    END IF
END IF
IF x$ = "2" THEN
    IF spivy < 11 THEN
        IF MID$(Spiel$(level, spivy + 1), spivx, 1) = "~" THEN
            MID$(Spiel$(level, spivy), spivx, 1) = "~"
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivy = spivy + 1: spiy = spiy + 16
            PUT (spix, spiy), Feld04()
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy + 1), spivx, 1) = "C" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivy = spivy + 1: spiy = spiy + 16
            GOSUB clr
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Bomben = Bomben + 1: Punkte = Punkte + 1: Zeit = Zeit - 1: RedrawTimeBar Zeit, afb, ifb
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy + 1), spivx, 1) = "A" THEN
            Ghostsound
            LEBEN = LEBEN - 1: IF LEBEN < 0 THEN GOTO Gameend
            GOTO Spiel2
        END IF
        IF MID$(Spiel$(level, spivy + 1), spivx, 1) = "J" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivy = spivy + 1: spiy = spiy + 16
            GOSUB clr
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Punkte = Punkte + 3
            LEBEN = LEBEN + .2
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy + 1), spivx, 1) = "K" THEN
            IF spivy < 10 THEN
                IF MID$(Spiel$(level, spivy + 2), spivx, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy + 1), spivx) = "~"
                    spiy = spiy + 16: spivy = spivy + 1
                    GOSUB clr
                    PUT (spix, spiy), Feld04()
                    PUT (spix, spiy + 16), Feld12()
                    MID$(Spiel$(level, spivy + 1), spivx, 1) = "K"
                    SOUND 37, .5
                END IF
            END IF
        END IF
        IF MID$(Spiel$(level, spivy + 1), spivx, 1) = "B" THEN
            IF spivy < 10 THEN
                IF MID$(Spiel$(level, spivy + 2), spivx, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy + 1), spivx) = "~"
                    spiy = spiy + 16: spivy = spivy + 1
                    GOSUB clr
                    PUT (spix, spiy), Feld04()
                    PUT (spix, spiy + 16), Feld06()
                    MID$(Spiel$(level, spivy + 1), spivx, 1) = "E"
                    SOUND 37, .5
                END IF
            END IF
        END IF
    END IF
END IF
IF x$ = "8" THEN
    IF spivy > 1 THEN
        IF MID$(Spiel$(level, spivy - 1), spivx, 1) = "~" THEN
            MID$(Spiel$(level, spivy), spivx, 1) = "~"
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivy = spivy - 1: spiy = spiy - 16
            PUT (spix, spiy), Feld04()
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy - 1), spivx, 1) = "C" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivy = spivy - 1: spiy = spiy - 16
            GOSUB clr
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Bomben = Bomben + 1: Punkte = Punkte + 1: Zeit = Zeit - 1: RedrawTimeBar Zeit, afb, ifb
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy - 1), spivx, 1) = "A" THEN
            Ghostsound
            LEBEN = LEBEN - 1: IF LEBEN < 0 THEN GOTO Gameend
            GOTO Spiel2
        END IF
        IF MID$(Spiel$(level, spivy - 1), spivx, 1) = "J" THEN
            GOSUB Fuel
            LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
            spivy = spivy - 1: spiy = spiy - 16
            GOSUB clr
            PUT (spix, spiy), Feld04()
            Bombsound 1
            Punkte = Punkte + 3
            LEBEN = LEBEN + .2
            GOSUB sceen
            GOTO Spiel3
        END IF
        IF MID$(Spiel$(level, spivy - 1), spivx, 1) = "K" THEN
            IF spivy > 2 THEN
                IF MID$(Spiel$(level, spivy - 2), spivx, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy - 1), spivx) = "~"
                    spiy = spiy - 16: spivy = spivy - 1
                    GOSUB clr
                    PUT (spix, spiy), Feld04()
                    PUT (spix, spiy - 16), Feld12()
                    MID$(Spiel$(level, spivy - 1), spivx, 1) = "K"
                    SOUND 37, .5
                END IF
            END IF
        END IF
        IF MID$(Spiel$(level, spivy - 1), spivx, 1) = "B" THEN
            IF spivy > 2 THEN
                IF MID$(Spiel$(level, spivy - 2), spivx, 1) = "~" THEN
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy), spivx) = "~"
                    LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
                    MID$(Spiel$(level, spivy - 1), spivx) = "~"
                    spiy = spiy - 16: spivy = spivy - 1
                    GOSUB clr
                    PUT (spix, spiy), Feld04()
                    PUT (spix, spiy - 16), Feld06()
                    MID$(Spiel$(level, spivy - 1), spivx, 1) = "E"
                    SOUND 37, .5
                END IF
            END IF
        END IF
    END IF
END IF
GOTO Spiel3

x$ = INPUT$(1)
END

Editor:
Loda = 0: Wada = 0: level = 1
IF leveltest = 1 THEN leveltest = 0: level = savelevel
Editor2:
LOCATE 24, 30: PRINT "Level:"; level;
LINE (0, 0)-(289, 177), afb, B
edx = 1: edy = 1: Symbol = 1: edvx = 1: edvy = 1: Zed$ = "ABCDEFGHIJK~ "
Loda = 0: Wada = 0
FOR edvy = 1 TO 11
    FOR edvx = 1 TO 18
        edy = edvy * 16 - 15
        edx = edvx * 16 - 15
        LINE (edx, edy)-(edx + 15, edy + 15), 0, BF
        GOSUB Setzsymb
    NEXT
NEXT: edy = 1: edx = 1: edvy = 1: edvx = 1: GOSUB Setzsymb
Edit1:
KEY 5, CHR$(5)
LINE (edx, edy)-(edx + 15, edy + 15), 0, BF
LINE (edx, edy)-(edx + 15, edy + 15), ifb, B
LINE (edx, edy)-(edx + 15, edy + 15), 0, BF
GOSUB Setzsymb
x$ = GETKEY$
IF Newl = 1 THEN Newl = 0: GOTO Editor2
x$ = UCASE$(x$)
IF x$ = "8" THEN: IF edy > 1 THEN edy = edy - 16: edvy = edvy - 1
IF x$ = "6" THEN IF edx < 272 THEN edx = edx + 16: edvx = edvx + 1
IF x$ = "2" THEN IF edy < 156 THEN edy = edy + 16: edvy = edvy + 1
IF x$ = "4" THEN IF edx > 1 THEN edx = edx - 16: edvx = edvx - 1
IF x$ = CHR$(5) THEN savelevel = level: leveltest = 1: GOTO spiel1
IF x$ = CHR$(1) OR x$ = CHR$(2) OR x$ = CHR$(3) THEN GOTO Edit2
IF x$ = " " THEN x$ = "~"
IF INSTR(Zed$, x$) > 0 AND INSTR(Zed$, x$) < 14 THEN MID$(Editor$(level, edvy), edvx, 1) = x$
GOTO Edit1
Setzsymb:
SpezSymb$ = MID$(Editor$(level, edvy), edvx, 1)
SpezSymb$ = UCASE$(SpezSymb$)
IF SpezSymb$ = " " THEN SpezSymb$ = "~"
IF SpezSymb$ = "A" THEN PUT (edx, edy), Feld01()
IF SpezSymb$ = "B" THEN PUT (edx, edy), Feld02()
IF SpezSymb$ = "C" THEN PUT (edx, edy), Feld03()
IF SpezSymb$ = "D" THEN
    IF Loda = 1 THEN MID$(Editor$(level, lovy), lovx, 1) = "~": LINE (lox, loy)-(lox + 15, loy + 15), 0, BF
    lox = edx: lovx = edvx
    loy = edy: lovy = edvy
    Loda = 1
    PUT (edx, edy), Feld04()
    MID$(Editor$(level, edvy), edvx, 1) = "D"
END IF
IF SpezSymb$ = "E" THEN PUT (edx, edy), Feld06()
IF SpezSymb$ = "F" THEN PUT (edx, edy), Feld07()
IF SpezSymb$ = "G" THEN PUT (edx, edy), Feld08()
IF SpezSymb$ = "H" THEN PUT (edx, edy), Feld09()
IF SpezSymb$ = "I" THEN
    IF Wada = 1 THEN MID$(Editor$(level, wavy), wavx, 1) = "~": LINE (wax, way)-(wax + 15, way + 15), 0, BF
    wax = edx: wavx = edvx
    way = edy: wavy = edvy
    Wada = 1
    PUT (edx, edy), Feld10()
    MID$(Editor$(level, wavy), wavx, 1) = "I"
END IF
IF SpezSymb$ = "J" THEN PUT (edx, edy), Feld11()
IF SpezSymb$ = "K" THEN PUT (edx, edy), Feld12()
IF SpezSymb$ = "~" THEN
    LINE (edx, edy)-(edx + 15, edy + 15), 0, BF
END IF
RETURN
Edit2:
IF x$ = CHR$(1) THEN
    sea = 0
    FOR search = 1 TO 11
        sea = sea + INSTR(Editor$(level, search), "D")
    NEXT search
    IF sea = 0 THEN SOUND 2000, 1: SOUND 1000, 1: SOUND 100, 1: GOTO Edit1
    LOCATE 23, 1: LINE INPUT "Level ", Lsg$
    LOCATE 23, 1: PRINT "                            ";
    lsgs = VAL(Lsg$)
    IF lsgs > 50 OR lsgs < 1 THEN SOUND 1000, 1: GOTO Editor2
    IF lsgs < 51 AND lsgs > 0 THEN level = lsgs
    GOTO Editor2
END IF
IF x$ = CHR$(3) THEN
    OPEN "Levels2.trf" FOR OUTPUT AS #1
    FOR OutLevels = 1 TO 50
        FOR OutZeilen = 1 TO 11
            WRITE #1, MID$(Editor$(OutLevels, OutZeilen), 1, 18)
        NEXT OutZeilen
    NEXT OutLevels
    CLOSE #1
    CLS
    GOTO Newloc
END IF
GOTO Edit1


Setzgamesymb:
SpezSymb$ = MID$(Spiel$(level, Outlev1), Outlev2, 1)
SpezSymb$ = UCASE$(SpezSymb$)
IF SpezSymb$ = " " THEN SpezSymb$ = "~"
IF SpezSymb$ = "A" THEN PUT (edx, edy), Feld01()
IF SpezSymb$ = "B" THEN PUT (edx, edy), Feld02()
IF SpezSymb$ = "C" THEN PUT (edx, edy), Feld03()
IF SpezSymb$ = "D" THEN
    IF Loda = 1 THEN MID$(Editor$(level, lovy), lovx, 1) = "~": LINE (lox, loy)-(lox + 15, loy + 15), 0, BF
    lox = edx: lovx = edvx: spivx = Outlev2: spix = edx
    loy = edy: lovy = edvy: spivy = Outlev1: spiy = edy
    Loda = 1
    PUT (edx, edy), Feld04()
    MID$(Editor$(level, Outlev1), Outlev2, 1) = "D"
END IF
IF SpezSymb$ = "E" THEN PUT (edx, edy), Feld06()
IF SpezSymb$ = "F" THEN PUT (edx, edy), Feld07()
IF SpezSymb$ = "G" THEN PUT (edx, edy), Feld08(): Pflanz = Pflanz + 1
IF SpezSymb$ = "H" THEN PUT (edx, edy), Feld09()
IF SpezSymb$ = "I" THEN
    IF Wada = 1 THEN MID$(Editor$(level, wavy), wavx, 1) = "~": LINE (wax, way)-(wax + 15, way + 15), 0, BF
    wax = edx: wavx = Outlev2
    way = edy: wavy = Outlev1
    Wada = 1
    PUT (edx, edy), Feld10()
    MID$(Editor$(level, wavy), wavx, 1) = "I"
END IF
IF SpezSymb$ = "J" THEN PUT (edx, edy), Feld11()
IF SpezSymb$ = "K" THEN PUT (edx, edy), Feld12()
IF SpezSymb$ = "~" THEN
    LINE (edx, edy)-(edx + 15, edy + 15), 0, BF
END IF
RETURN

Fuel:
MID$(Spiel$(level, spivy), spivx, 1) = "~"
RETURN

sceen:
IF Modus = 7 THEN COLOR 13, 0
LOCATE 24, 1: PRINT " Leben :"; LEBEN;
IF Modus = 7 THEN COLOR 14, 0
LOCATE 25, 1: PRINT " Level :"; level;
IF Modus = 7 THEN COLOR 14, 0
LOCATE 24, 12: PRINT "Bomben :"; Bomben;
IF Modus = 7 THEN COLOR 12, 0
LOCATE 24, 27: PRINT "Zeit :"; INT(177 - Zeit);
IF Modus = 7 THEN COLOR 12, 0
LOCATE 25, 12: PRINT "Punkte :"; Punkte;
RETURN

clr:
LINE (spix, spiy)-(spix + 15, spiy + 15), 0, BF
RETURN

Gameend:
FOR gst = 1 TO 3: Ghostsound: NEXT gst
LINE (30, 70)-(260, 110), afb, BF
LINE (30, 70)-(260, 110), ifb, B
Vierletter 35, 100, ifb, "GAME-OVER"
Ok$ = INPUT$(1)
CLS
IF leveltest = 1 THEN GOTO Editor:
GOTO Newloc













Legbombe:
IF Bomben = 0 THEN GOTO Spiel3
DO
    Bo$ = GETKEY$
    Zeit = TIMER - Time1
    PSET (296, Zeit + 1), 0: DRAW "r8"
    LOCATE 24, 27: PRINT "Zeit :"; INT(177 - Zeit);
    LINE (295, 0)-(305, 177), afb, B
    IF INT(177 - Zeit) = 0 THEN
        Ghostsound
        LEBEN = LEBEN - 1
        IF LEBEN < 0 THEN GOTO Gameend
        GOTO Spiel2
    END IF
LOOP UNTIL Bo$ <> ""
IF Bo$ = CHR$(27) THEN GOTO Spiel3
IF Bo$ = "8" THEN
    IF spivy > 1 THEN
        Bomben = Bomben - 1: Zeit = Zeit - 4: RedrawTimeBar Zeit, afb, ifb
        GET (spix, spiy - 16)-(spix + 15, spiy - 1), Bombret()
        LINE (spix, spiy - 16)-(spix + 15, spiy - 1), 0, BF
        FOR t = 1 TO 50
            PUT (spix, spiy - 16), Feld05()
            _DELAY BombFrameDelay!
            PUT (spix, spiy - 16), Bombret()
            _DELAY BombFrameDelay!
            SOUND RND * 200 + 37, .1
        NEXT
        PUT (spix, spiy - 16), Bombret()
        IF MID$(Spiel$(level, spivy - 1), spivx, 1) = "E" THEN MID$(Spiel$(level, spivy - 1), spivx, 1) = "~": LINE (spix, spiy - 16)-(spix + 15, spiy - 1), 0, BF
    END IF
END IF
IF Bo$ = "6" THEN
    IF spivx < 18 THEN
        Bomben = Bomben - 1: Zeit = Zeit - 4: RedrawTimeBar Zeit, afb, ifb
        GET (spix + 16, spiy)-(spix + 31, spiy + 15), Bombret()
        LINE (spix + 16, spiy)-(spix + 31, spiy + 15), 0, BF
        FOR t = 1 TO 50
            PUT (spix + 16, spiy), Feld05()
            _DELAY BombFrameDelay!
            PUT (spix + 16, spiy), Bombret()
            _DELAY BombFrameDelay!
            SOUND RND * 200 + 37, .1
        NEXT
        PUT (spix + 16, spiy), Bombret()
        IF MID$(Spiel$(level, spivy), spivx + 1, 1) = "E" THEN MID$(Spiel$(level, spivy), spivx + 1, 1) = "~": LINE (spix + 16, spiy)-(spix + 31, spiy + 15), 0, BF
    END IF
END IF
IF Bo$ = "2" THEN
    IF spivy < 11 THEN
        Bomben = Bomben - 1: Zeit = Zeit - 4: RedrawTimeBar Zeit, afb, ifb
        GET (spix, spiy + 16)-(spix + 15, spiy + 31), Bombret()
        LINE (spix, spiy + 16)-(spix + 15, spiy + 31), 0, BF
        FOR t = 1 TO 50
            PUT (spix, spiy + 16), Feld05()
            _DELAY BombFrameDelay!
            PUT (spix, spiy + 16), Bombret()
            _DELAY BombFrameDelay!
            SOUND RND * 200 + 37, .1
        NEXT
        PUT (spix, spiy + 16), Bombret()
        IF MID$(Spiel$(level, spivy + 1), spivx, 1) = "E" THEN MID$(Spiel$(level, spivy + 1), spivx, 1) = "~": LINE (spix, spiy + 16)-(spix + 15, spiy + 31), 0, BF
    END IF
END IF
IF Bo$ = "4" THEN
    IF spivx > 1 THEN
        Bomben = Bomben - 1: Zeit = Zeit - 4: RedrawTimeBar Zeit, afb, ifb
        GET (spix - 16, spiy)-(spix - 1, spiy + 15), Bombret()
        FOR t = 1 TO 50
            PUT (spix - 16, spiy), Feld05()
            _DELAY BombFrameDelay!
            PUT (spix - 16, spiy), Bombret()
            _DELAY BombFrameDelay!
            SOUND RND * 200 + 37, .1
        NEXT
        PUT (spix - 16, spiy), Bombret()
        IF MID$(Spiel$(level, spivy), spivx - 1, 1) = "E" THEN MID$(Spiel$(level, spivy), spivx - 1, 1) = "~": LINE (spix - 16, spiy)-(spix - 1, spiy + 15), 0, BF
    END IF
END IF



GOSUB sceen
GOTO Spiel3

Waterfill:
GeistDa = 0
BlumeDa = 0
IchDa = 1
lose$ = "ACDGI~"
fest$ = "BEFHJK"
FOR ycre = 1 TO 11
    FOR xcre = 1 TO 18
        pct$ = MID$(Spiel$(level, ycre), xcre, 1)
        pct$ = UCASE$(pct$)
        IF INSTR(lose$, pct$) > 0 THEN
            PSET (xcre + 296, ycre + 179), ifb
            IF pct$ = "I" THEN hanx = xcre: hany = ycre
            IF pct$ = "G" THEN BlumeDa = BlumeDa + 1
            IF pct$ = "A" THEN GeistDa = GeistDa + 1
        END IF
        IF INSTR(fest$, pct$) > 0 THEN
            PSET (xcre + 296, ycre + 179), afb
        END IF
    NEXT xcre
NEXT ycre
IF Modus = 1 THEN bfb = 0
IF Modus = 7 THEN bfb = 9
PSET (hanx + 296, hany + 179), BF
PAINT (hanx + 296, hany + 179), bfb, afb
GeistEg = GeistDa
FOR ycn = 1 TO 11
    FOR xcn = 1 TO 18
        REM _DELAY (20)
        IF POINT(xcn + 296, ycn + 179) = bfb THEN
            aktz$ = MID$(Spiel$(level, ycn), xcn, 1)
            IF aktz$ = "G" THEN BlumeDa = BlumeDa - 1
            IF aktz$ = "A" THEN GeistEg = GeistEg - 1
            IF aktz$ = "D" THEN IchDa = 0
            LINE (xcn * 16 - 15, ycn * 16 - 15)-(xcn * 16, ycn * 16), 0, BF
            PUT (xcn * 16 - 15, ycn * 16 - 15), Feld13()
        END IF
    NEXT xcn
NEXT ycn
x$ = INPUT$(1)
LINE (296, 179)-(315, 191), 0, BF
LOCATE 25, 1: PRINT STRING$(40, 32);
Punkte = Punkte + INT(177 - (Zeit / 2))
IF BlumeDa = 0 THEN
    IF IchDa = 1 THEN
        IF GeistEg = GeistDa THEN
            level = level + 1: Bombsound 3: GOTO Spiel2
        END IF
    END IF
END IF
LEBEN = LEBEN - 1: GOTO Spiel2
CLS: GOTO Newloc

wingame:
Bombsound 13
LINE (30, 70)-(260, 110), afb, BF
LINE (30, 70)-(260, 110), ifb, B
Vierletter 35, 100, ifb, "Gewonnen"
Ok$ = INPUT$(1)
CLS
IF leveltest = 1 THEN GOTO Editor:
GOTO Newloc

SUB Bombsound (wiederholung)
    FOR whol = 1 TO wiederholung
        FOR so = 100 TO 1000 STEP 200: SOUND so, .1: NEXT so
    NEXT whol
END SUB

SUB Clearboard
    DO
        CLEARBOARDVAR$ = INKEY$
    LOOP UNTIL CLEARBOARDVAR$ = "" AND CLEARBOARDVAR$ <> CHR$(13)
END SUB

FUNCTION GETKEY$
    GETKEY1:
    Keyw = 0
    key$ = INKEY$
    IF (LEN(key$) = 2) THEN Keyw = ASC(RIGHT$(key$, 1))
    IF Keyw = 71 THEN Upslmx$ = "7"
    IF Keyw = 72 THEN Upslmx$ = "8"
    IF Keyw = 73 THEN Upslmx$ = "9"
    IF Keyw = 75 THEN Upslmx$ = "4"
    IF Keyw = 77 THEN Upslmx$ = "6"
    IF Keyw = 79 THEN Upslmx$ = "1"
    IF Keyw = 80 THEN Upslmx$ = "2"
    IF Keyw = 81 THEN Upslmx$ = "3"
    IF Keyw = 82 THEN Upslmx$ = "0"
    IF Keyw = 83 THEN Upslmx$ = "."
    GETKEYEND:
    IF Keyw = 0 THEN Upslmx$ = key$
    GETKEY$ = Upslmx$
END FUNCTION

SUB Ghostsound
    FOR ts = 300 TO 37 STEP -5: SOUND ts, .1: NEXT
END SUB

SUB Vierletter (LETTERX, LETTERY, ZCHNFARBE, ZCHNKETTE$)
    ZCHNKETTE$ = UCASE$(ZCHNKETTE$)
    VERLEGX = LETTERX: VERLEGY = LETTERY
    LMI$ = "A4B4C4D4E4F4G4H4I4K4"
    LA$ = "D7E7F7G7C6D6G6H6B5C5H5I5A4B4I4K4A3B3C3D3E3F3G3H3I3K3A2B2I2K2A1B1I1K1"
    LE$ = "A7B7C7D7E7F7G7H7I7K7A6B6A5B5A4B4C4D4E4F4G4H4A3B3A2B2A1B1C1D1E1F1G1H1I1K1"
    LG$ = "B7C7D7E7F7G7H7I7A6B6A5B5A4B4E4F4G4H4I4K4A3B3I3K3A2B2I2K2B1C1D1E1F1G1H1I1"
    LM$ = "A7B7I7K7A6B6C6D6G6H6I6K6A5B5D5E5F5G5I5K5A4B4E4F4I4K4A3B3I3K3A2B2I2K2A1B1I1K1"
    LN$ = "A7B7I7K7A6B6C6D6I6K6A5B5D5E5I5K5A4B4E4F4I4K4A3B3F3G3I3K3A2B2G2H2I2K2A1B1I1K1"
    LO$ = "B7C7D7E7F7G7H7I7A6B6I6K6A5B5I5K5A4B4I4K4A3B3I3K3A2B2I2K2B1C1D1E1F1G1H1I1"
    LR$ = "A7B7C7D7E7F7G7H7A6B6I6K6A5B5I5K5A4B4C4D4E4F4G4H4A3B3E3F3A2B2F2G2A1B1H1I1"
    LV$ = "B7C7H7I7B6C6H6I6B5C5H5I5B4C4H4I4C3D3G3H3D2E2F2G2E1F1"
    LW$ = "A7B7I7K7A6B6I6K6A5B5E5F5I5K5A4B4E4F4I4K4A3B3D3E3F3G3I3K3A2B2C2D2G2H2I2K2B1C1H1I1"
    FOR WIEDERHOLUNG1 = 1 TO LEN(ZCHNKETTE$)
        SCHNITT1$ = MID$(ZCHNKETTE$, WIEDERHOLUNG1, 1)
        ASA$ = SCHNITT1$
        IF ASA$ = "-" THEN S2$ = LMI$
        IF ASA$ = "A" THEN S2$ = LA$
        IF ASA$ = "E" THEN S2$ = LE$
        IF ASA$ = "G" THEN S2$ = LG$
        IF ASA$ = "M" THEN S2$ = LM$
        IF ASA$ = "N" THEN S2$ = LN$
        IF ASA$ = "O" THEN S2$ = LO$
        IF ASA$ = "R" THEN S2$ = LR$
        IF ASA$ = "V" THEN S2$ = LV$
        IF ASA$ = "W" THEN S2$ = LW$
        FOR WIEDERHOLUNG2 = 1 TO LEN(S2$) STEP 2
            S3$ = MID$(S2$, WIEDERHOLUNG2, 2)
            SA3$ = MID$(S3$, 1, 1)
            SB3$ = MID$(S3$, 2, 1)
            LEIHX = LETTERX
            LEIHY = LETTERY
            IF SA3$ = "A" THEN LEIHX = LEIHX + 0
            IF SA3$ = "B" THEN LEIHX = LEIHX + 2
            IF SA3$ = "C" THEN LEIHX = LEIHX + 4
            IF SA3$ = "D" THEN LEIHX = LEIHX + 6
            IF SA3$ = "E" THEN LEIHX = LEIHX + 8
            IF SA3$ = "F" THEN LEIHX = LEIHX + 10
            IF SA3$ = "G" THEN LEIHX = LEIHX + 12
            IF SA3$ = "H" THEN LEIHX = LEIHX + 14
            IF SA3$ = "I" THEN LEIHX = LEIHX + 16
            IF SA3$ = "K" THEN LEIHX = LEIHX + 18
            IF SB3$ = "1" THEN LEIHY = LEIHY - 0
            IF SB3$ = "2" THEN LEIHY = LEIHY - 3
            IF SB3$ = "3" THEN LEIHY = LEIHY - 6
            IF SB3$ = "4" THEN LEIHY = LEIHY - 9
            IF SB3$ = "5" THEN LEIHY = LEIHY - 12
            IF SB3$ = "6" THEN LEIHY = LEIHY - 15
            IF SB3$ = "7" THEN LEIHY = LEIHY - 18
            PSET (LEIHX, LEIHY), ZCHNFARBE: DRAW "U2;R1;D2"
            HELLHJK1:
            LEIHX = LETTERX: LEIHY = LETTERY
    NEXT WIEDERHOLUNG2: LETTERX = LETTERX + 25: NEXT WIEDERHOLUNG1
    LETTERX = VERLEGX: LETTERY = VERLEGY
END SUB


SUB RedrawTimeBar (Zeit, afb, ifb)
    ' Clears and redraws the time bar to avoid artifacts when Zeit decreases
    LINE (297, 1)-(304, 176), ifb, BF
    z = INT(Zeit)
    IF z < 0 THEN z = 0
    IF z > 175 THEN z = 175
    FOR yy = 1 TO z + 1
        PSET (297, yy), 0: DRAW "r7"
    NEXT yy
    LINE (296, 0)-(305, 177), afb, B
END SUB

