130 lines
2.4 KiB
Plaintext
130 lines
2.4 KiB
Plaintext
Rem *********************
|
|
Rem ** primo programma **
|
|
Rem ** conta insieme **
|
|
Rem *********************
|
|
|
|
Auto A$, badscore As Double, iterazioni As Double
|
|
Auto limit As Double, limit_2 As Double, res As Double
|
|
Auto resu As Double, ri As Int, riga As Double
|
|
Auto score As Double, se$, segno As Double, x As Double
|
|
Auto y As Double
|
|
|
|
Do
|
|
A$ = SPLASHSCREEN
|
|
|
|
Rem ******************
|
|
Rem ** Main Program **
|
|
Rem ******************
|
|
|
|
limit = 100
|
|
limit_2 = 20
|
|
iterazioni = 0
|
|
score = 0
|
|
badscore = 0
|
|
|
|
Locate 0, 15
|
|
Print "---------------------------------------"
|
|
Color 3
|
|
Locate 4, 15 : Print " "; A$; " "
|
|
|
|
Repeat
|
|
x = Rand(limit + 1)
|
|
y = Rand(limit_2 + 1)
|
|
If x < y
|
|
Swap x, y
|
|
End If
|
|
segno = Rand(2)
|
|
If segno = 1
|
|
se$ = " +"
|
|
resu = x + y
|
|
Else
|
|
se$ = " -"
|
|
resu = x - y
|
|
End If
|
|
|
|
riga = (iterazioni Mod 5) * 2 + 1
|
|
If riga = 1
|
|
Cancella
|
|
End If
|
|
Locate 0, riga
|
|
Rem Pen 2
|
|
Print " Quanto fa"; x; se$; y; " ";
|
|
Input res
|
|
|
|
If res = resu
|
|
Locate 25, riga : Print "OK!"
|
|
score = score + 1
|
|
SUONO_OK
|
|
PALLINA(score, 1)
|
|
Else
|
|
Locate 25, riga : Print "ERRORE!"; resu
|
|
badscore = badscore + 1
|
|
SUONO_ERROR
|
|
PALLINA(badscore, 0)
|
|
End If
|
|
|
|
iterazioni = iterazioni + 1
|
|
Until iterazioni > 39
|
|
|
|
Cls
|
|
Locate 0, 1
|
|
Print "Bravo "; A$; "!"
|
|
Print
|
|
Print "Hai eseguito "; score; " operazioni corrette"
|
|
Print " e "; badscore; " operazioni errate"
|
|
Print
|
|
Print "Ora tocca al prossimo giocatore!"
|
|
Rem EVNT_TIMER(1000)
|
|
|
|
Loop
|
|
|
|
Rem ***************************
|
|
Rem ** Procedure e funzioni **
|
|
Rem ***************************
|
|
|
|
Function SPLASHSCREEN
|
|
Cls
|
|
Locate 0, 1
|
|
Print " Conta Insieme"
|
|
Print " -------------"
|
|
|
|
Locate 1, 5
|
|
Input "Come ti chiami? ";A$
|
|
|
|
Locate 1, 8
|
|
Print "Ciao "; A$; ", partiamo!"
|
|
|
|
Cls
|
|
Return A$
|
|
End Function
|
|
|
|
Procedure SUONO_OK
|
|
End Proc
|
|
|
|
Procedure SUONO_ERROR
|
|
End Proc
|
|
|
|
Procedure PALLINA(ITERAZIONI, RISULTATO)
|
|
If RISULTATO = 1
|
|
Rem pallina buona
|
|
Locate ITERAZIONI - 1, 17
|
|
Rem Pen 5
|
|
Print "O"
|
|
Rem Pen 2
|
|
Else
|
|
Rem pallina cattiva
|
|
Locate ITERAZIONI - 1, 19
|
|
Rem Pen 4
|
|
Print "X"
|
|
Rem Pen 2
|
|
End If
|
|
End Proc
|
|
|
|
Procedure Cancella
|
|
'##E#
|
|
Locate 0, 0
|
|
For ri = 0 To 10
|
|
Print " "
|
|
Next ri
|
|
End Proc
|