Código: Seleccionar todo
' Gambas class file
felder AS String[]
spielKarteTMP AS String[] '
spielKarte[8, 8] AS String '
spielKartePiep[8, 8] AS String
offene AS string[] ' gefundene karten
spielKarteBol[8, 8] AS Integer
tmpStr AS String
aufgedeckt1 AS String
aufgedeckt2 AS String
anz AS Integer
klickzahl AS Integer
tempX1 AS Integer
tempY1 AS Integer
tempX2 AS Integer
tempY2 AS Integer
anzTXT AS Integer
sekunde AS Integer
minu AS Integer
stunde AS Integer
bild AS Picture
bildCW AS Picture
eratene AS Integer
VERSION AS String
PUBLIC SUB _new()
END
PUBLIC SUB Form_Open()
DIM i AS Integer
DIM ii AS Integer
VERSION = "0.0.2a"
ME.Center()
ME.text = "Morsememory V." & VERSION
versiontest()
felder = ["qsk", "qrb", "qrg", "qrh", "qri", "qrk", "qrl", "qrm", "qrn", "qro", "qrp", "qrq", "qrs", "qrt", "qru", "qrv", "qrx", "qsa", "qsb", "qsk", "qsd", "qsl", "qso", "qsv", "qsy", "qth", "qtr", "abt", "afsk", "agc", "agn", "alc", "atv", "avc", "award", "awdh", "bcnu", "bfo", "bpm", "bug", "cfm", "conds", "condx", "congrats", "cpi", "cuagn", "cul", "dwn", "elbug", "ere", "vy", "wtts", "wx", "xcus", "xmas", "tnx", "sure", "rig", "pse", "my", "name", "73", "ant"]
IF Exist(User.Home & "/Morsememory/") THEN
ELSE
MKDIR User.Home & "/Morsememory/"
MKDIR User.Home & "/Morsememory/Karten/"
COPY "ABC.krt" TO User.Home & "/Morsememory/Karten/ABC.krt"
ENDIF
bild = NEW Picture
bildCW = NEW Picture
bild = Picture["karte.png"]
bildCW = Picture["karteCW.png"]
Hilfeeinschalten.Checked = FALSE
Frame1.Visible = FALSE
offene = NEW String[]
' ModuleMorseCode.Play("morse memory")
GridView1.Columns.Count = 8
GridView1.Rows.Count = 8
GridView1.Columns.Width = 72
GridView1.Rows[0].Height = 72
GridView1.Rows[1].Height = 72
GridView1.Rows[2].Height = 72
GridView1.Rows[3].Height = 72
GridView1.Rows[4].Height = 72
GridView1.Rows[5].Height = 72
GridView1.Rows[6].Height = 72
GridView1.Rows[7].Height = 72
FOR i = 0 TO 7
FOR ii = 0 TO 7
GridView1[i, ii].Picture = bild
NEXT
NEXT
Button1_Click() ' Karten mischen
' testausgabe()
END
'------------------------------------------------------
PUBLIC SUB versiontest()
DIM h AS HttpClient
DIM buffer AS String
DIM tmp AS String[]
h = NEW HttpClient AS "h"
h.UserAgent = "Gambas Morsememory/V " & VERSION & " versionstest"
h.URL = "http://dulbs.homelinux.org/morsememory/version.txt"
h.Get
DO WHILE h.Status <> 0
WAIT 0.01
LOOP
IF h.Status < 0 THEN
'PRINT "ERROR"
ELSE
' Success - read the data
IF Lof(h) THEN READ #h, buffer, Lof(h)
IF InStr(buffer, "|||") THEN
tmp = Split(buffer, "|")
'PRINT "ak_Version=" & tmp[0]
IF tmp[0] > VERSION THEN
'ELSE
Message.Info(("Es ist eine neue Programmversion verfügbar"), "OK")
ENDIF
ENDIF
END IF
END
PUBLIC SUB fueller()
DIM i AS Integer
DIM a AS Integer
DIM z AS Integer
DIM bildCW AS Picture
DIM bild AS Picture
bild = NEW Picture
bild = Picture["karte.png"]
bildCW = NEW Picture
bildCW = Picture["karteCW.png"]
anz = 0
anz = anz + 1
FOR i = 0 TO 7
FOR a = 0 TO 7
anz = anz + 1
GridView1[i, a].Picture = bild
NEXT
NEXT
END
PUBLIC SUB machmaText()
DIM i AS Integer
DIM ii AS Integer
DIM z AS Integer
DIM tmpStr2 AS String
DIM tmpar AS String[]
anzTXT = 0
tmpStr = ""
RANDOMIZE
DO WHILE anzTXT < 32
z = Int(Rnd(0, felder.Count)) ' zufallszahl 0 bis anzahl karten
IF InStr(tmpStr, felder[z]) THEN
ELSE
tmpStr = tmpStr & " " & Trim(felder[z])
anzTXT = anzTXT + 1
' PRINT "\"" & Trim(felder[z]) & "\""
ENDIF
z = Int(Rnd(0, felder.Count)) ' zufallszahl 0 bis anzahl karten
LOOP
tmpar = Split(tmpStr, " ")
' PRINT "--------------" & tmpar.Count
DO WHILE anzTXT < 64
z = Int(Rnd(0, tmpar.Count))
IF tmpar[z] = " " OR tmpar[z] = "" THEN
tmpar.Remove(z)
ELSE
tmpStr2 = tmpStr2 & " " & Trim(tmpar[z])
anzTXT = anzTXT + 1
' PRINT z & " = \"" & Trim(tmpar[z]) & "\""
tmpar.Remove(z)
ENDIF
LOOP
' PRINT tmpStr
'PRINT tmpStr2
' PRINT
tmpStr = tmpStr & tmpStr2
' PRINT tmpStr / 2
END
PUBLIC SUB Button1_Click() ' Karten mischen
DIM kartenTMP AS String[]
DIM kartenTMPcw AS String[]
DIM i AS Integer
DIM ii AS Integer
DIM iii AS Integer
klickzahl = 0
LCDNumber1.value = 0
eratene = 0
TextLabel3.text = ""
TextLabel5.text = ""
' TextLabel6.text = 0
sekunde = 0
minu = 0
stunde = 0
machmaText()
anz = 0
fueller() '
iii = 1
kartenTMP = Split(tmpStr, " ")
FOR i = 0 TO 7
FOR ii = 0 TO 7
spielKarte[i, ii] = kartenTMP[iii]
iii = iii + 1
NEXT
NEXT
END
PUBLIC SUB Hilfeeinschalten_Click()
IF Hilfeeinschalten.Checked = TRUE THEN Frame1.Visible = TRUE
IF Hilfeeinschalten.Checked = FALSE THEN Frame1.Visible = FALSE
END
PUBLIC SUB GridView1_Click()
' PRINT "Row = " & GridView1.Row & " " & "Column = " & GridView1.Column
SELECT klickzahl
CASE 1
IF offene.find(GridView1.Row & "/" & GridView1.Column) = TRUE THEN 'Karten noch im Spiel ?
IF GridView1.Row = tempX1 AND GridView1.Column = tempY1 THEN 'Karte schon offen ?
'klickzahl = 1
ELSE
GridView1[GridView1.Row, GridView1.Column].Picture = bildCW
klickzahl = klickzahl + 1
aufgedeckt2 = spielKarte[GridView1.Row, GridView1.Column]
ModuleMorseCode.Play(aufgedeckt2)
WAIT 0.2
'PRINT "aufgedeckt2 =" & aufgedeckt2
TextLabel5.text = aufgedeckt2
' TextLabel6.text = klickzahl
tempX2 = GridView1.Row
tempY2 = GridView1.Column
' PRINT aufgedeckt1 & "=" & aufgedeckt2
' PRINT "spielKarte[" & GridView1.Row & "," & GridView1.Column & "] = " & spielKarte[GridView1.Row, GridView1.Column]
IF aufgedeckt1 = aufgedeckt2 THEN ' gefunden
eratene = eratene + 1
IF eratene = 32 THEN
Music.Load("Applaus.ogg")
Music.Play()
ENDIF
PictureBox1.Visible = TRUE
LCDNumber1.Visible = TRUE
LCDNumber1.value = eratene
GridView1[tempX1, tempY1].Picture = NULL
GridView1[tempX2, tempY2].Picture = NULL
offene.add(tempX1 & "/" & tempY1)
offene.add(tempX2 & "/" & tempY2)
ELSE
'Music.Load("failure.ogg")
'Music.Play()
ENDIF
ENDIF
ENDIF
CASE 0
IF offene.find(GridView1.Row & "/" & GridView1.Column) = TRUE THEN
GridView1[GridView1.Row, GridView1.Column].Picture = bildCW
tempX1 = GridView1.Row
tempY1 = GridView1.Column
TextLabel3.text = spielKarte[GridView1.Row, GridView1.Column]
aufgedeckt1 = TextLabel3.text
ModuleMorseCode.Play(aufgedeckt1)
WAIT 0.2
' PRINT "aufgedeckt1 =" & aufgedeckt1
' PRINT "spielKarte[" & GridView1.Row & "," & GridView1.Column & "] = " & spielKarte[GridView1.Row, GridView1.Column]
klickzahl = klickzahl + 1
' TextLabel6.text = klickzahl
ENDIF
CASE 2
klickzahl = 0
' TextLabel6.text = klickzahl
TextLabel5.text = ""
TextLabel3.text = ""
IF GridView1[tempX1, tempY1].Picture = bildcw THEN GridView1[tempX1, tempY1].Picture = bild
IF GridView1[tempX2, tempY2].Picture = bildcw THEN GridView1[tempX2, tempY2].Picture = bild
aufgedeckt1 = ""
aufgedeckt2 = ""
END SELECT
WAIT 1
END
PUBLIC SUB Button2_Click()
ME.Close
END
PUBLIC SUB testausgabe() 'nur zum testen
PRINT spielKarte[0, 0] & " " & spielKarte[0, 1] & " " & spielKarte[0, 2] & " " & spielKarte[0, 3] & " " & spielKarte[0, 4] & " " & spielKarte[0, 5] & " " & spielKarte[0, 6] & " " & spielKarte[0, 7]
PRINT spielKarte[1, 1] & " " & spielKarte[1, 1] & " " & spielKarte[1, 2] & " " & spielKarte[1, 3] & " " & spielKarte[1, 4] & " " & spielKarte[1, 5] & " " & spielKarte[1, 6] & " " & spielKarte[1, 7]
PRINT spielKarte[2, 1] & " " & spielKarte[2, 1] & " " & spielKarte[2, 2] & " " & spielKarte[2, 3] & " " & spielKarte[2, 4] & " " & spielKarte[2, 5] & " " & spielKarte[2, 6] & " " & spielKarte[2, 7]
PRINT spielKarte[3, 1] & " " & spielKarte[3, 1] & " " & spielKarte[3, 2] & " " & spielKarte[3, 3] & " " & spielKarte[3, 4] & " " & spielKarte[3, 5] & " " & spielKarte[3, 6] & " " & spielKarte[3, 7]
PRINT spielKarte[4, 1] & " " & spielKarte[4, 1] & " " & spielKarte[4, 2] & " " & spielKarte[4, 3] & " " & spielKarte[4, 4] & " " & spielKarte[4, 5] & " " & spielKarte[4, 6] & " " & spielKarte[4, 7]
PRINT spielKarte[5, 1] & " " & spielKarte[5, 1] & " " & spielKarte[5, 2] & " " & spielKarte[5, 3] & " " & spielKarte[5, 4] & " " & spielKarte[5, 5] & " " & spielKarte[5, 6] & " " & spielKarte[5, 7]
PRINT spielKarte[6, 1] & " " & spielKarte[6, 1] & " " & spielKarte[6, 2] & " " & spielKarte[6, 3] & " " & spielKarte[6, 4] & " " & spielKarte[6, 5] & " " & spielKarte[6, 6] & " " & spielKarte[6, 7]
PRINT spielKarte[7, 1] & " " & spielKarte[7, 1] & " " & spielKarte[7, 2] & " " & spielKarte[7, 3] & " " & spielKarte[7, 4] & " " & spielKarte[7, 5] & " " & spielKarte[7, 6] & " " & spielKarte[7, 7]
END
PUBLIC SUB Menu2_Click() 'info
DIM msg AS String
msg = ("Morsememory darf kostenlos für nich Kommerzielle Zwecke genutzt werden.\n")
msg = msg & ("(c) 2009 by Dirk Unverzagt, DL8AAX\n")
msg = msg & ("E-Mail [email protected]\n")
msg = msg & "\n"
Message(msg, (" OK "))
END
PUBLIC SUB Menu5_Click() 'Programmende
Button2_Click()
END
PUBLIC SUB Menu4_Click() ' Karten laden
DIM hfile AS File
DIM zeile AS String
DIM anzahl AS Integer
DIM tempar AS String[]
tempar = NEW String[]
Dialog.Path = User.Home & "/Morsememory/Karten"
IF NOT Exist(Dialog.Path) THEN
Dialog.Path = User.Home
ENDIF
Dialog.Title = ("Karten Laden")
Dialog.Filter = ["*.krt", "Karten"]
anzahl = 1
IF Dialog.OpenFile() THEN RETURN
hFile = OPEN Dialog.Path FOR READ
WHILE NOT Eof(hFile)
LINE INPUT #hFile, zeile
IF InStr(zeile, "#") THEN
ELSE
TextLabel6.text = zeile
' tempa[anz] = zeile
tempar.Add(zeile)
anzahl = anzahl + 1
ENDIF
WEND
CLOSE hFile
TextLabel6.text = anzahl & " " & ("Spielkarten geladen:") & " " & Dialog.Path
IF anzahl > 31 THEN
felder.clear
felder = tempar
Button1_Click()
ENDIF
END
PUBLIC SUB GridView1_DblClick()
END
PUBLIC SUB Timer1_Timer()
sekunde = sekunde + 1
IF sekunde > 60 THEN
minu = minu + 1
sekunde = 0
END IF
IF minu > 60 THEN
stunde = stunde + 1
minu = 0
END IF
IF stunde > 24 THEN
stunde = 0
minu = 0
sekunde = 0
END IF
TextLabel7.Text = stunde & ":" & minu & ":" & sekunde
END
Código: Seleccionar todo
' Gambas module file
' Developed using Gambas2 Version
'
' Version: 1.9.48
'
' Gambas Components Used:
'
' gb - Gambas Internal native classes
' gb.sdl.sound - Sound library based on SDL
'
' Look in the Project menu then Properties... and select
' the Components tab. Check that the listed components
' are in the project.
'
'''
' External Dependencies:
'
' None.
'
'''
' Class Usage:
'
' Call the Play() method with some text:
'
' ModuleMorseCode.Play("some text")
'
' Call the Stop() method if you get fed up with the noise.
'
' ModuleMorseCode.Stop()
'
'''
PUBLIC _timeTrigger AS Timer
PRIVATE currentText AS String
PUBLIC SUB _init()
_timeTrigger = NEW Timer AS "_timeTrigger"
_timeTrigger.Delay = 250
END
'''
''' Public methods
'''
PUBLIC SUB Play(Text AS String)
IF Trim(currentText) THEN
' If we still have some text left then
' add a space and the new text
currentText = currentText & " " & Text
ELSE
currentText = currentText & Text
END IF
_timeTrigger.Enabled = TRUE
END
PUBLIC SUB Stop()
currentText = ""
END
'''
''' Timer event
'''
PUBLIC SUB _timeTrigger_Timer()
DIM c AS String
' Check if we still have some text left
IF currentText THEN
' Check if we are still playing the current ogg file
IF Music.Pos = 0.0 THEN
' No music file playing.
' Get next character. Note: characters are
' converted to upper case for our file names
c = Upper(Left(currentText))
currentText = Right(currentText, -1)
IF c LIKE "[0-9]" THEN
WAIT 0.1
' Play numbers sound file
Music.Load("MorseCodeSounds/" & c & "_number_morse_code.ogg")
Music.Play()
' FormMorseCode.Sending(c)
' FMain.Sending(c)
ELSE IF c LIKE "[A-Z]" THEN
WAIT 0.1
' Play letters sound file
Music.Load("MorseCodeSounds/" & c & "_morse_code.ogg")
Music.Play()
'FormMorseCode.Sending(c)
' MainForm.Sending(c)
ELSE
' Any other item we shall treat as a space
' i.e wait 0.7 of a second
' FormMorseCode.Sending("space")
' MainForm.Sending("space")
_timeTrigger.Enabled = FALSE
WAIT 0.7
_timeTrigger.Enabled = TRUE
END IF
END IF
ELSE
' No text left. So end timer
'FormMorseCode.Sending("")
' MainForm.Sending("")
_timeTrigger.Enabled = FALSE
END IF
END
''' End of ModuleMorseCode '''