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

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




PostPosted: Thu Jan 20, 2005 10:49 pm   Post subject: Changing Colours

Hey everyone hows it goin.. i have a program i made which draws watever shape you pick. In the program you choose a colour for the shape, and what i want to do is make it so that you can press the right arrow key to increase the colour by 1, and if you press the left arrow key then it will decrease the colour by 1.

If anyone can help me i would really appreciate it!

Thanks so much.
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Thu Jan 20, 2005 10:53 pm   Post subject: (No subject)

1)
Hello.

2)
In future, post your code (using [code] or [syntax] tags) so that we can assess what level you are at and how best to answer your question.

3)
In this case you'll need to be able to receive input from the User and determine which key was pressed. Depending on what method you use (get, getch, Input.KeyDown) use an if structure to determine what will happen to the colour variable that you have for your shape.

e.g. (pseudo code Razz, I'll let you figure out the good stuff)
[code]
if entered_key = Left arrow then
colourNumber += 1
elsif entered_key = right arrow then
colourNumber -= 1
end if

DrawShape
[/code]
basketball4ever




PostPosted: Thu Jan 20, 2005 11:21 pm   Post subject: (No subject)

code:

var col:int:=1
for x:0..100
colour (col)
put"1"..
col:=col+1
end for


try that... most basic way i can explain it to you Very Happy

so everytime it loops (with the for loop)
col (which starts off as colour1) turns into colour 2...

with that note...
its easy then...
just put a getch (left key or right key)
then
if key = leftkey then
col :=col-1
elsif key = rightkey then
col := col+1
end if

easy.Razz
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  [ 3 Posts ]
Jump to:   


Style:  
Search: