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

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




PostPosted: Thu Jan 13, 2005 6:13 pm   Post subject: turing coding

Can anyone tell me in depth what this piece of coding(turing) does.

loop
randint (add, 5, 10)
drawfillbox (position (1), 0, position (1) + 100, 100, white)
Pic.Draw (horse, position (1) + add, 0, 0)
position (1) := position (1) + add
drawline (maxx - 100, maxy, maxx - 100, 0, black)
delay (25)
if position (1) >= maxx - 100 then
cls
Pic.Draw (horse, maxx div 2, maxy div 2, 0)
check := "1"
exit
end if
randint (add, 5, 10)
drawfillbox (position (2), 100, position (2) + 100, 200, white)
Pic.Draw (horse2, position (2) + add, 100, 0)
drawline (maxx - 100, maxy, maxx - 100, 0, black)
delay (25)
position (2) := position (2) + add
if position (2) >= maxx - 100 then
cls
Pic.Draw (horse2, maxx div 2, maxy div 2, 0)
check := "2"
exit
end if
randint (add, 5, 10)
drawfillbox (position (3), 200, position (3) + 100, 300, white)
Pic.Draw (horse3, position (3) + add, 200, 0)
drawline (maxx - 100, maxy, maxx - 100, 0, black)
delay (25)
position (3) := position (3) + add
if position (3) >= maxx - 100 then
cls
Pic.Draw (horse3, maxx div 2, maxy div 2, 0)
check := "3"
exit
end if
randint (add, 5, 10)
drawfillbox (position (4), 300, position (4) + 100, 400, white)
Pic.Draw (horse4, position (4) + add, 300, 0)
drawline (maxx - 100, maxy, maxx - 100, 0, black)
delay (25)
position (4) := position (4) + add
if position (4) >= maxx - 100 then
cls
Pic.Draw (horse4, maxx div 2, maxy div 2, 0)
check := "4"
exit
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Thu Jan 13, 2005 6:19 pm   Post subject: (No subject)

It looks it will animate a horse as it moves across the screen (at a somewhat random pace). If the horse reaches the end of the screen, the screen is cleared and the "frame" of the "animation" is stored in the variable "check".
If you want more in-depth than that, it'd probably be easiest for you to tell us what you don't understand.

Lastly, please use [ code][ /code] or [ syntax][ /syntax] tags when posting code.
sammy101




PostPosted: Fri Jan 14, 2005 2:58 pm   Post subject: (No subject)

thanks cervantes for the help with coding

I have another part to this program as well that I need help on
if anyone can tell me what this is for.....
code:
loop
        Mouse.Where (x, y, z)
        if z = 1 and x > 39 and x < 261 and y > maxy - 116 - sub and y < maxy - 64 - sub then
            exit
        elsif z = 1 and x > 289 and x < 511 and y > maxy - 116 - sub and y < maxy - 64 - sub then
            bet := "n"
            exit
        end if
    end loop
sport




PostPosted: Fri Jan 14, 2005 3:35 pm   Post subject: (No subject)

x and y tell you the position and if z=1 then the mouse has been clicked
sammy101




PostPosted: Sat Jan 15, 2005 7:20 pm   Post subject: (No subject)

at the risk of sounding like a noob what do you mean if z=1?What is z in this case...
Cervantes




PostPosted: Sat Jan 15, 2005 7:43 pm   Post subject: (No subject)

Ohter than a horrible variable name, z represents whether a mouse button has been pushed.
Read the Turing Reference before asking these simple questions.
The Turing Reference, accessed by pressing F9 or F10 wrote:

Syntax Mouse.Where (var x, y, button : int)

Description The Mouse.Where procedure is used to get current information about the status of the mouse. The parameters x and y are set to the current location of the mouse cursor. If the program is running on a system using windows, the cursor may be outside the window. This means that x and y may be set to values outside of the bounds of 0 to maxx and 0 to maxy.
The parameter button is set depending on the current mode. In "single-button mode" (where the mouse is treated like a one-button mouse), button is set to 0 if all the mouse buttons are up, and 1 if any of the mouse buttons are down. In "multi-button mode", button is assigned the sum of 1 if the left button is down, 10 if the middle button is down, and 100 if the right button is down. Thus if button has the value of 101, then it means that the left and right mouse buttons were depressed.
sport




PostPosted: Sat Jan 15, 2005 10:46 pm   Post subject: (No subject)

I guess you're right it's a horrible name but that's the variable that he had in the code
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  [ 7 Posts ]
Jump to:   


Style:  
Search: