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

Username:   Password: 
 RegisterRegister   
 Easy Program
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
upthescale




PostPosted: Sat Mar 25, 2006 9:52 pm   Post subject: Easy Program

Here is a little program that involves math...




code:

var x, y, numb, button, score : int
var ch : string (1)
score := 0
put "You will see a random number...then a big box will appear..."
put "Remember that number you saw at the beginning, because that"
put "is how many times you will hit the big box...When the number"
put "of times you have hit the big box matches the number at the beginning"
put "then hit the smaller box. For example...If you see a 6 at the beginning"
put "then hit the big box 6 times, and then hit the smaller box!"
put ""
put "Hit a key to continue!"
getch (ch)
cls
randint (numb, 1, 15)
put "The number is ", numb
delay (1200)
cls
loop
    mousewhere (x, y, button)
    drawfillbox (100, 270, 300, 56, 7)
    if x > 100 and x < 300 and y > 56 and y < 270 and button = 1 then
        score := score + 1
        delay (300)
        View.Update
        cls
        put "You have hit the square ", score, " times"
    end if
    mousewhere (x, y, button)
    drawfillbox (570, 340, 500, 410, 7)
    if x > 500 and x < 570 and y > 340 and y < 410 and score = numb and button = 1 then
        put "Good!"
        delay (900)
        exit
    elsif x > 500 and x < 570 and y > 340 and y < 410 and button = 1 then
        delay (300)
        put "The number of times you have hit the square"
        put "does not match the random number at the beginning!"
        delay (2200)
        cls
    end if
end loop
put "You have won!"
delay (900)
cls
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Sat Mar 25, 2006 10:17 pm   Post subject: (No subject)

Good but there is no interaction in it because we win every time even if I hit the small box after 10 days. Confused =S Add some interaction to it other wise it falls under this category:
http://www.compsci.ca/v2/viewtopic.php?t=7734
upthescale




PostPosted: Sat Mar 25, 2006 10:31 pm   Post subject: (No subject)

kk
upthescale




PostPosted: Sat Mar 25, 2006 10:32 pm   Post subject: (No subject)

i cud add a timer
MysticVegeta




PostPosted: Sun Mar 26, 2006 11:20 am   Post subject: (No subject)

Yes, that would be great! And also learn how to make multiple of them falling at the same time Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: