DECLARE SUB BmpLoad () DECLARE SUB MonsterEncounter () RANDOMIZE TIMER SCREEN 7, 0, 1, 0 '' BmpLoad PCOPY 1, 0 DO WHILE INKEY$ = "": LOOP '' DATA 15,15,15,15,15,15,15,15,15 DATA 15,07,07,07,07,07,07,07,08 DATA 15,07,07,07,07,07,07,07,08 DATA 15,07,07,07,07,07,07,07,08 DATA 15,07,07,07,07,07,07,07,08 DATA 15,07,07,07,07,07,07,07,08 DATA 15,07,07,07,07,07,07,07,08 DATA 15,07,07,07,07,07,07,07,08 DATA 15,07,07,07,07,07,07,07,08 DATA 15,08,08,08,08,08,08,08,08 DATA 00,00,00,01,01,00,00,00,00 DATA 00,00,01,01,01,01,00,00,00 DATA 00,00,14,14,00,14,00,00,00 DATA 00,00,14,14,14,14,00,00,00 DATA 00,01,01,01,01,01,01,00,00 DATA 01,00,01,01,01,01,00,01,00 DATA 01,00,01,01,01,01,00,01,00 DATA 00,00,01,01,01,01,00,00,00 DATA 00,01,01,00,00,01,01,00,00 DATA 00,06,06,00,00,06,06,00,00 DATA 00,00,00,10,10,00,00,00,00 DATA 00,00,10,10,10,10,00,00,00 DATA 00,10,10,10,10,10,10,00,00 DATA 00,10,10,10,10,10,10,00,00 DATA 00,10,02,10,10,02,10,00,00 DATA 00,10,10,02,02,10,10,00,00 DATA 00,10,10,10,10,02,10,00,00 DATA 00,00,10,10,10,10,00,00,00 DATA 00,00,00,02,00,00,00,00,00 DATA 00,00,00,02,02,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DATA 00,00,00,00,00,00,00,00,00 DIM wall(100), archer(100), monster(100) FOR y = 1 TO 10 FOR x = 1 TO 9 READ Z PSET (x, y), Z NEXT NEXT GET (0, 0)-(9, 10), wall FOR y = 1 TO 10 FOR x = 1 TO 9 READ Z PSET (x, y), Z NEXT NEXT GET (0, 0)-(9, 10), archer FOR y = 1 TO 10 FOR x = 1 TO 9 READ Z PSET (x, y), Z NEXT NEXT GET (0, 0)-(9, 10), monster DIM board$(15, 32) board$(y, x) = "a" oldx = 2 oldy = 2 hp = 30 drawmap: IF monston = 1 THEN monston = 0 CLOSE OPEN "mapfile" + board$(y, x) + ".dat" FOR INPUT AS 1 FOR y = 1 TO 15 LINE INPUT #1, lin$ FOR x = 1 TO 32 board$(y, x) = STRING$(1, lin$) lin$ = MID$(lin$, 2) NEXT NEXT CLS FOR y = 1 TO 15 FOR x = 1 TO 32 SELECT CASE board$(y, x) CASE "x" PUT (x * 10 - 10, y * 10 - 10), wall CASE "1" PSET (x * 10 - 5, y * 10 - 5), 10 CASE "2" PSET (x * 10 - 5, y * 10 - 5), 10 CASE "3" PSET (x * 10 - 5, y * 10 - 5), 9 CASE "4" PSET (x * 10 - 5, y * 10 - 5), 15 CASE "5" PSET (x * 10 - 5, y * 10 - 5), 14 CASE "6" PSET (x * 10 - 5, y * 10 - 5), 13 CASE "7" PSET (x * 10 - 5, y * 10 - 5), 12 CASE "8" PSET (x * 10 - 5, y * 10 - 5), 11 CASE "9" PSET (x * 10 - 5, y * 10 - 5), 10 CASE "." END SELECT NEXT NEXT PCOPY 1, 2 x = oldx y = oldy gameloop: IF ASC(board$(y, x)) >= 65 AND ASC(board$(y, x)) <= 90 THEN IF monston <> 1 THEN IF s$ = "8" THEN oldy = 14: oldx = x IF s$ = "6" THEN oldy = y: oldx = 2 IF s$ = "2" THEN oldy = 2: oldx = x IF s$ = "4" THEN oldy = y: oldx = 31 ELSE oldstatus$ = status$ status$ = "You can't leave with a monster here!" IF s$ = "8" THEN y = y + 1 IF s$ = "6" THEN x = x - 1 IF s$ = "2" THEN y = y - 1 IF s$ = "4" THEN x = x + 1 GOTO s END IF GOTO drawmap END IF IF monston = 0 THEN IF INT(RND * 20) = 1 THEN monston = 1: mhp = INT(RND * 5) + 5 mdo: mx = INT(RND * 29) + 2 my = INT(RND * 12) + 2 IF board$(my, mx) = "x" THEN GOTO mdo IF mx = x AND my = y THEN GOTO mdo END IF END IF PCOPY 2, 1 IF board$(y, x) = "1" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 100: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "2" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 200: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "3" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 300: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "4" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 400: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "5" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 500: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "6" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 600: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "7" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 700: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "8" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 800: board$(y, x) = ".": PCOPY 1, 0 IF board$(y, x) = "9" THEN oldstatus$ = status$: status$ = "You found treasure!": score = score + 900: board$(y, x) = ".": PCOPY 1, 0 LOCATE 20, 1 PRINT "X:"; x; "Y:"; y; "Score:"; score; "Level: "; score \ 1000; "HP:"; hp LOCATE 21, 1 IF oldstatus$ <> status$ THEN COLOR 12 PRINT status$ COLOR 15 LOCATE 22, 1 PRINT mstatus$; PUT (x * 10 - 10, y * 10 - 10), archer IF monston = 1 THEN PUT (mx * 10 - 10, my * 10 - 10), monster PCOPY 1, 0 s: s$ = "": DO WHILE s$ = "": s$ = INKEY$: IF monston = 1 THEN a = a + 1: IF a = 4000 THEN GOTO MonsterMove LOOP SELECT CASE s$ CASE "6" IF board$(y, x + 1) <> "x" THEN x = x + 1 CASE "4" IF board$(y, x - 1) <> "x" THEN x = x - 1 CASE "2" IF board$(y + 1, x) <> "x" THEN y = y + 1 CASE "8" IF board$(y - 1, x) <> "x" THEN y = y - 1 CASE "a" IF monston = 1 THEN good = 0 IF mx = x - 1 THEN good = good + 1 IF mx = x + 1 THEN good = good + 1 IF my = y - 1 THEN good = good + 1 IF my = y + 1 THEN good = good + 1 IF good > 0 THEN LOCATE 21, 1 oldstatus$ = status$: status$ = "You attack!": s = INT(RND * 2) + 1: FOR i = 1 TO 1000: NEXT PCOPY 1, 0 IF s = 1 THEN LOCATE 21, 13: oldstatus$ = status$: status$ = status$ + "... and hit!": oldstatus$ = status$ PCOPY 1, 0 mhp = mhp - INT(RND * 4) + 1 IF mhp <= 0 THEN monston = 0: score = score + 200: status$ = "You killed the monster!" FOR i = 1 TO 5000: NEXT ELSE LOCATE 21, 13: oldstatus$ = status$: status$ = status$ + "... and miss!" PCOPY 1, 0 FOR i = 1 TO 5000: NEXT END IF END IF END IF END SELECT GOTO gameloop MonsterMove: a = 0 IF mx - x < 0 THEN IF board$(my, mx + 1) <> "x" THEN cantmove = 1 mx = mx + 1 IF tryit = 1 THEN tryit = 0 GOTO gameloop 'IF tryit = 1 AND mx = oldmx THEN GOTO randommonstermove ELSE GOTO Monster2 END IF END IF Monster2: IF mx - x > 0 THEN IF board$(my, mx - 1) <> "x" THEN cantmove = 1 mx = mx - 1 IF tryit = 1 THEN tryit = 0 GOTO gameloop 'IF tryit = 1 AND mx = oldmx THEN GOTO randommonstermove ELSE GOTO Monster3 END IF END IF Monster3: IF my - y < 0 THEN IF board$(my + 1, mx) <> "x" THEN cantmove = 1 my = my + 1 IF tryit = 1 THEN tryit = 0 GOTO gameloop IF tryit = 1 AND my = oldmy THEN GOTO randommonstermove ELSE GOTO Monster4 END IF END IF Monster4: IF my - y > 0 THEN IF board$(my - 1, mx) <> "x" THEN cantmove = 1 my = my - 1 GOTO gameloop IF tryit = 1 AND my = oldmy THEN GOTO randommonstermove ELSE GOTO Monster5 END IF END IF Monster5: IF cantmove = 1 THEN cantmove = 0: GOTO randommonstermove good = 0 IF mx = x - 1 THEN good = good + 1 IF mx = x THEN good = good + 1 IF mx = x + 1 THEN good = good + 1 IF my = y THEN good = good + 1 IF my = y - 1 THEN good = good + 1 IF my = y + 1 THEN good = good + 1 IF good > 0 THEN LOCATE 21, 1 mstatus$ = "You are attacked!": s = INT(RND * 2) + 1: FOR i = 1 TO 1000: NEXT PCOPY 1, 0 IF s = 1 THEN LOCATE 21, 18: mstatus$ = mstatus$ + "... and are hit!" hp = hp - 2 LOCATE 20, 1 PRINT "X:"; x; "Y:"; y; "Score:"; score; "Level: "; score \ 1000; "HP:"; hp IF hp <= 0 THEN END FOR i = 1 TO 5000: NEXT ELSE LOCATE 21, 18: mstatus$ = mstatus$ + "... and dodge!" PCOPY 1, 0 FOR i = 1 TO 5000: NEXT END IF ELSE randommonstermove: s = INT(RND * 4) oldmx = mx oldmy = my SELECT CASE s CASE 1 IF board$(my + 1, mx) <> "x" THEN my = my + 1 CASE 2 IF board$(my - 1, mx) <> "x" THEN my = my - 1 CASE 3 IF board$(my, mx + 1) <> "x" THEN mx = mx + 1 CASE 4 IF board$(my, mx - 1) <> "x" THEN mx = mx - 1 END SELECT tryit = 1 GOTO gameloop END IF GOTO gameloop SUB BmpLoad DEFINT A-Z DIM byte AS STRING * 1 CLS data$ = "venture.bmp" IF LTRIM$(RTRIM$(data$)) = "" THEN END OPEN data$ FOR BINARY AS #1 IF LOF(1) = 0 THEN PRINT "File not found!": CLOSE : KILL data$: END table$ = INPUT$(54, #1) 'Get the file header (54 bytes) DIM table&(30) 'Create numerical array for header DEF SEG = VARSEG(table&(1)) pointer% = VARPTR(table&(1)) 'Poke the data from string "table$" into numerical array "table&" FOR x% = 0 TO 51 POKE pointer% + x%, ASC(MID$(table$, x% + 3, 1)) NEXT DEF SEG 'Check for valid file type IF MID$(table$, 1, 2) <> "BM" OR table&(4) <> 40 THEN PRINT "Not a valid *.BMP file!": END END IF IF table&(8) <> 0 THEN PRINT "This program will not diplay RLE encoded files": END END IF 'IF ASC(MID$(table$, 29, 1)) <> 4 THEN ' PRINT "Only 16 color bitmaps are supported!": END 'END IF 'Set the video mode for best picture fit IF (table&(5) < 321) AND (table&(6) < 201) THEN SCREEN 7 ELSE SCREEN 12 END IF LOCATE 2, 1 ' " Image is "; table&(5); " by "; table&(6) thecolors$ = INPUT$(table&(3) - 54, #1) 'Read in pallette info DEF SEG = VARSEG(pal&) pointer% = VARPTR(pal&) 'Poke the pallette info from the string "thecolors$" 'into pal& and reduce to 6 bits per byte. FOR x% = 0 TO 63 STEP 4 POKE pointer%, (ASC(MID$(thecolors$, x% + 3, 1))) \ 4 POKE pointer% + 1, (ASC(MID$(thecolors$, x% + 2, 1))) \ 4 POKE pointer% + 2, (ASC(MID$(thecolors$, x% + 1, 1))) \ 4 POKE pointer% + 3, 0 'PALETTE x% \ 4, pal& NEXT DEF SEG 'Read in Bitmap data and set pixels accordingly y% = table&(6) 'Put number of vertical pixels into y% DO data$ = INPUT$((((table&(5) - 1) OR 7) + 1) \ 2, #1) IF (table&(5) \ 2) < LEN(data$) THEN linelength% = table&(5) \ 2 ELSE linelength% = LEN(data$) END IF FOR x% = 1 TO linelength% pixel% = ASC(MID$(data$, x%, 1)) PSET (x% * 2 + 1, y%), pixel% AND 15 PSET (x% * 2, y%), pixel% \ 16 NEXT y% = y% - 1 LOOP UNTIL EOF(1) OR INKEY$ <> "" END SUB DEFSNG A-Z SUB MonsterEncounter END SUB