Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program to learn German articles.
#6
The zip contains the following.

BAS FILE:
Code: (Select All)
Screen _NewImage(1920, 1080, 256)
_FullScreen , _Smooth
For i = 1 To 255
    _MapUnicode i To i
Next i
geluid = 1
begin:
Font& = _LoadFont("lucon.ttf", 28, "MONOSPACE")
Font1& = _LoadFont("lucon.ttf", 24, "MONOSPACE")
Font2& = _LoadFont("lucon.ttf", 84, "MONOSPACE")
tekstkleur& = _RGB(28, 0, 105)
tekstkleur1& = _RGB(144, 144, 128)

If Font& = 0 Then
    Print "No font!": Beep
    End
End If

Cls
_PaletteColor 0, _RGB32(216, 211, 205)
Color tekstkleur&
Dim regel As String
Dim regels(10000) As String
Dim totaalRegels As Long
Dim willekeurigIndex As Long
Dim woord As String
Dim geslacht As String
Dim kommaPositie As Long
Randomize Timer
Open "woorden.txt" For Input As #1
totaalRegels = 0
Do While Not EOF(1)
    Line Input #1, regel
    totaalRegels = totaalRegels + 1
    regels(totaalRegels) = regel
Loop
Close #1

If totaalRegels = 0 Then
    Print "No lines in file!": Beep
    End
End If

willekeurigIndex = Int(Rnd * totaalRegels) + 1
kommaPositie = InStr(regels(willekeurigIndex), ",")

If kommaPositie > 0 Then
    If kommaPositie > 1 Then
        woord = Left$(regels(willekeurigIndex), kommaPositie - 1)
    Else
        woord = regels(willekeurigIndex)
    End If
    geslacht = Mid$(regels(willekeurigIndex), kommaPositie + 1)
Else
    woord = regels(willekeurigIndex)
    geslacht = ""
End If

_Font Font1&
teller = teller + 1
Locate 2, 1
Print "  Score: "; score; "/"; teller
Locate 2, 126: Print "ESC = Quit";
Locate 2, 96: Print "(Switch with s) SOUND = ";
If geluid = 1 Then Print "ON" Else Print "OFF";

Line (10, 10)-(1910, 1070), _RGB(150, 150, 127), B
Line (14, 14)-(1906, 1066), _RGB(150, 150, 127), B
_Font Font2&
Color tekstkleur1&
tekstBreedte = _PrintWidth("[" + woord + "]")
xPositie = (1920 - tekstBreedte) \ 2
yPositie = 150
_PrintString (xPositie, yPositie), "[" + woord + "]"
_Font Font&
Color tekstkleur&
tekstBreedte = _PrintWidth("What article is correct?")
xPositie = (1920 - tekstBreedte) \ 2
yPositie = 340
_PrintString (xPositie, yPositie), "Which article is correct?"
verschuif = -130

If geslacht <> "" Then
    Color 4
    tekstBreedte = _PrintWidth("1. Der " + woord)
    xPositie = (1920 - tekstBreedte) \ 2
    yPositie = 600
    _PrintString (xPositie, yPositie + verschuif), "1. Der " + woord

    tekstBreedte = _PrintWidth("2. Die " + woord)
    xPositie = (1920 - tekstBreedte) \ 2
    yPositie = 650
    _PrintString (xPositie, yPositie + verschuif), "2. Die " + woord

    tekstBreedte = _PrintWidth("3. Das " + woord)
    xPositie = (1920 - tekstBreedte) \ 2
    yPositie = 700
    _PrintString (xPositie, yPositie + verschuif), "3. Das " + woord
End If

Do
    invoer$ = InKey$
    If invoer$ = "s" And geluid = 0 Then geluid = 1: _Font Font1&: Locate 2, 96: Color tekstkleur&: Print "(Switch with s) SOUND = ON ";: Sound 900, 1: GoTo 3
    If invoer$ = "s" And geluid = 1 Then geluid = 0: _Font Font1&: Locate 2, 96: Color tekstkleur&: Print "(Switch with s) SOUND = OFF";: Sound 300, 1: GoTo 3
    3
    If invoer$ = Chr$(27) Then System
    If invoer$ = "1" Or invoer$ = "2" Or invoer$ = "3" Then Exit Do
Loop

uitslag:
correct = 0
If invoer$ = "1" And geslacht = "der" Then correct = 1
If invoer$ = "2" And geslacht = "die" Then correct = 1
If invoer$ = "3" And geslacht = "das" Then correct = 1

If correct = 1 Then
    score = score + 1
    tekstBreedte = _PrintWidth("Correct! It's indeed '" + geslacht + " " + woord + "'.")
    xPositie = (1920 - tekstBreedte) \ 2
    yPositie = 750
    Color 2
    _PrintString (xPositie, yPositie), "Correct! It's indeed '" + geslacht + " " + woord + "'."
    If geluid = 1 Then Sound 300, 2: Sound 370, 2: Sound 440, 4: Sound 585, 4
Else
    tekstBreedte = _PrintWidth("Incorrect! The right answer was '" + geslacht + " " + woord + "'.")
    xPositie = (1920 - tekstBreedte) \ 2
    yPositie = 750
    Color 12
    _PrintString (xPositie, yPositie), "Incorrect! The right answer was '" + geslacht + " " + woord + "'."
    If geluid = 1 Then For i = 1 To 160: Sound 60 + i + Int(Rnd * 1000), .03: Next i
End If

tekstBreedte = _PrintWidth("Press any key to continue...")
xPositie = (1920 - tekstBreedte) \ 2
yPositie = 1000
Color 3
_PrintString (xPositie, yPositie), "Press any key to continue..."

Do
    A$ = InKey$
    If invoer$ = "s" And geluid = 0 Then geluid = 1: _Font Font1&: Locate 2, 96: Color tekstkleur&: Print "(Switch with s) SOUND = ON ";: Sound 900, 1: GoTo 4
    If invoer$ = "s" And geluid = 1 Then geluid = 0: _Font Font1&: Locate 2, 96: Color tekstkleur&: Print "(Switch with s) SOUND = OFF";: Sound 300, 1: GoTo 4
    4
    If A$ = Chr$(27) Then System
    If A$ <> "" Then GoTo begin
Loop

And the text file (which has German encoding in it):


.txt   woorden.txt (Size: 9.01 KB / Downloads: 29)
Reply


Messages In This Thread
RE: Program to learn German articles. - by JRace - 10-27-2024, 03:01 AM
RE: Program to learn German articles. - by SMcNeill - 10-26-2024, 05:52 PM
RE: Program to learn German articles. - by JRace - 10-28-2024, 01:16 AM



Users browsing this thread: 1 Guest(s)