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

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




PostPosted: Tue Jan 18, 2005 6:46 pm   Post subject: variable meaning??

code:

procedure drawbuttons
    drawbox (39, maxy - 116 - sub, 261, maxy - 64 - sub, black)
    drawfillbox (40, maxy - 115 - sub, 260, maxy - 65 - sub, 30)
    drawfillbox (45, maxy - 110 - sub, 255, maxy - 70 - sub, 27)
    Draw.Text (names (b), 50, maxy - 100 - sub, font, 34)
end drawbuttons

Can anyone please tell me what the variable sub in the procedure above is/does in this case?
oh and as well as the "names (b) part
Sponsor
Sponsor
Sponsor
sponsor
xHoly-Divinity




PostPosted: Tue Jan 18, 2005 6:53 pm   Post subject: (No subject)

It does nothing because it has not been 'declared.' You would have to put something like var sub, names : int

Or in your procedure you would have to put
code:

procedure blah (sub, names : int)
code
code
code
end blah


then when you recall it, you would go

code:

blah (x, y)
%You can put any values you want for x and y
basketball4ever




PostPosted: Tue Jan 18, 2005 6:55 pm   Post subject: (No subject)

if ur talking about maxx and maxy... thats not a variable... i believe its the max : P not really a variable... like if ur max pixels on ur window is 60... then the maxx is 60 something like that...
and as for the names... it does nothing
Bacchus




PostPosted: Tue Jan 18, 2005 7:02 pm   Post subject: (No subject)

accually i think he was talking about the variables sub and names Razz not maxy, basically just geussing at the variables and thing. it draws a outline of a box with a filld box inside with another filled box inside of that, and then outputs something under the variables names
sammy101




PostPosted: Tue Jan 18, 2005 7:25 pm   Post subject: (No subject)

yea i think what bacchus said is right
here's another part of the same program,its basically piece of a car racing game
code:

randint
(add, 5, 10)
drawfillbox (position(1), 0, position(1)+100, 100, white)
Pic.Draw (car1, 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 (car1, maxx div 2, maxy div 2, 0)
check := "1"
exit
end if

its supposed to animate car1 and move it accross a screen,can someone please explain the randint(add,5,10)part and how do you determine the speed it moves across the screen???
Bacchus




PostPosted: Tue Jan 18, 2005 7:46 pm   Post subject: (No subject)

randint(add,5,10) assigns a random integer between 5 and 10 (ex. 5, 6, 7, 8, 9, 10) and the speed of the car is accually in that part. the position(1) array/var/thingy (watever you want to call it) is the current position of the car and then the add var (now a random number between 5 and 10) is added to it when the car is drawn and then its permently added to the var. (really they could have added it to the var earlier and skiped the +add in the drawpic) thats what causes the movement, im also guessing that the bit u poasted is in a loop somewhere
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  [ 6 Posts ]
Jump to:   


Style:  
Search: