Weekly Qbasic and Qb64 Lesson Topics

QB64 lessons and tutorials,Games => Lesson Disussion => Topic started by: GarrisonRicketson on May 11, 2011, 08:11:07 am



Title: What I have so Far,Learning program
Post by: GarrisonRicketson on May 11, 2011, 08:11:07 am
This is not much, but here is what I have so far,..it is a idea I have for a "learning Program"....
Code:
   LOCATE 5, 30
PRINT "INTRODUCTION"
PLAY "10aaa4gg1bb10e2g1a"
LOCATE 8, 4
PRINT " This is a program to learn, for very young children, and adults too"
PRINT " Eso es una programa, para ni¤os, y tambien adultos"
PRINT " Es deficil, porque no estoy seguro, por donde empieza"
PRINT " This is hard because I am not sure where to start."
PRINT " It has become obvious, if the person or child dose not know how to read,"
PRINT " I either need to use some voice instruction, or they need some, guidance."
PRINT "Neccistas un guia, o voz, por algunos los quein,no sabes nada de leer"
INPUT ; "press enter to continue,prende intro para continuar ", dummy$
_DELAY 3

SCREEN 12
WIDTH 40
COLOR 15: LOCATE 10, 12: PRINT SPACE$(20)
COLOR 14: LOCATE 10, 12: INPUT "Name: ", name$
PRINT "hello,hola "; name$
INPUT ; "press enter to continue,prende intro para continuar ", dummy$
CLS

COLOR 5: LOCATE 12, 18
WIDTH 40
PRINT "A"
'_playsnd later, "this is A
INPUT "Letter: ", letter$
'-------------------------------
'IF    Not A , try again



'----------------------------------
'  ELSE
PRINT " Bien,te escribe ,Good You wrote "; letter$
_DELAY 1
INPUT ; "press enter to continue,prende intro para continuar ", dummy$
PRINT "Good,you typed,"; letter$
INPUT ; "press enter to continue,prende intro paracontinuar ", dummy$
PRINT "Sorry , thats all for now"



   
Any sugestions are welcome..
from Garry


Title: Re: What I have so Far,Learning program
Post by: OlDosLover on May 11, 2011, 08:19:09 am
Hi all,
    I see you are comparing what was the user entered to a constant (letters of the alphabet).
Code:
PRINT "A"

INPUT "Letter: ", letter$
'-------------------------------
IF    letter$ <> "A" then
  'redo (redirect) this input or fall through to the next statement below the end if.
End If

or

While letter$ <> "A"
  INPUT "Letter: ", letter$
WEND
Could you post a description of what you want your program to do from start to finish please Garry. This would be our "definition of the problem" with which we would break it down into smaller problem and solve.
OlDosLover.


Title: Re: What I have so Far,Learning program
Post by: OlDosLover on May 11, 2011, 09:27:59 am
Hi all,
    Here's a stripped down version of your program Garry. It works except for the exit of the program.
Code:
SCREEN 12
LOCATE 5, 30
PRINT "INTRODUCTION"

LOCATE 8, 4
PRINT " This is a program to learn, for very young children, and adults too"
PRINT " Eso es una programa, para ni¤os, y tambien adultos"
PRINT " Es deficil, porque no estoy seguro, por donde empieza"
PRINT " This is hard because I am not sure where to start."
PRINT " It has become obvious, if the person or child dose not know how to read,"
PRINT " I either need to use some voice instruction, or they need some, guidance."
PRINT "Neccistas un guia, o voz, por algunos los quein,no sabes nada de leer"
PRINT
PRINT "press enter to continue,prende intro para continuar "
dummy$ = INPUT$(1)

CLS

DO
  PRINT "Press the LETTER please"
  z = INT(RND * 26) + 66
  PRINT CHR$(z)
  WHILE Letter$ <> CHR$(z)
    INPUT "Letter: ", Letter$
    Letter$ = UCASE$(Letter$)
  WEND
  PRINT " Bien,te escribe ,Good You wrote "; Letter$
  _DELAY 1
  CLS
LOOP UNTIL _KEYDOWN(27)

PRINT "Sorry , thats all for now"
SLEEP
SYSTEM
It would probably better to use inkey than input.
OlDosLover.


Title: Re: What I have so Far,Learning program
Post by: OlDosLover on May 11, 2011, 10:07:05 am
Hi all,
    Here is a better version that generates random letters that fall downward the screen. If the user misses the letter at bottom of the sceen it continues on. If the user pressed the corrct letter then it prints that.
Code:
SCREEN 12
LOCATE 5, 30
PRINT "INTRODUCTION"

LOCATE 8, 4
PRINT " This is a program to learn, for very young children, and adults too"
PRINT " Eso es una programa, para ni¤os, y tambien adultos"
PRINT " Es deficil, porque no estoy seguro, por donde empieza"
PRINT " This is hard because I am not sure where to start."
PRINT " It has become obvious, if the person or child dose not know how to read,"
PRINT " I either need to use some voice instruction, or they need some, guidance."
PRINT "Neccistas un guia, o voz, por algunos los quein,no sabes nada de leer"
PRINT
PRINT "press enter to continue,prende intro para continuar "
dummy$ = INPUT$(1)
RANDOMIZE TIMER

CLS


DO
  PRINT "Press the LETTER please"
  z = INT(RND * 26) + 65
  Dir = INT(RND * 2) + 1
  RRow% = 1: CCol% = 40: DDelay! = 1

  DO
    LOCATE RRow%, CCol%
    PRINT CHR$(z)
    Letter$ = INKEY$
    IF UCASE$(Letter$) = CHR$(z) THEN EXIT DO
    RRow% = RRow% + 1: IF Dir = 1 THEN CCol% = CCol% + 1 ELSE CCol% = CCol% - 1
    _DELAY DDelay!
    DDelay! = DDelay! - .03 '<-- greater than .03 leads to error
  LOOP WHILE RRow% < 29
  PRINT " Bien,te escribe ,Good You wrote "; Letter$
  _DELAY 1
  CLS
LOOP UNTIL _KEYDOWN(27)
PRINT "Sorry , thats all for now"
SLEEP
SYSTEM
    This was the first learning program that i wrote for my daughter about 18 years ago. This is the QB64 equivalent.
OlDosLover.


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on May 11, 2011, 07:34:38 pm
Hello All,
Quote
Could you post a description of what you want your program to do from start to finish please Garry. This would be our "definition of the problem" with which we would break it down into smaller problem and solve.
OlDosLover.   
Ok,I may also put a program I have, (for Dos), on Drop Box,
it dosen't run real well,...but it would be a good example,...I am not sure I still have it. It should be ,hopefully later tonight,...I will write a description,...It seems like it is fairly complex, in some ways, but your approach, to break it down,...is good, each stage, probably is not that complicated, I am sure you have seen Clippys, qbasics demo,...I like the "flow", it has, how the first page ,is a index of chapters,..you can either, start at chapt 1, or enter the chapter number....
Then each chapter is also, "pages" or segments,...the only thing I don't particuly like, is he never put in a , "go back" option,...so is one wants to go back to the previous "page" or a previous chapter, the only way is to exit and start again, select the chapter, work your way up to the part you want---
 A similar,...but instead of code, early learning of first, the letters, and numbers,
,simple words, spelling them correctly, and perhaps, toward the end some very basic math,...a small , "music", chapter, where the child can enter the basic notes, and perhaps play a simple tune,..and then of course a simple drawing/paint option,.....Perhaps, it be better, instead of entering a chapter number,  a "click" menu, Letters, Numbers, Words and Spelling, Math, Music, Drawing,... we do have various "draw and paint",. programs,so that would be pretty easy, in away, this is not to bad of a description,....Where is the best place to start ?,...it seems, like the "menu" or index,...Like I mentioned, assumeing the user, is a very young child, and can not hardly read yet,...we will need to also do some "sound tracks",...the idea is, to make it as much possible, something a child, could do, without much if any supervision,.... We have already, been covering alot of the "bits and pieces",...in your lessons , and tuts,.....Unseens GDK, may very well be the better way to go,...for one, the colors, are so much nicer "vivid", etc,....I already have found, it is pretty easy to insert _sndplay ( I think it was, I have sort of forgotten,) but In the catch the Bunny it was real easy to insert the music, useng midi, or wav, it would be relatively easy to make recordings, and put the "voice" in.
 I do have some code that, can make the computer "talk", useing  MS sam,..but the words are not all that clear,...I think recordings would be better.
 I guess this may seem like alot, but there is no hurry---I am still going to take the time, to write, a better description, I probably will have to attach it as a text file, or put it on drop box,......Obviuously, this will take some time, and perhaps, several people, if others get interested,...If we really got ambitous,we could do one ver1, for kindargarden, ages, Later another, more advanced, that also included some very basic codeing lessons, along with, math,...At the moment it almost seems over whelming, and impossible, but this is cause I am a little tired,...I haven't tryd any of your code yet, but will, as soon as I close this, just to explain why I didn't mention any of it,...in this post, I am anxious to see, the one you did for your daughter,...in relation to my grandchildren, and the one about to be born, it will still be a couple of years, before any of them could use this,...So there is lots of time...
from Garry


Title: Re: What I have so Far,Learning program
Post by: OlDosLover on May 12, 2011, 02:04:43 am
Hi all,
    From your post i have garnered this as the code idea:
Quote
   EARLY LEARNING PROGRAM
Letter recognition
Number recognition

Simple Spelling
Siimple Maths
Simple Music
Simple Drawing

A master menu , mouse selection, for all of the above topics

    This is achievable. As to the GDK colors , the GDK uses the same _rgb32(r,g,b) as standard QB64 programs. It may be the choice of colors and the use of many similar individual colors that unseen used to compose a picture. This could be done in GDK. This could also be done in standard QB64 and then converted into the GDK.
    I'd prefer that it be done in standard QB64 and later converted. GDK is always being improved. Unseen is the only one fluent in the library. By having 2 versions (standard and gdk) gives the community a choice. ATM we can break this up into simple sections that get stuck back together to compose the complete program.
    If this is what you envisioned in your mind Garry , then id say you should PM all our members and ask who wants to help. The program could be divided into sections and or code,music,graphics. By keeping this flexable and giving people a choice we may get more support.
OlDosLover.


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on May 12, 2011, 07:42:10 am
Thats pretty much it in your summary,..and agree on the GDK,.. I actually like your description, real well,Mine would probably get to long and overly detailed, thus confuseing people, more then discribeing,..,...
----From Garry
Here is the new topic:
New Project, learning program

http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/topic,171.msg943.html#msg943

Quote
then id say you should PM all our members and ask who wants to help.   
I made the note, everyone is welcome to help (particpate),...but also will do the PMs, later...
from Garry


Title: Re: What I have so Far,Learning program
Post by: OlDosLover on May 12, 2011, 03:05:41 pm
Hi all,
    Garry id like to do the main screen and main menu part. I have an idea that would work and look good. Id make the menu so that on clicking the relevant menu item the code jumps to that section. The individual programs would slot into this "structure" easily enough. One thing is lets make this version 1 and just get it to work. Better ideas will come about once we have a working program.
Id also suggest version 1 be mostly a text program and leave the fancy graphics to version 2.
OlDosLover.


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on May 13, 2011, 07:39:28 am
This sounds good, I still didn't do anything with more description,
but yea,I agree,...Sorry on the delay,replying, actually I thought I had, replied,
last night,...
from garry


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on June 11, 2011, 07:27:04 pm
I was going back thru this, and allthough I understand some, there is something I can not quite figure out,...
Code:
DO
    PRINT "Press the LETTER please"
    z = INT(RND * 26) + 66
    PRINT CHR$(z)
    WHILE Letter$ <> CHR$(z)
        INPUT "Letter: ", Letter$ '//// somewhere in here, I want it to print "sorry, that is not the correct letter, try again " if the letter is not correct
        Letter$ = UCASE$(Letter$)
    WEND
    PRINT " Bien,te escribe ,Good You wrote "; Letter$
    _DELAY 1
    CLS
LOOP UNTIL _KEYDOWN(27)

PRINT "Sorry , thats all for now"
SLEEP
SYSTEM
Ok hope I make sense, as it is, if the letter is not correct, it just displays:
LETTER:  and what I was trying to do is make it say "sorry try again" (or somethin like that) if the letter did not match,.. If the correct letter is entered, it dose say:  " Bien,te escribe ,Good You wrote " and a new letter appears , with the LETTER: prompt,...that part is fine,
since this is not a IF statement I caouldnt use ELSE, WHILE and WEND, are new to me.
Thanks From Garry


Title: Re: What I have so Far,Learning program
Post by: OlDosLover on June 11, 2011, 07:48:11 pm
Hi all,
    While ... Wend is like Do ... Loop. The syntax is
WHILE condition true WEND. So in this case where
Quote
WHILE Letter$ <> CHR$(z)
is written , it means in plain english, While the generated letter does not equal the inputted letter. Which leads to repetition and allows user to select another letter.
    If you want to respond to an incorrect letter then simply add a comparison and message off that comparisson.
Code:
WHILE Letter$ <> CHR$(z)
        INPUT "Letter: ", Letter$ '//// somewhere in here, I want it to print "sorry, that is not the correct letter, try again " if the letter is not correct
        Letter$ = UCASE$(Letter$)
        If ucase$(Letter$) <> chr$(z) then
           Print "You selected ";Letter$;" which is wrong.Please enter ";chr$(z)
        end if
    WEND
OlDosLover.


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on June 11, 2011, 08:07:11 pm
Thanks a bunch Oldoslover,
 That was a simple one, but it would of taken me hours, looking thru tutorials, and then I might never have found what fits this,...the < > greater then ,less then symbols, are significant of "not equal too " ?
From Garry


Title: Re: What I have so Far,Learning program
Post by: OlDosLover on June 11, 2011, 08:18:17 pm
Hi all,
    Respectfully if you dont know this then you should research tutorials so you understand it. As programmers we have to use combinations of those symbols to make our programs work. Therefor to read and understand another programmers program you need to know them.
something = something equal
something => something equal or greater than
something =< something equal or less than
something <> something not equal
This stuff should be in the wiki. This is part of the reason you should compose a program description in english. That way you can relate the action wanted into the code that produces that action. Makeing a program work is half the job. Understanding how and why it works is the other half.
OlDosLover.


Title: Re: What I have so Far,Learning program
Post by: OlDosLover 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.


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on June 11, 2011, 11:48:35 pm
Quote
  Respectfully if you dont know this then you should research tutorials so you understand it
Ok well sorry, all though I did know > is greater then , < is less then ,but no I didnt, know combined <> is not equal too,...Probably thats what I need to do, is just spend all my time looking at the tutorials, and try to figure it, instead of bothering people with "silly" questions,.. I realize most of what I am trying to learn is so basic, that it must seem ridiculess, some of the things I ask about ,sorry.
From Garry


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on June 12, 2011, 02:34:00 am
No no offense taken, and I appreciate the efforts  to explain, I though you knew, my math level is of about the 4th grade level, I did read in one tutorial, it said one needs, at least trigonometry, to get any where with programming code. After all said and done, I agree, my best route would be to not only study the tutorials more, but look for some tutorials on symbols and math, Although I am sure most of what you are saying could be understood by someone with algerbra, and a college level of schooling,..for me it is pretty much just numbers and symbols,I don't think I will ever grasp enough of this, for it to be worth yours or anyone elses, time and trouble, to try to explain,...
Code:
         CLS


DO
    WIDTH 40
    PRINT "Press the LETTER please"
    z = INT(RND * 26) + 66
    PRINT CHR$(z)
    '-------------------------------------------
    WHILE Letter$ <> CHR$(z)
        INPUT "Letter: ", Letter$ '//// somewhere in here, I want it to print "sorry, that is not the correct letter, try again " if the letter is not correct

        Letter$ = UCASE$(Letter$)

        IF UCASE$(Letter$) <> CHR$(z) THEN
            PRINT "Wrong ,you wrote "; Letter$; " Please Try again "; CHR$(z)
        END IF
    WEND

    WHILE Letter$ <> CHR$(z)
        INPUT "Letter: ", Letter$
        Letter$ = UCASE$(Letter$)
    WEND
    PRINT " Good You wrote "; Letter$
    _DELAY 1
    CLS
LOOP UNTIL _KEYDOWN(27)
SLEEP
SYSTEM
I was trying to say I did understand that <> is significant to not equal too,...
The rest I don't, all it gave me was a bunch of letters and numbers,...With the above,  that is all I needed,... and thanks,..but anyway, I have given up on tyng to understand all of this,...it is never going to make any sense to, me perhaps, as suggested, studying the tutorials, and maybe some math,..one day,..But until I learn enough, to understand, the answers to my questions, then I best not ask, and if I understand that much, I probably won't need to ask. I don't even know enough to ask a question,...sensibly.
 But thank you very much for all the time, and trouble trying to teach me,...I do appreciate that, even though it was a hopeless task.
from Garry


Title: Re: What I have so Far,Learning program
Post by: guest on June 12, 2011, 03:12:33 am

     
Quote
I did read in one tutorial, it said one needs, at least trigonometry, to get any where with programming code.
That may ot neccesarily be true, but the math is helpful.
    I rewrote your code to this
Code:
SCREEN 12

WIDTH 40
CLS

DO
  PRINT "Press the LETTER please"
  z = INT(RND * 26) + 66
  PRINT CHR$(z)
  '-------------------------------------------
  WHILE Letter$ <> CHR$(z)
    INPUT "Letter: ", Letter$ 'somewhere in here, I want it to print message if the letter is not correct
    Letter$ = UCASE$(Letter$)

    IF Letter$ = CHR$(z) THEN
      PRINT " Good You wrote "; Letter$
    ELSE
      PRINT "Wrong ,you wrote "; Letter$; " Please Try again "; CHR$(z)
    END IF
  WEND

  _DELAY 1
  CLS
LOOP UNTIL _KEYDOWN(27)
SLEEP
SYSTEM

   


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on June 15, 2011, 12:46:14 am
Code:
SCREEN 12

WIDTH 40
CLS
COLOR 15: LOCATE 10, 12: PRINT SPACE$(20)
COLOR 14: LOCATE 10, 12: INPUT "Enter your Name: ", name$
IF UCASE$(name$) = UCASE$(name$) THEN PRINT "Hello "; name$; " Hope you enjoy this little program "


DO

    COLOR 14, 2
    PLAY "2a4g8e12g4a4a"
    PRINT "Press the LETTER please"
    az = INT(RND * 26) + 65
    PRINT CHR$(az)
    '-------------------------------------------
    WHILE Letter$ <> CHR$(az)
        INPUT "Letter: ", Letter$ 'somewhere in here, I want it to print message if the letter is not correct
        Letter$ = UCASE$(Letter$)

        IF Letter$ = CHR$(az) THEN
            PRINT " Good "; name$; " You wrote "; Letter$
        ELSE
            PRINT "Wrong ,you wrote "; Letter$; " Please Try again "; CHR$(az)
        END IF
    WEND

    _DELAY 1
    CLS
LOOP UNTIL _KEYDOWN(27)
SLEEP
SYSTEM   
From Garry


Title: Re: What I have so Far,Learning program
Post by: GarrisonRicketson on September 11, 2011, 07:08:14 pm
Actually this never made much sense to me,..but it might to some one else.

 
Quote
           LETTER DROP
   So now that we have the skeleton of code that holds our data (A-Z) we now come to the choice of methods we
1] display them
2] monitor any keyboard entry
3] results at program end.

1]   If we use SCREEN 12 then we know that we have 30 rows. So if we create a variable that holds the row we increment it upward until its equal to 30 and at that point we end this particular letters journey. Next we select the next letter in our array and reset our variable that holds the row back to 1. The process repeats. While this is happening we need to decide how much time our letter is displayed before it drops down a line. Probably best is a time that starts slow and speeds up. We probably want between 5 to 10 seconds of total falling.

2]   When we monitor the keyboard we have several options. Input , Inkey or _keydown.
   a] Input - program execution stalls and waits for a keypress and enter.
   b] Inkey allows execution to continues but we have to remove keys from the buffer
   c] _Keydown allows execution to continue and doesnt care about the buffer being full or empty

3]   We need to connect right and wrong attempts to the existing 26 items of data. Idealy we could use another 2 arrays (parallel) to our Alphabet array to record both correct and incorrect attempts. At program end we could display back the wrong or right or both letters and their totals. This also allows us to "track" the users efforts and later to recommend them what are their faults. And obviously these would allow us to monitor the programs execution.

   So clearly here there are 3 things that need to be done simultaneously. And all of this needs to repeat. This needs to repeat until the user exhausts all of the correct options or gets bored and wants to exit. So lets write some psuedo code to describe this.

Do
  Locate and Print selected Letter
  Monitor keyboard
  If keyboard data compare it to existing game data
  If key data right or wrong record it
  Increment Row , Timer period , wrong attempts
  If a letter sequence has been completed reset for next letter
Loop until Correct = All OR _keydown = ESCAPE