Oon lähössä kaverin mökille vappua viettämään. Mutta koska oon semmonen aamuvirkku, niin tylsistyin aika nopeesti ku porukoilla luonnollisesti kestää (herääminen). Koodasin huvikseni tämmösen "pelin", jossa testataan sekä reaktionopeutta, että "tietokonekirjoitustaitoja"... Omat enkat on siinä kaheksan sekunnin lukemisissa ilman virheitä..
Idea on siis seuraava: ruudulla on kopio sun näppiksen tietystä osasta (aakkoset ja -.,). Yksi niistä loistaa ja sitä näppäintä on tarkoitus painaa. Painaessa näppäin vaihtuu toiseen. Paina taas sitä jne. Kymmenen kertaa pitää painaa (tosin voihan sitä lukua muuttaa koodista), jonka jälkeen näet nopeutesi ja tarkkuutesi. Tämä ohjelma ei siis jäljittele mitään oikeita sanoja. Koodissa on tällä hetkellä aivan turhia välejä ja voi olla jopa jotain turhaa sälääkin, kun en jaksanut siihen ulkoasuun panostaa.
Code: Select all
SCREEN 1024, 768
FrameLimit 40
fFont = LoadFont( "Times New Roman", 20 )
fLarge = LoadFont( "Times New Roman", 40 )
Const SIZE = 50
Const MAX_TIMES = 10
While True
newNbr = Rand( 16, 53 )
If Not Restricted( newNbr ) Then Exit
Wend
gameState = 2
Repeat
If gameState <> 0 Then
Color 200, 200, 200
Box ScreenWidth() / 2 - ScreenWidth() / 4, ScreenHeight() / 2 - ScreenHeight() / 4, ScreenWidth() / 2, ScreenHeight() / 2
Color cbWhite
Box ScreenWidth() / 2 - ScreenWidth() / 4, ScreenHeight() / 2 - ScreenHeight() / 4, ScreenWidth() / 2, ScreenHeight() / 2, 0
If gameState = 3 Then
SetFont fFont
Color cbBlack
_message$ = "Time: " + ( loppuaika - aika# ) / 1000 + " seconds."
_message2$ = "Mistakes: " + virheitä + " / " + ( virheitä + osumia )
_message3$ = "Press enter to start the game... (esc to quit)"
Text ScreenWidth() / 2 - TextWidth( _message$ ) / 2, ScreenHeight() / 2 - TextHeight( _message$ ) / 2, _message$
Text ScreenWidth() / 2 - TextWidth( _message$ ) / 2, ScreenHeight() / 2 - TextHeight( _message$ ) / 2 + TextHeight("I"), _message2$
Text ScreenWidth() / 2 - TextWidth( _message3$ ) / 2, ScreenHeight() / 2 - TextHeight( _message3$ ) / 2 + TextHeight("I") * 4, _message3$
If KeyHit( cbkeyreturn ) Then
_times = 0
gameState = 1
aloitusAika = Timer() + 2000
ClearKeys()
EndIf
ElseIf gameState = 2 Then
SetFont fLarge
Color cbBlack
_message$ = "Press enter to start the game..."
Text ScreenWidth() / 2 - TextWidth( _message$ ) / 2, ScreenHeight() / 2 - TextHeight( _message$ ) / 2, _message$
If KeyHit( cbkeyreturn ) Then
aloitusAika = Timer() + 2000
gameState = 1
EndIf
ElseIf gameState = 1
SetFont fLarge
Color cbBlack
_tempAika = ( aloitusAika - Timer() ) / 1000
If _tempAika = 1 Then
_message$ = "Start!"
ElseIf _tempAika = 0 Then
gameState = 0
virheitä = 0
osumia = 0
aika# = Timer()
EndIf
Text ScreenWidth() / 2 - TextWidth( _message$ ) / 2, ScreenHeight() / 2 - TextHeight( _message$ ) / 2, _message$
EndIf
EndIf
SetFont fFont
y = 0
x = 0
key = 0
alhaalla = 0
For a = 16 To 53
If KeyDown( a ) Then alhaalla + 1
Next a
For i = 16 To 53
x + 1
If x > 14 Then
x = 1
y + 1
EndIf
If gameState = 0 Then
If KeyDown( i ) Then key = i
If KeyUp( i ) Then
If i = newNbr And alhaalla < 2 Then
osumia + 1
Else
virheitä + 1
EndIf
key = 0
While True
newNbr = Rand( 16, 53 )
If Not Restricted( newNbr ) Then Exit
Wend
_times + 1
EndIf
EndIf
If Not Restricted( i ) Then
Select i
Case 16
_txt$ = "Q"
Case 17
_txt$ = "W"
Case 18
_txt$ = "E"
Case 19
_txt$ = "R"
Case 20
_txt$ = "T"
Case 21
_txt$ = "Y"
Case 22
_txt$ = "U"
Case 23
_txt$ = "I"
Case 24
_txt$ = "O"
Case 25
_txt$ = "P"
Case 26
_txt$ = "Å"
Case 30
_txt$ = "A"
Case 31
_txt$ = "S"
Case 32
_txt$ = "D"
Case 33
_txt$ = "F"
Case 34
_txt$ = "G"
Case 35
_txt$ = "H"
Case 36
_txt$ = "J"
Case 37
_txt$ = "K"
Case 38
_txt$ = "L"
Case 39
_txt$ = "Ö"
Case 40
_txt$ = "Ä"
Case 44
_txt$ = "Z"
Case 45
_txt$ = "X"
Case 46
_txt$ = "C"
Case 47
_txt$ = "V"
Case 48
_txt$ = "B"
Case 49
_txt$ = "N"
Case 50
_txt$ = "M"
Case 51
_txt$ = ","
Case 52
_txt$ = "."
Case 53
_txt$ = "-"
EndSelect
Color cbWhite
If gameState = 0 Then
If i = newNbr Then Color cbBlue
If i = key then
Color cbRed
If i = newNbr + 14 Or i = newNbr - 1 Or i = NewNbr + 1 Or i = newNbr - 14 Then
Color cbOrange
EndIf
If i = newNbr then Color cbGreen
EndIf
EndIf
Box SIZE * x + y * 10, SIZE * y, SIZE, SIZE
Color cbBlack
Box SIZE * x + y * 10, SIZE * y, SIZE, SIZE, 0
Text SIZE * x + y * 10 + SIZE / 4, SIZE * y + SIZE / 4, _txt$
Else
If key = 28 Then
While True
newNbr = Rand( 16, 53 )
If Not Restricted( newNbr ) Then Exit
Wend
_times = 0
gameState = 2
ClearKeys()
EndIf
EndIf
Next i
Color cbWhite
If _times => MAX_TIMES And gameState <> 3 Then
gameState = 3
loppuaika = Timer()
EndIf
DrawScreen
Forever
Function Restricted( _nbr )
If _nbr = 27 Or _nbr = 28 Or _nbr = 29 Or _nbr = 41 Or _nbr = 42 Or _nbr = 43 Then
Return 1
EndIf
End Function
Edit: 6.771 ilman virheitä enkka. Edit2. W0t ei ookkaa
. Bugi koodissa, jostain syystä pääsin läpi kaheksalla painalluksella. Eli tavallista hitaammin vedin
.
Edit3. Bugi korjattu. Ongelma oli restartissa. Laskuria ei nollattu.
Ton postin ja kolmen editin välissä oli niin pieni aika, että tää muistuttaa enemmänki jotain outoa yksinpuhelua...