Whoa! lots of stuff going on here: loops, arrays, ifs, variables... It's OK if this is all new to you - even if you don't understand everything in a program yet, you can still customize it! The "Learn More" sections will give you some ideas for changing this game. I'll try to add a more gentle introduction to all these things later, but for now, you can read some of the references below, or check out Pencil Code Gym for non-dog-centric tutorials!
Speed it up!
In this game, the dog is supposed to tap on the blue rectangle. The turtle draws 4 new rectangles at the beginning of each round. But the turtle is kind of slow - plus, we don't really need to see it for this game! Try removing st() (on line 2), and in its place, putting speed 100 or even speed Infinity!
Change the colors!
On line 12, we set boxColors to be an array of four colors. If you change the colors in the array, the turtle will draw your new colors! Note: if you use less than 4 colors, the turtle will get confused. If you use more than 4, it will only use the first 4. Try it and see! You can also change which color is the "correct" one by changing which color we use in the if on the second-to-last line.
Dogs and colors
Dogs are red-green colorblind (or something like it). They are pretty good at blue and yellow, though!
Learn More
# show the turtle, so we know what it's doing:
st()
# define some useful numbers and colors:
boxSize = max(totalWidth, totalHeight)/2
boxCenters = [
[-boxSize/2, -boxSize/2]
[-boxSize/2, boxSize/2]
[boxSize/2, boxSize/2]
[boxSize/2, -boxSize/2]
]
boxColors = [blue, yellow, white, black]
# on round start, randomize box position and draw 4 boxes
onRoundStart ->
cg() # clear graphics
shuffle boxCenters # randomize the order of the box centers
for i in [0..3] # for each of the 4 box centers/colors
moveto boxCenters[i] # move to the current center
box boxColors[i], boxSize # draw a box of the current color
# on tap, see if the tap was on blue. if yes, feed the dog!
tap ->
if lasttap.touches blue
feed()