Computer Science Canada

Help with colour changing

Author:  RobertCoombs [ Fri May 15, 2009 9:39 am ]
Post subject:  Help with colour changing

I'm currently working on a project for my Grade 10 Comp. Eng. class and I need help making the blue circles on the picture to turn red when I click on them and turn back blue when clicked again. Any help would be appreciated.

Thanks in Advance,
RobertCoombs

The Code:

Turing:
% Outline
Draw.ThickLine (550, 100, 600, 200, 10, black)
Draw.ThickLine (100, 100, 50, 200, 10, black)
Draw.ThickLine (100, 100, 550, 100, 10, black)
Draw.ThickLine (50, 200, 600, 200, 10, black)

% Top Pin Holes

drawfilloval (115, 175, 10, 10, black)
drawfilloval (150, 175, 10, 10, black)
drawfilloval (185, 175, 10, 10, black)
drawfilloval (220, 175, 10, 10, black)
drawfilloval (255, 175, 10, 10, blue)
drawfilloval (290, 175, 10, 10, blue)
drawfilloval (325, 175, 10, 10, blue)
drawfilloval (360, 175, 10, 10, blue)
drawfilloval (395, 175, 10, 10, blue)
drawfilloval (430, 175, 10, 10, blue)
drawfilloval (465, 175, 10, 10, blue)
drawfilloval (500, 175, 10, 10, blue)
drawfilloval (535, 175, 10, 10, black)

% Bottom Pin Holes

drawfilloval (135, 130, 10, 10, black)
drawfilloval (170, 130, 10, 10, black)
drawfilloval (205, 130, 10, 10, black)
drawfilloval (240, 130, 10, 10, black)
drawfilloval (275, 130, 10, 10, black)
drawfilloval (310, 130, 10, 10, black)
drawfilloval (345, 130, 10, 10, black)
drawfilloval (380, 130, 10, 10, black)
drawfilloval (415, 130, 10, 10, black)
drawfilloval (450, 130, 10, 10, black)
drawfilloval (485, 130, 10, 10, black)
drawfilloval (520, 130, 10, 10, black)




Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]

Author:  BigBear [ Fri May 15, 2009 1:45 pm ]
Post subject:  RE:Help with colour changing

So you need to use Mouse.Where(x,y,button)

and check if the mouse is over the position of the circle and that button > 0 meaning clicked

and if it has been clicked before or what color it is if blue then re draw red

if red and mouse stuff then draw black

Author:  tjmoore1993 [ Fri May 15, 2009 3:29 pm ]
Post subject:  Re: Help with colour changing

Like BigBear suggested

Turing:

var X, Y, CLICK : int
loop % needed so that the mouse information is updated at a constant rate
Mouse.Where (X, Y, CLICK)

if CLICK = 1 then % if click is true basically
% Collision detection inside here
end if

end loop


Check out the Turing Tutorial section for Perfect Circle Collision Smile


: