Question
Require Java At least you game should include the following required components: The introduction screen which shows the title of your game and how to
Require Java
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
Screenshot
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
**Code 1**
// 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
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
{
Bubble b = (Bubble)pieces.get(i); // get the current piece
if (b.diameter
{
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();
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------
**Code 2**
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 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
if (y + diameter/2 > height) { y = height - diameter/2; vy *= -1; } else if (y - diameter/2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started