Buchempfehlung
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
"Der" Petzold, das über 1000 Seiten starke Standardwerk zum Win32-API - besonders nützlich u. a. bei der GUI-Programmierung in FreeBASIC! [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

Hangman Final (ohne verschlüsselung)q

Uploader:MitgliedThe_Muh
Datum/Zeit:04.08.2008 03:33:17

DIM mode as integer
dim key as string
dim leben as integer
dim wort as string
dim hit as integer
dim suchpos as integer
dim offen as string
dim woerter() as string
dim punkte as short
dim old() as string
dim weiter as integer
dim gefunden() as string 'dynamischer array
dim x as integer
dim doppelt as integer
Screenres 400,200
open "liste" for input as #1
REDIM old(1) AS STRING
REDIM s2(1) AS STRING
while not EOF(1)
    x += 1
    REDIM Preserve woerter(x) AS STRING
    REDIM Preserve s2(x) AS STRING
        line INPUT #1, woerter(x)
wend
close #1

print "Doppelte Fehler nicht werten?"
Print "Du hast dann weniger Versuche"
print "           J / N"
do : sleep 1 : key = inkey : loop until key <> ""
if lcase(key) = "j" then
    doppelt = 1
    leben = 9
else
    doppelt = 0
    leben = 15
end if

cls

randomize timer
x = rnd * (ubound(woerter)) +1
wort = woerter(x)
wort = lcase(wort)
offen = ""
redim gefunden(1 to len(wort))
do
    locate 1,1
    print "Punktestand: "& punkte
    locate 3,1
    print "Versuche: "& leben
    locate 5,1
    Print "Buchstaben eingeben (Kein enter erforderlich)"
    locate 7,1
    if leben > 0 then
        offen = ""
        for i as integer = 1 to len(wort)
            if gefunden(i) <> "" then
                print gefunden(i) & " ";
                offen = offen + gefunden(i)
            else
                print "_ ";
            end if
        next
    end if
    if leben = 0 or offen = wort then
        cls
        if offen = wort then
            print "Du hast gewonnen, das wort ist "& wort
            punkte += (len(wort) + leben)
            print "Punktestand: "& punkte
        end if

        print "Weiter? J/N"
        do : sleep 1 : key = inkey : loop until key <> ""
        if lcase(key) = "j" then
            if doppelt = 1 then
                leben = 9
            else
                leben = 15
            end if
            do
                x = rnd * (ubound(woerter)-1) +1
                if x > ubound(woerter) or x = 0 then print "alarm"
                wort = woerter(x)
                wort = lcase(wort)
            loop until offen <> wort
            redim gefunden(1 to len(wort))
            redim old(1)
            offen = ""
            cls
            continue do
        else
            exit do
        end if
    end if
    do : sleep 1 : key = inkey : loop until key <> ""
    cls
    key = lcase(key)
    if asc(key) = 27 then
        exit do
    end if
    locate 9,1
    if asc(key) >= 97 and asc(key) <= 122 then
        suchpos = 0
        weiter = 1
        if doppelt = 1 then
        for i as integer = 1 to ubound(old)
            if key = old(i) then weiter = 0
        next
        end if
        if weiter = 1 then
        do
            hit = instr(suchpos+1,wort,key)
            if hit = 0 and suchpos = 0 then
                leben -= 1
                if leben = 0 then
                    Print "Falsch! Du hast leider verloren"
                end if
            end if
            if hit <> 0 then 'falls treffer!
                gefunden(hit) = key
                suchpos = hit
            end if
        loop until hit = 0
        redim preserve old(ubound(old)+1)
        old(ubound(old)) = key
        else
            Print ucase(key) & " wurde schoneinmal Genannt"
        end if
    end if
loop