Create a new Open Processing sketch.
Open your creature code where you have incorporated the variables and it is now set on mouseX and mouseY. This is the sketch named like: “MyCreature_(name)__XY”.
Save a Fork and name it RandomCreature.
Do the following:
- Take out the mouseX and mouseY and replace them with numeric values.
- Change the frame rate to 5 by adding a call to the
frameRatefunction inside of
setup(). The call to
frameRateshould look like this:
- Choose a part of your creature that you want to randomly change color.
- Declare variables R, G, B for the part you want to have change color randomly such as the eyes, legs, or whatever. (for example:
var eyeR =random(255); var eyeG = random(255); var eyeB = random(255);.) Declare these variables just one line above the part you want to change. Then, replace the arguments for the fill with your new variable names.
Does your creature now have a body part that changes colors randomly?
To have your creature begin in the center of the screen, inside the
setup() function, set x to be equal to one-half the width of the screen:
x = windowWidth/2;
Then, let’s make your creature begin off the screen on the y. What would you have to do with the y variable to accomplish that? [Hint: it would have to be declared in the setup also] Answer this question as a comment at the bottom of your program.
Add an increment that would bring your creature from the bottom of the screen up on the y-axis.
Go back to: Random