Make them infect each other!
For the last step we will code the dots to sense when they touch another dot and to infect them depending on the colour.
Red infects green (so green changes to red)
Green infects blue (so blue changes to green)
Blue infects red (so red changes to blue)
Add the following code underneath the if on edge, bounce block, pay careful attention to how the if then blocks are 'nested' inside each other.
when I start as a clone
repeat (pick random (1) to (3)) // there are only 3 costumes
go to (random position v)
point in direction (pick random (0) to (359))
move (3) steps
if on edge, bounce // insert the new code below this
if < color [#ff6666] is touching [#4d86c1] ?> then // use the eye dropper tool to select the colours
switch costume to (blue v)
if < color [#49b655] is touching [#ff6666] ?> then
switch costume to (red v)
if < color [#4d86c1] is touching [#49b655] ?> then
switch costume to (green v)
Once you've added this code click the green flag to test that it works. The 100 dots should appear and move around infecting each other until one colour wins!!
Show: How to choose a colour
Some of the sensing blocks allow you to set a colour to decide what they should do.
< touching color [#3e7144] ?>
< color [#ff6666] is touching [#4d86c1] ?>
You can choose which colour to use by clicking on the colour in the block and either using 'Color', 'Saturation' and 'Brightness' sliders to set the color.
Or you can use the eye dropper tool to choose a colour.