Partager via


Create your own typing tutor!

Here’s an idea to teach somebody the positions of the letters on the keyboard: letters fly in randomly from the right for 30 seconds. Hit the letter on the keyboard for points. Miss and lose points. As time goes on, the letters move faster and there are more of them. More points are earned for faster typists. Points are deducted for misses. Can anyone beat my high score of 3760?

#define MAXLETS 10

PUBLIC ox

ox=CREATEOBJECT("Letters")

ox.show()

DEFINE CLASS Letters as Form

      left=200

      width=600

      height=300

      backcolor=-1

      nScore=0

      nTicks=0

      nHighScore=0

      nInterval=100 && # of msecs per tick

      DIMENSION aLets[MAXLETS]

      allowoutput=.f.

      nMaxSecs=30

      ADD OBJECT MyTimer as timer

      PROCEDURE init

            FOR i = 1 TO MAXLETS

                  thisform.AddObject("thisform.aLets["+trans(i)+"]","MyLabel")

            ENDFOR

            DECLARE integer Beep IN WIN32API integer Freq, integer DurationMs

            this.mytimer.interval=thisform.nInterval

            IF FILE("letters.txt")

                  this.nHighScore=INT(VAL(FILETOSTR("letters.txt")))

            ENDIF

      PROCEDURE keypress(nKeyCode, nShiftAltCtrl)

            IF nKeyCode=27 && Escape

                  thisform.Release

            ELSE

                  oGotone = .null.

                  FOR i = 1 TO MAXLETS

                        WITH thisform.aLets[i] as Label

                              IF .Visible AND .Caption = UPPER(CHR(nKeyCode))

                                    IF ISNULL(oGotone) OR .Left < oGotone.left && get leftmost

                                          oGotone = thisform.aLets[i]

                                    ENDIF

                              ENDIF

                        ENDWITH

                  ENDFOR

                  IF ISNULL(oGotone)

                        thisform.BadOne(50)

                  ELSE

                        oGotone.visible = .f.

                        thisform.nScore=thisform.nScore+ INT(oGotone.left/10) && higher score for rightmost

                  ENDIF

            ENDIF

      PROCEDURE BadOne(nHowBad)

            thisform.nScore=MAX(0,thisform.nScore-nHowBad)

            beep(2000,20)

      PROCEDURE MyTimer.timer

            thisform.nTicks=thisform.nTicks+1

            nSecs=thisform.nTicks*this.interval/1000

            IF nSecs > thisform.nMaxSecs && out of time?

                  FOR i = 1 TO MAXLETS

                        thisform.aLets[i].Visible=.f. && hide all letters

                  ENDFOR

                  IF thisform.nHighScore < thisform.nScore

                        MESSAGEBOX("New High Score: "+TRANSFORM(thisform.nScore)+"! Old = "+TRANSFORM(thisform.nHighScore),48)

                        thisform.nHighScore=thisform.nScore

                        STRTOFILE(TRANSFORM(thisform.nScore),"letters.txt") && record high score

                  ELSE

                        MESSAGEBOX("Your Score: "+TRANSFORM(thisform.nScore)+" High Score = "+TRANSFORM(thisform.nHighScore))

                  ENDIF

                  thisform.nScore=0 && Restart

                  thisform.nTicks=0

            ELSE

                  thisform.Caption = TRANSFORM(thisform.nScore) + " "+TRANSFORM(INT((thisform.nMaxSecs- nSecs)))

                  FOR i = 1 TO MAXLETS

                        WITH thisform.aLets[i] as Label

                              IF .Visible

                                    .Left = .Left - .dx

                                    IF .Left <= 0

                                          .Visible=.f.

                                          thisform.BadOne(100)

                                    ENDIF

                              ELSE

                                    nFactor = nSecs /thisform.nMaxSecs && 0-1

                                    IF RAND() < .5*nFactor && gradually increase # of letters

                                          .dx = 1+RAND() * 15 * nFactor && gradually accelerate

                                          .Left=thisform.Width - .dx

                                          .ForeColor=0xffffff-MOD(thisform.nTicks*100,256^3)

                                          .Top = .9 * (RAND() * thisform.Height)

                                          .Caption = CHR(65+RAND()*26)

                                          .Visible= 1

                                    ENDIF

                              ENDIF

                        ENDWITH

                  ENDFOR

            ENDIF

ENDDEFINE

DEFINE CLASS MyLabel as Label

      Fontsize=20

      FontBold=1

      FontName="Verdana"

      BackStyle=0 && transparent

      dx=1

      Height = 32

      Width = 26

ENDDEFINE

Comments

  • Anonymous
    January 23, 2006
    That's fun Calvin. I'll send you a bill for the work I've missed playing your game. LOL

  • Anonymous
    January 24, 2006
    This is cool! My kids (9 and 12) will love it! Thanks.

  • Anonymous
    February 20, 2006
    The comment has been removed

  • Anonymous
    September 05, 2006
    Warning: this simple program produces mesmerizing spirographic images that seem hallucinatory in nature!...

  • Anonymous
    September 14, 2006
    When I took my 3 year old son for the first day of preschool, there was a table with several nametags...

  • Anonymous
    September 22, 2006
    1st try: 5634

    Wow, didn't think I could type that well.  You wouldn't know it if you watched me program

  • Anonymous
    June 19, 2007
    Sometimes friends or relatives might hear that you’re an expert with using computers, and might ask you

  • Anonymous
    April 01, 2008
    This program is a very Fast, Easy, Fun typing program ONLINE for free! You will be able to see your typoing skills IMPROVE within just a coupole of weeks! Remember the key to success is: NEVER GIVE UP! Have fun!

  • Anonymous
    April 24, 2008
    how do you want to play a typing game

  • Anonymous
    April 24, 2008
    i want to help people learn by doing something fun by a very fun game

  • Anonymous
    April 24, 2008
    i want to help people learn by doing something fun by a very fun game

  • Anonymous
    June 06, 2008
    I was using a program that was yet another TLA and I wanted to create a mnemonic to help me remember

  • Anonymous
    June 30, 2008
    In this post, Create your own typing tutor! is code to create a game for learning the letters of the

  • Anonymous
    September 10, 2008
    great piece of code thanks man.

  • Anonymous
    September 26, 2008
    with software I need to buy or I need to download in order to make the typing tutor. cuold you advice. the program I want to make is for first grade. Schoold proyect. your advice will be appreciated. Thank you Rafael

  • Anonymous
    September 26, 2008
    with software I need to buy or I need to download in order to make the typing tutor. cuold you advice. the program I want to make is for first grade. Schoold proyect. your advice will be appreciated. Thank you Rafael

  • Anonymous
    March 01, 2009
    Several years ago, my wife and I were walking through a local shopping mall. At the time, there was some

  • Anonymous
    June 01, 2009
    PingBack from http://uniformstores.info/story.php?id=4736

  • Anonymous
    June 01, 2009
    PingBack from http://uniformstores.info/story.php?id=18725

  • Anonymous
    June 02, 2009
    PingBack from http://uniformstores.info/story.php?id=32714

  • Anonymous
    July 02, 2009
    The comment has been removed

  • Anonymous
    March 31, 2013
    I want to start my own Typing Program online and how can I do that?