Weekly Qbasic and Qb64 Lesson Topics
May 15, 2025, 06:34:26 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

What I have so Far,Learning program

Pages: [1] 2
  Print  
Author Topic: What I have so Far,Learning program  (Read 2092 times)
OlDosLover
Guest
« on: June 11, 2011, 09:53:29 pm »

Hi all,
    Here's an example like im talking about. Anyone should be able to follow the idea and the methods.
Quote
            LETTER DROP
   This is an early learning program that has randomly selected letters of the alphabet falling from the top of the screen to the bottom of the screen. As the letter is falling the end user can press the corresponding letter. On entering a letter the program acknowledges a correct selection by rewarding the user with a message of praise and then repeats with another letter allowing the process to continue. On entering a wrong letter the program could ignore it or warn the user that entry is wrong.
   From our description we need 26 letters of the alphabet. We need to select one randomly. We need the letter to fall downward the screen. While the letter is falling the user can press the corresponding letter or an incorrect letter. On reaching the bottom of the screen and no entry or correct entry we assume that the user got it wrong. If the user gets the letter right then we remove that letter from our show list. Eventually the user is left with a list of incorrect letters that should continue to fall until entryed correctly.
   From the more detailed description we can start to code the program. We need a "list" of the 26 letters. Lets discuss how we could create this list.
1] Create the 26 letters in an array
2] randomly generate a number between 65 and 90 which is the ASCII value for capital A to Z
Pro's and Con's
1]    a] We get all the correct letters with no duplicates
   b] They are not randomly placed in the array
2]   a] Each letter is random
   b] Is possible a letter can be repeated more than once at any time
   Now what seemed so easy a minute ago is now complicated. We need a combination of both 1 and 2. If we could create the array and fill it with the correct sequence of numbers representing the leters then we are assured there is none missing or duplicated. Then now if we could shuffle the array randomly then we would have achieved our aim.
Code:
Code:
REM
DEFINT A-Z

SCREEN 12
'create and fill our alphabet array
OPTION BASE 1 'set all arrays to start a element 1 and not as zero
DIM Alphabet%(26) 'our container for the letters
count% = 1
FOR a% = 65 TO 90
  Alphabet%(count%) = a% 'assign the value of a into the correct element of the array
  PRINT CHR$(a%), Alphabet%(count%)
  count% = count% + 1 'count upward 1 to 26 to represent the correct element of the array to be used
NEXT a%

_DELAY 1
PRINT

'shuffle our alphabet array so the order is different
FOR a = 1 TO 26
  elementotswap = INT(RND * 26) + 1 'create randomly 1 to 26
  SWAP Alphabet%(a), Alphabet%(elementotswap) 'swap current with random
  PRINT CHR$(a + 64), Alphabet%(a), CHR$(Alphabet%(a)) ' show proof
NEXT a
SLEEP
SYSTEM

Is this clearer or better?
OlDosLover.
« Last Edit: June 11, 2011, 09:59:53 pm by OlDosLover » Report Spam   Logged

Pages: [1] 2
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy