Liberty BASIC Community Forum
« Need a little kick start »

Welcome Guest. Please Login or Register.
Feb 22nd, 2018, 12:20pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Need a little kick start  (Read 354 times)
cogburn
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 108
xx Need a little kick start
« Thread started on: Aug 6th, 2014, 2:05pm »

I want to make a program that will scroll through a list of students in my class and randomly select one to answer a question. It should work kind of like a slot machine. Names would appear on the screen and perhaps the color of the name would change in a scrolling fashion or names would flash up on the screen quickly in a random order and finally a name would remain on the screen. I need a kick start in a direction I should go. I plan to put the student names in data statements if that would work.

Any suggestions would be appreciated.
« Last Edit: Aug 6th, 2014, 2:06pm by cogburn » User IP Logged

Noble D. Bell
Board Moderator

member is offline

Avatar




PM

Gender: Male
Posts: 935
xx Re: Need a little kick start
« Reply #1 on: Aug 6th, 2014, 4:24pm »

It sounds like you have it pretty well outlined on paper what you would like to do.

Here are some thoughts (kick-start's):

You can put the names of the students in data statements and read them into a string array.

I would then create a random number generator to give you a random number from 1 to the total number of students.

You could then have the random number routine loop x number of times to simulate a slot machine effect.

While the random number routine is looping you could take the number it gives you each time and look at the corresponding array index and display the name on the screen.

I would put a pause in here so that people could see it change.

On the last time through do not clear the screen so as to leave the name there. That would be the one that answers the question.
User IP Logged

Thank you and God bless,
Noble D. Bell
http://www.noblebell.com
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1182
xx Re: Need a little kick start
« Reply #2 on: Aug 6th, 2014, 5:20pm »

Hi Cogburn- good to see you are still around!
I threw this together- you could adapt several of the ideas used.
Code:
    nomainwin

    read classSize

    dim name$( classSize)

    for i =1 to classSize
        read i$: name$( i) =i$
    next i


    WindowWidth  =310
    WindowHeight =300

    graphicbox #w.g, 10, 10, 280, 250

    open "Random student selector" for window as #w

    #w "trapclose [quit]"

    #w.g "down"
    #w.g "font arial bold 20"

    kOld =1

    for j =1 to 100
        #w.g "place 1 240"
        k =1 +int( classSize *rnd( 1))
        if k <>kOld then
            #w.g "color     "; 256*rnd(1); " "; 256*rnd(1); " "; 256*rnd(1)
            #w.g "backcolor "; 256*rnd(1); " "; 256*rnd(1); " "; 256*rnd(1)
            #w.g "\ "; name$( k); space$( 40)
            #w.g "getbmp scr 1 1 280 250"
            #w.g "cls ; drawbmp scr 1 -36"
        end if
        kOld =k
        timer int( 2 * j), [cont]
        wait
        [cont]
        timer 0
    next j

    #w.g "cls"
    #w.g "place 20 100"
    r =256*rnd(1): g =256*rnd(1): b =256*rnd(1)
    #w.g "fill     "; r; " "; g; " "; b
    #w.g "backcolor "; b; " "; r; " "; g
    #w.g "\ "; name$( k); " "

    wait

    [quit]
    close #w
    end

    data 9, "John F", "Carl G", "Anatoly", "Alyce W", "Michael M", "Noble Bell", "Rod Bird", "Chris I", "Bluatigro"
 
« Last Edit: Aug 7th, 2014, 03:19am by tenochtitlanuk » User IP Logged

cogburn
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 108
xx Re: Need a little kick start
« Reply #3 on: Aug 7th, 2014, 11:45am »

Thanks to both of you for the ideas and code. This is just about exactly what I needed.
Scott
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls