mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2024-12-04 11:49:51 +00:00
81 lines
2.3 KiB
Plaintext
81 lines
2.3 KiB
Plaintext
|
100 REM DICE GAME
|
||
|
110 PR#0:DIM RW$(11)
|
||
|
120 FOR I=0 to 11:READ ST$:RW$(I)=ST$:NEXT
|
||
|
130 DATA "Fabulous!","Oh yeah!"
|
||
|
140 DATA "Impressive!","Sensational!"
|
||
|
150 DATA "You are a star!","Excellent!"
|
||
|
160 DATA "My hero!","Top student!"
|
||
|
170 DATA "Stunning!","What a brain!"
|
||
|
180 DATA "Terrific work!","Too easy for you!"
|
||
|
190 DIM SR$(9)
|
||
|
200 FOR I=0 to 9:READ ST$:SR$(I)=ST$:NEXT
|
||
|
210 DATA "Sorry,","Hmmm,","Not quite,"
|
||
|
220 DATA "Try again,","Keep at it,"
|
||
|
230 DATA "Careful,","Steady,"
|
||
|
240 DATA "Next time,","Stay calm,","D'oh,"
|
||
|
|
||
|
300 REM MAIN LOOP
|
||
|
310 SC=0:DG=0:SD=RND(-PEEK(78)-PEEK(79)*256)
|
||
|
320 HOME:GR:X=1:Y=9
|
||
|
330 IF SC=5 THEN HOME:SC=0
|
||
|
340 GOSUB 500:AN=RN:X=14
|
||
|
350 GOSUB 500:AN=AN+RN:X=27
|
||
|
360 GOSUB 500:AN=AN+RN
|
||
|
370 HOME:VTAB 21:HTAB 7
|
||
|
380 INPUT "Add the dice together = ";IN:VTAB 23
|
||
|
390 IF IN=AN THEN GOSUB 8000:HTAB HT:PRINT A$
|
||
|
400 IF IN<>AN THEN HTAB 17:GOSUB 9000:HTAB HT:PRINT A$
|
||
|
410 VTAB 24:HTAB 7
|
||
|
420 PRINT "Press any key to continue. ";
|
||
|
430 GET IN$:GOTO 320
|
||
|
|
||
|
500 REM DRAW DICE
|
||
|
510 C1=INT(RND(1)*15)+1:C2=INT(RND(1)*16)
|
||
|
520 IF C1=C2 THEN GOTO 510
|
||
|
530 IF C1=5 OR C1=10 THEN C1=15:C2=1
|
||
|
540 COLOR=C1:HLIN X+1,X+10 AT Y
|
||
|
550 FOR V=1 TO 20:HLIN X,X+11 AT Y+V:NEXT
|
||
|
560 HLIN X+1,X+10 AT Y+21:COLOR=C2
|
||
|
570 RN=INT(RND(1)*6)+1:DG=1-DG
|
||
|
580 ON RN GOSUB 1000,2000,3000,4000,5000,6000:RETURN
|
||
|
|
||
|
1000 REM ONE
|
||
|
1010 DX=X+5:DY=Y+9:GOSUB 7000:RETURN
|
||
|
|
||
|
2000 REM TWO
|
||
|
2010 IF DG THEN DX=X+3:DY=Y+5:GOSUB 7000:DX=X+7:DY=Y+12:GOSUB 7000
|
||
|
2020 IF NOT DG THEN DX=X+7:DY=Y+5:GOSUB 7000:DX=X+3:DY=Y+12:GOSUB 7000
|
||
|
2030 RETURN
|
||
|
|
||
|
3000 REM THREE
|
||
|
3010 IF DG THEN DX=X+2:DY=Y+4:GOSUB 7000:DX=X+8:DY=Y+14:GOSUB 7000
|
||
|
3020 IF NOT DG THEN DX=X+8:DY=Y+4:GOSUB 7000:DX=X+2:DY=Y+14:GOSUB 7000
|
||
|
3030 GOSUB 1000:RETURN
|
||
|
|
||
|
4000 REM FOUR
|
||
|
4010 DX=X+2:DY=Y+4:GOSUB 7000
|
||
|
4020 DX=X+8:DY=Y+4:GOSUB 7000
|
||
|
4030 DX=X+2:DY=Y+14:GOSUB 7000
|
||
|
4040 DX=X+8:DY=Y+14:GOSUB 7000
|
||
|
4050 RETURN
|
||
|
|
||
|
5000 REM FIVE
|
||
|
5010 GOSUB 4000:GOSUB 1000:RETURN
|
||
|
|
||
|
6000 REM SIX
|
||
|
6010 GOSUB 4000
|
||
|
6020 IF DG THEN DX=X+5:DY=Y+4:GOSUB 7000:DX=X+5:DY=Y+14:GOSUB 7000
|
||
|
6030 IF NOT DG THEN DX=X+2:DY=Y+9:GOSUB 7000:DX=X+8:DY=Y+9:GOSUB 7000
|
||
|
6040 RETURN
|
||
|
|
||
|
7000 REM DRAW SPOT
|
||
|
7010 FOR V=0 TO 3:HLIN DX,DX+1 AT DY+V:NEXT:RETURN
|
||
|
|
||
|
8000 REM GIVE REWARD
|
||
|
8010 SC=SC+1
|
||
|
8020 A$=RW$(RND(1)*10) + " " + STR$(SC) + "/5"
|
||
|
8030 HT=20-INT((LEN(A$)/2)):RETURN
|
||
|
|
||
|
9000 REM GIVE ENCOURAGEMENT
|
||
|
9010 A$=SR$(RND(1)*10) + " answer is " + STR$(AN)
|
||
|
9020 HT=19-INT((LEN(A$)/2)):RETURN
|