Create a sketch that defines a class called tribble

Assignment Help JAVA Programming
Reference no: EM131514146

Assignment: The Trouble with Tribbles

Goal

The purpose of this assignment is to create oodles and oodles of Tribbles.

Assignment

Your assignment is to create a sketch that defines a class called "Tribble". A Tribble is a small fuzzy creature kept as a cute pet that breeds quickly. Your sketch should create hundreds of instances of Tribbles around the screen and show them doing their thing. Define methods and instance variables for the class Tribble as appropriate.

Tribbles look like small fuzzy blobs. You can start by drawing them as circles, but your final sketch should show your interpretation of what "fuzzy" means. Tribbles spend most of their time sleeping (not moving). Every five seconds they wake up and get excited and vibrate for two seconds (horizontally by 1 pixel each frame, randomly), then settle down and continue sleeping.

Each instance of Tribble should be on its own schedule of vibration and should start at a random location on the screen. Optional: give each Tribble a random color.

Timed Behavior

Each Tribble should have a boolean instance variable to indicate whether it is asleep or excited. It will also probably need some integer counts for timing so you know how long it has been asleep or excited.

Sequence

• Start with one Tribble. Define a simple class.
• Get simple drawing, random location, and setup done.
• Add the "excited" behavior (assume it is excited all the time).
• Add the sleep-wakeup timed behavior using your integer instance variables.
• Make the drawing better (fuzzier)
• Declare and initialize an array of 5 Tribbles
• Create all the instances to fill up your array (passing random locations and other values to the constructor)
• Update your draw() function to loop through and draw all the Tribbles and do any other calls needed
• Check that the sleeping-wakeup behavior is correct
• Check that all the tribbles are not synchronized (pass random integer counts to constructor to start them in different states)
• Increase the array size to 200

Submission

Submit your zipped pde file directly here to eCommons.

0.5 Did they submit a Processing sketch?
0.5 Does the sketch run?
0.5 Is the code organized and clean?
0.5 Does the code have proper comments?
1.5 200 tribbles are drawn using array.
1.0 Tribbles generate at random positions.
1.5 The tribbles are not synchronized (they start in different states).
1.5 Every five seconds tribbles wake up and get excited.
1.5 In excited state, tribbles vibrate for two seconds (horizontally by 1 pixel each frame, randomly) before settling down and continuing to sleep.
1.0 Tribbles are drawn with an interpretation of "fuzzy". They are not just drawn as circles.

Example

Zoog zoog;

void setup() {
size(200,200);
smooth();
zoog = new Zoog(100,125,60,60,16);
}
void draw() {
background(255);
// mouseX position determines speed factor
float factor = constrain(mouseX/10,0,5);
zoog.jiggle(factor);
zoog.display();
}
class Zoog {
// Zoog's variables
float x,y,w,h,eyeSize;
// Zoog constructor
Zoog(float tempX, float tempY, float tempW, float tempH, float tempEyeSize) {
x = tempX;
y = tempY;
w = tempW;
h = tempH;
eyeSize = tempEyeSize;
}

// Move Zoog
void jiggle(float speed) {
// Change the location of Zoog randomly
x = x + random(-1,1)*speed;
y = y + random(-1,1)*speed;
// Constrain Zoog to window
x = constrain(x,0,width);
y = constrain(y,0,height);
}
// Display Zoog
void display() {
// Set ellipses and rects to CENTER mode
ellipseMode(CENTER);
rectMode(CENTER);
// Draw Zoog's arms with a for loop
for (float i = y - h/3; i < y + h/2; i + = 10) {
stroke(0);
line(x-w/4,i,x + w/4,i);
}
// Draw Zoog's body
stroke(0);
fill(175);
rect(x,y,w/6,h);
// Draw Zoog's head
stroke(0);
fill(255);
ellipse(x,y-h,w,h);
// Draw Zoog's eyes
fill(0);
ellipse(x-w/3,y-h,eyeSize,eyeSize*2);
ellipse(x + w/3,y - h,eyeSize,eyeSize*2);
// Draw Zoog's legs
stroke(0);
line(x - w/12,y + h/2,x - w/4,y + h/2 + 10);
line(x + w/12,y + h/2,x + w/4,y + h/2 + 10);
}
}

Reference no: EM131514146

Questions Cloud

Explain the trends that you observed with each company : Explain the trends that you observed with each company. To what could you attribute the increases or decreases in each company's trend(s)?
Different types of brute force attacks : Write a 1- to 2 page paper in which you present the two (2) different types of brute force attacks.
Compute the minimum time between adjacent pulses : Describe CSMA/CA protocol for multiple access used by WLANs. Compute the minimum time between adjacent pulses. Compute the maximum time between adjacent pulses.
Summarize the footprinting analysis : Summarize the footprinting analysis of the company you selected.
Create a sketch that defines a class called tribble : Your assignment is to create a sketch that defines a class called "Tribble". A Tribble is a small fuzzy creature kept as a cute pet that breeds quickly.
Aspects of the industry in presentation : Choose any web-based travel service that you want. Include information about the following aspects of the industry in your presentation:
How is market size measured in the paper : Econometrics 120C STATA Assignment. Market size is widely considered to be an important determinant of R&D expenditures. How is market size measured in paper
How long does the crime occur before it is discovered : How long does the crime occur before it is discovered? How is it discovered and who/why/how is the crime discovered?
Discuss the key process that a forensic analyst could use : From the second e-Activity, discuss the key process that a forensic analyst could use in order to preserve the verifiable integrity of digital evidence.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd