Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 colouring squares
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
marshymell0




PostPosted: Wed Mar 23, 2005 10:06 pm   Post subject: colouring squares

hey, I found this neat program in ur free source section at
http://www.compsci.ca/v2/viewtopic.php?t=2579
I'm planning to use it for a score board, but I'm not sure how, this is what I have

code:
var a, b, c, d, counter : int
a := 150
counter := 0
b := maxy div 2 + 60
c := 170
d := maxy div 2 + 40
loop
        delay (100)
        a := a + 25
        c := c + 25
        drawbox (a, b, c, d, 8)
        counter := counter + 1
        if counter = 13 or counter = 26 or counter = 39 then
            a := a - 325
            c := c - 325
            b := b - 25
            d := d - 25
        end if
        exit when counter=39
        end loop
I'm going to have a score variable, that adds up throughout a quiz I made. So at the end, I'm going to clear screen and add this, but I was wondering how I could colour in the number of squares according to how many questions the user got right. Is this possible? tnx and thx for the code too! Very Happy
Sponsor
Sponsor
Sponsor
sponsor
ssr




PostPosted: Wed Mar 23, 2005 10:17 pm   Post subject: (No subject)

of course you can
I would make an array
save up all the answers
and do something like
if answer = correct then
answer (i):=1
else answer:= 0

end if

now according to the answers, make a loop adn fill out each square. Very Happy gl
marshymell0




PostPosted: Wed Mar 23, 2005 10:19 pm   Post subject: (No subject)

um.....I never learned arrays Confused lol
at the end of my quiz, I ahve a score which has added up, so it'll be a number/int.
ssr




PostPosted: Wed Mar 23, 2005 10:30 pm   Post subject: (No subject)

oh so u dont wanna show liek which one is right,
anyway
this is easier now,
u see how many rights there are
and do a for loop
drawfill in each square until the loop reaches the # of right answers
I will show u an example soon


btw read teh tutorial and learn array
its really useful Very Happy
ssr




PostPosted: Wed Mar 23, 2005 10:48 pm   Post subject: (No subject)

code:
var a := 150
var b := maxy div 2 + 60
var answer : int
put "how many right answers?"
get answer

for counter : 1 .. answer
    drawfillbox (a, b, a + 20, b + 20, 8)
    if counter mod 13 = 0 then
        a := a - 325
        b := b - 25
    end if
    delay (100)
    a := a + 25
end for

for i:answer+1..39
    drawbox (a, b, a + 20, b + 20, 8)
    if i mod 13 = 0 then
        a := a - 325
        b := b - 25
    end if
    delay (100)
    a := a + 25
    delay (100)
end for
or

This is a really long code, u should be able to shorten this code
anyway this is the basic concept Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: