Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Keep this line as is, except for renaming the class
- class KatiemObj extends AnimatedObject {
- float fishSize;
- float xC;
- float yC;
- int direction;
- int sink;
- // Constructor
- KatiemObj(float size) {
- fishSize = size;
- xC = random(1,800-fishSize);
- yC = random(1,600-fishSize);
- direction = (int)random(0,2);
- sink = (int)random(0,2);
- }
- // Displays the creature
- void display() {
- fill(#FF8D8C);
- if(direction == 0) //rightFish
- {
- ellipse(xC,yC,fishSize,fishSize/2);
- fill(0);
- ellipse(xC + fishSize/4,yC, fishSize/10,fishSize/10);
- }
- else
- {
- ellipse(xC,yC,fishSize,fishSize/2);
- fill(0);
- ellipse(xC - fishSize/4,yC, fishSize/10,fishSize/10);
- }
- }
- // Moves the creature
- void move() {
- if(sink == 0)
- {
- yC = yC - random(.25);
- if(yC < fishSize/4)
- sink = 1;
- }
- else
- {
- yC = yC + random(.25);
- if(yC >height - fishSize/4-40)
- sink = 0;
- }
- if(direction == 0)
- {
- xC = xC + .5;
- if(xC > width - fishSize)
- direction = 1;
- }
- else
- {
- xC = xC - .5;
- if(xC < fishSize)
- direction = 0;
- }
- }
- }
- /** If you want to enhance the tank background
- * to showcase your own project, you can put
- * drawing code in this function, which is called
- * near the start of the draw() function above.
- */
- void drawTankBackground() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement