Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will use your imagination to develop a game based on the skeleton code. You can feel free to add any elements

In this assignment, you will use your imagination to develop a game based on the skeleton code.

You can feel free to add any elements to this game and make it fun.

At least you game should include the following required components:

The introduction screen which shows the title of your game and how to start your game. (10 points)

The scheme that decides the outcome of the game (e.g. time-based or score-based or other). (20 points)

Resources that you can use to earn points or health or other factors that can affect the game progress/outcome. (30 points)

The factors that can make the player lose points, or health, or other factors that can affect the game progress/outcome. (30 points)

The resulting screen shows you win or lose the game. It may also show how to replay the game. (10 points)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

--->In order to do this assigment you have to installed processor.com

https://processing.org/

download it and installed it

--->The computer langauge is Java

----> Code 1 and Code 2 will be provided it for it.

Code 1 is called boomshine

Code 2 is called bubble

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Code 1 and

// adapted from the "BouncyBubbles" example.

int numBubbles = 40; // initial bubble count

final int BROKEN = -99; // code for "broken", may have other states later

final int MAXDIAMETER = 120; // maximum size of expanding bubble

ArrayList pieces; // all the playing pieces

void setup()

{

pieces = new ArrayList(numBubbles);

size(640, 640);

noStroke();

smooth();

for (int i = 0; i < numBubbles; i++)

pieces.add(new Bubble(random(width), random(height), 30, i, pieces));

}

void mousePressed()

{

// on click, create a new burst bubble at the mouse location and add it to the field

Bubble b = new Bubble(mouseX,mouseY,2,numBubbles,pieces);

b.burst();

pieces.add(b);

numBubbles++;

}

void draw()

{

background(0);

for (int i = 0; i < numBubbles; i++)

{

Bubble b = (Bubble)pieces.get(i); // get the current piece

if (b.diameter < 1) // if too small, remove

{

pieces.remove(i);

numBubbles--;

i--;

}

else

{

// check collisions, update state, and draw this piece

if (b.broken == BROKEN) // only bother to check collisions with broken bubbles

b.collide();

b.update();

b.display();

}

}

}

-------------------------------------------------------------------------------------------------

class Bubble { float x, y; float diameter; float vx = 0; float vy = 0; int id; int broken = 0; float growrate = 0; ArrayList others; Bubble(float xin, float yin, float din, int idin, ArrayList oin) { x = xin; y = yin; diameter = din; growrate = 0; id = idin; vx = random(0,100)/50. - 1.; vy = random(0,100)/50. - 1.; others = oin; } void burst() { if (this.broken != BROKEN) // only burst once { this.broken = BROKEN; this.growrate = 2; // start it expanding } } void collide() { Bubble b; // check collisions with all bubbles for (int i = 0; i < numBubbles; i++) { b = (Bubble)others.get(i); float dx = b.x - x; float dy = b.y - y; float distance = sqrt(dx*dx + dy*dy); float minDist = b.diameter/2 + diameter/2; if (distance < minDist) { // collision has happened if ((this.broken == BROKEN) || (b.broken == BROKEN)) { // broken bubbles cause others to break also b.burst(); } } } } void update() { if (this.broken == BROKEN) { this.diameter += this.growrate; if (this.diameter > MAXDIAMETER) // reached max size this.growrate = -0.75; // start shrinking } else { // move via Euler integration x += vx; y += vy; // the rest: reflect off the sides and top and bottom of the screen if (x + diameter/2 > width) { x = width - diameter/2; vx *= -1; } else if (x - diameter/2 < 0) { x = diameter/2; vx *= -1; }

if (y + diameter/2 > height) { y = height - diameter/2; vy *= -1; } else if (y - diameter/2 < 0) { y = diameter/2; vy *= -1; } } } void display() { // how to draw a bubble: set to white with some transparency, draw a circle fill(255, 204); ellipse(x, y, diameter, diameter); } }

-----------------------------------------------------------------------

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago