Ask Java Expert


Home >> Java

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);
}
}

Java, Programming

  • Category:- Java
  • Reference No.:- M92322873

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As