|
Post by B+ on Jun 27, 2021 22:35:09 GMT
' _Title "Simple Simon" 'b+ 2021-06-27 While 1 b$ = b$ + Str$(Int(Rnd(0) * 4) + 1) For i = 1 To Len(b$) Cls Print Space$(i - 1); Mid$(b$, i, 1) call pause 1000 Next Cls Print "Simon says repeat all that:" For i = 1 To Len(b$) k$ = Input$(1) ' < Dav mod to save 3 lines to poll key from Inkey$ Print k$; If k$ <> Mid$(b$, i, 1) Then Beep Print Print b$ end End If Next Wend
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
|
|
|
Post by tsh73 on Jun 28, 2021 9:31:27 GMT
For those who didn't plyed it in childhood (I might be the only one here I guess) program shows a number then hides it and says "Simon says repeat all that:" - this hang me for a while. Repeat WHAT? There is nothing more on the screen ;) You supposed to repeat that number If you did program adds another number fo the first one Now you got to repeat two ... until your memory failed ;)
|
|
|
Post by Rod on Jun 28, 2021 11:10:33 GMT
This uses a pair of textboxes and a standard time delay.
' Simple Simon program using window type dialog and .default button ' this allows either ok or enter to action the user input to the textbox nomainwin statictext #w.st1, "Simple Simon, repeat after me", 20, 10, 260, 25 textbox #w.txt1, 20, 40, 260, 25 textbox #w.txt2, 20, 70, 260, 25 button #w.default, "OK", [respond], UL, 20,100 WindowWidth = 350 : WindowHeight = 190 open "Simple Simon" for dialog as #w #w "trapclose [quit]" while 1 b$ = b$ + Str$(Int(Rnd(0) * 4) + 1)
[shownumber] #w.txt1 b$ timer 1000,[guess] wait
[guess] timer 0 #w.txt1 "" #w.txt2 "!setfocus" wait
[respond] 'get the contents if ok or enter has been clicked #w.txt2 "!contents? response$" #w.txt2 "" if response$<>b$ then playwave "beep",async goto [shownumber] end if wend
[quit] close #w end
|
|
|
Post by Rod on Jun 28, 2021 18:26:10 GMT
Ok, this is B+ mainwin code tweaked a bit. The standard timer makes the input$(1) trick bomb. So I put a while wend delay in line and take a sequence of characters as input. Playwave "beep",async is the standard workround for Beep not working.
' _Title "Simple Simon" 'b+ 2021-06-27 While 1 b$ = b$ + Str$(Int(Rnd(0) * 4) + 1) print b$;" remember this." t=time$("ms")+1017 while time$("ms")<t : wend cls Print "Simon says repeat that number:" 'accept characters and display them until Enter is pressed text$ = "" : c$="" while c$ <> chr$(13) c$ = input$(1) print c$; if c$ <> chr$(13) then text$ = text$ + c$ wend print "You typed:"; text$
If text$ <> b$ Then playwave "beep",async Print "Wrong answer, number was ";b$ end End If Wend
|
|
|
Post by B+ on Jun 29, 2021 0:29:53 GMT
I don't know, showing all the digits in sequence seems to make it easier?
Have you seen the Game Simon with 4 color panels that light up, advancing in difficulty, patterns to memorize?
|
|
|
Post by Rod on Jun 29, 2021 11:12:24 GMT
Easy? I can't get beyond six numbers
|
|
|
Post by B+ on Jun 30, 2021 0:08:17 GMT
:-)) Odds are you will get 7 digits the same if you play enough.
|
|