User Tools

Site Tools


ugbasic:user:example:contrib_valley
Translations of this page:


ugBASIC User Manual

PURPOSE

SOURCE CODE

 10 CLS 
 70 ST=RND(9)+RND(9)+RND(9):IQ=RND(9)+RND(9)+RND(9) 
 80 EN=RND(9)+RND(9)+RND(9):ST=ST*5:IQ=IQ*5:EN=EN*6 
 90 PRINT"1) WARRIOR":PRINT"2) CLERIC":PRINT"3) BARBARIAN" 
 100 PRINT"4) WIZARD":INPUT"WHICH ONE (1-4)";A 
 110 IFA<1ORA>4THENCL$="FOOL";IQ=IQ-RND(10) 
 120 IFA=1THENCL$="WARRIOR":ST=ST+RND(ST):IQ=IQ+RND(10) 
 130 IFA=2THENCL$="CLERIC":IQ=IQ+RND(10)*2 
 140 IFA=3THENCL$="BARBARIAN":IQ=IQ-RND(5):ST=ST+RND(ST) 
 150 IFA=3THENEN=EN+RND(ST) 
 160 IFA=4THENCL$="WIZARD":IQ=IQ+RND(15)*2:EN=EN+RND(5) 
 170 INPUT"NAME";NAME$ 
 180 IFNAME$=""THENNAME$="MR. 'X'"
 190 CLS 
 200 PRINTSTRING$(32,175);:FORN=0TO7:PRINTCHR$(175); 
 210 PRINTSTRING$(30,32);CHR$(175);:NEXT 
 220 PRINTSTRING$(32,175) 
 230 A$(1)=CHR$(175)+"#####################/\#######"+CHR$(175) 
 240 A$(2)=CHR$(175)+"#/\/\########/\/\##/## /\#####"+CHR$(175) 
 250 A$(3)=CHR$(175)+"p####\####/\/####\/######\/\/k"+CHR$(175) 
 260 A$(4)=CHR$(175)+"######\/\/"+STRING$(20,32)+CHR$(175) 
 270 J=RND(5)*32:PRINT@J,A$(1);:PRINTA$(2);:PRINTA$(3); 
 280 PRINTA$(4); 
 360 PRINT@352,NAME$;" THE ";CLASS$ 
 370 PRINT@384,"ST:";ST;TAB(10);"IQ:";IQ;TAB(20);"EN:"; 
 380 PRINTEN;:PRINT@416,"TR:";TR;TAB(20);"EX:";EX; 
 530 GOSUB 2300 
 2300 A$=INKEY$:IFA$=""THEN2300 
 2310 IFA$="R"THEND=-33 
 2320 IFA$="T"THEND=-32 
 2330 IFA$="Y"THEND=-31 
 2340 IFA$="F"THEND=-1 
 2350 IFA$="H"THEND=1 
 2360 IFA$="C"THEND=31 
 2370 IFA$="V"THEND=32 
 2380 IFA$="B"THEND=33 
 2450 RETURN 
 30 MAN=1056:Z=16 
 410 MAN=MAN+J+33 
 440 POKE MAN,36 
 560 IFPEEK(MAN+D)=111ORPEEK(MAN+D)=92THENMAN=MAN+D:POKE MAN-D,Z:PATH=1:Z=PEEK(MAN):GOTO660 
 570 IFPEEK(MANI+D)=11THENMAN=MAN+D:POKEMAN-D,Z:CASTLE=1:Z= PEEK(MAN):GOTO660 
 580 IFPEEK(MAN+D)=16THENMAN=MAN+D:POKEMAN-D,7:PL=1:Z=PEEK(MAN):GOTO660 
 650 IFPEEK(MAN+D)<>175THENMAN=MAN+D:POKEMAN-D,Z:Z=PEEK(MAN) 
 790 GOTO440 
 660 IFZ<>11THENCASTLE=0 
 670 IFZ<>16THENPL=0 
 680 IFZ<>92ANDZ<>111THENPATH=0 
 700 PRINT@320," " 
 710 IFPATH=1THENPRINT@320,"SAFE ON PATH" 
 720 IFCASTLE=1THENPRINT@320,"SAFE IN KEEP" 
 750 IFPL=1THENPRINT@320,"SAFE IN PALACE" 
 390 IF U=1 THEN RETURN 
 400 U=1 
 490 GOSUB 360 
 540 E=E+1:IFE=10THENEN=EN-1:E=0
 40 PL=1 
 500 IFRND(4)=2ANDDEAD=0ANDCASTLE=0ANDPATH=0ANDPL=0THENGOSUB2770 
 2770 SOUND100,5:SOUND100,6:RESTORE:IFEX<2000ANDTW=0THEN FORN=0TORND(19):READMONSTER$,HITS:NEXT 
 2780 M=0 
 2790 IFEX>=2000ORTW=1THENFORN=0TORND(19)+20:READMONSTER$,HITS:NEXT 
 2810 FORN=1TOLEN(MONSTER$):MID$(MONSTER$,N,1)=CHR$(ASC(MID$(MONSTER$,N,1))+32):IFMID$(MONSTER$,N,1)="@"THENMID$(MONSTER$,N,1)=CHR$(128):NEXT:MONSTER$;
 2820 PRINT@320,"YOU HAVE MET A ";MONSTER$; 
 2830 IFCLASS$="CLERIC"AND(MONSTER$="mummy"ORMONSTER$="wraith"ORMONSTER$="spectre")ANDRND(3)=2THENYZ=1 
 2840 IFYZ=1THENFORN=0TO2000:NEXT:PRINT@320,"BUT YOU TURN IT AWAY!":FORN=0TO2000:NEXT:PRINT@320," ":EX=EX+H:YZ=0:RETURN
 2850 HITS=HITS+RND(INT(HITS/2)):IFHITS<INT(EN/2)THEN2850 
 2860 H=HITS
 2870 FORN=0TO1000:NEXT
 2880 PRINT@448,"strike";CHR$(128);"now" 
 2890 SOUND50,2 
 2900 A$=INKEY$ 
 2910 PRINT@480,STRING$(28,32); 
 2920 PRINT@480,"THE MONSTER HAS";HITS;"ENERGY   "; 
 2930 FORN=0TO300:A$=INKEY$:IFA$<>""THEN2960:ELSENEXT:PRINT@448,"too";CHR$(128);"slow":FORN=0TO2000:NEXT:PRINT@448," ":GOTO2990
 2960 IFA$="H"ANDRND(2)=2THENG=RND(EN)+RND(ST)*SD:PRINT@448,"you";CHR$(128);"hit":FORN=0TO2000:NEXT:PRINT@448,G;"DAMAGE!";:FORN=0TO3000:NEXT:YZ=1
 2970 IFYZ=1THENYZ=0:PRINT@448," ":HITS=HITS-G:ELSEIFA$="H"THENPRINT@448,"you";CHR$(128);"missed":FORN=0TO2000:NEXT:PRINT@448,STRING$(30,32);:YZ=0
 2980 IFG>0THENSOUND150,2:G=0:ELSESOUND200,2 
 2990 PRINT@480,"THE MONSTER HAS";HITS;"ENERGY   "; 
 3000 IFHITS<=0THEN3110 
 3010 SOUND200,2:PRINT@448,"the";CHR$(128);"monster";CHR$(128);"strikes":FORN=0TO2000:NEXT:PRINT@448," " 
 3020 IFRND(2)=1THENM=RND(HITS):PRINT@448,"and";CHR$(128);"hits";:SOUND10,2:FORN=0TO2000:NEXT:ELSEPRINT@448,"and";CHR$(128);"misses";:SOUND50,2:YZ=1 
 3030 IFYZ=1THENFORN=0TO2000:NEXT:PRINT@448," ":YZ=0 
 3040 EN=EN-M 
 3050 IFM>0THENPRINT@448,"DOING";M;"DAMAGE!";:FORN=0TO2000:NEXT:PRINT@448," " 
 3060 GOSUB360 
 3070 M=0 
 3080 IFEN<=0THEN3770 
 3100 HITS=HITS-1:EN=EN-1:GOTO2880 
 3110 PRINT@448," ":PRINT@480,STRING$(31,32);:PRINT@320,"YOU'VE KILLED IT!":FORN=225TO250:SOUNDN,1:NEXT:EX=EX+H:EN=EN+RND(INT(H/2)) 
 3120 FORN=0TO2000:NEXT:PRINT@320," ":IFEN>400THENEN=EN-RND(INT(H/2)):RETURN:ELSERETURN 
 3200 DATA"BANDIT",20,"BERSERKER",20,"BUGBEAR",60,"CARRION CRAWLER",60,"COCKATRICE",100,"DWARF",20,"DOPPLEGANGER",80,"ELF",20,"FIRE BEETLE",20 
 3210 DATA"GARGOYLE",80,"GELATINUS CUBE",80,"GIANT ANT",40, "GIANT CENTIPEDE",5,"GIANT RAT",10,"GNOLL",40,"GNOME",10,"GOBLIN",10,"GREY OOZE",60 
 3220 DATA"HIPPOGRIFF",65,"HOBGOBLIN",15,"BLACK PUDDING",200,"CHIMERA",180,"DJINNI",145,"DRAGON",220,"GIANT",200,"GRIFFON",140,"HYDRA",160 
 3230 DATA"WEREBEAR",120,"MANTICORE",125,"MINOTAUR",120,"MUMMY",105,"OGRE",120,"OWL BEAR",110,"PURPLE WORM",300 
 3240 DATA"SPECTRE",120,"TROLL",130,"VAMPIRE",180,"WIGHT",60,"WRAITH",80,"HELL HOUND",140 
 3770 PRINT@320,"YOU'RE DEAD!":IFK=1THEN3770 
 3780 PLAY"O1V31T2L4GGL8GGL4B-AAGGF+G":K=1:GOTO3770

SOURCE FILE

HOW TO COMPILE AND RUN

ATARI 400/800 family

In order to compile and run the example, you need to have the Altirra emulator, and in particular that the altirra executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.atari contrib_valley.bas -o example.xex
 altirra example.xex
 
 # Windows 
 ugbc.atari.exe contrib_valley.bas -o example.xex
 altirra example.xex

ATARI 600XL/800XL/1200XL/XG(SE) family

In order to compile and run the example, you need to have the Altirra emulator, and in particular that the altirra executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.atarixl contrib_valley.bas -o example.xex
 altirra example.xex
 
 # Windows 
 ugbc.atarixl.exe contrib_valley.bas -o example.xex
 altirra example.xex

Commodore 64

In order to compile and run the example, you need to have the VICE emulator, and in particular that the x64sc executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.c64 contrib_valley.bas -o example.prg
 x64sc example.prg
 
 # Windows 
 ugbc.c64.exe contrib_valley.bas -o example.prg
 x64sc example.prg

Commodore PLUS/4

Using YAPE

In order to run the example, you need to have the YAPE emulator. In particular that the yape executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.plus4 contrib_valley.bas -o example.prg
 yape example.prg
 
 # Windows 
 ugbc.plus4.exe contrib_valley.bas -o example.prg
 yape example.prg
Using VICE

In order to run the example, you need to have the VICE emulator. In particular that the xplus4 executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.plus4 contrib_valley.bas -o example.prg
 xplus4 example.prg
 
 # Windows 
 ugbc.plus4.exe contrib_valley.bas -o example.prg
 xplus4 example.prg

Dragon 32

In order to compile and run the example, you need to have the XROAR emulator, and in particular that the xroar executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.d32 contrib_valley.bas -o example.bin
 xroar -rompath (your rom path) example.bin
 
 # Windows 
 ugbc.d32.exe contrib_valley.bas -o example.bin
 xroar.exe -rompath (your rom path) example.bin

ZX Spectrum

In order to compile and run the example, you need to have the Speccy emulator, and in particular that the speccy executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.zx contrib_valley.bas -o example.tap
 Speccy example.tap
 
 # Windows 
 ugbc.zx.exe contrib_valley.bas -o example.tap
 Speccy example.tap

ANY PROBLEM?

If you have found a problem trying to run this example, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub. Thank you!

POWERED BY