Question
Can someone help me using java create the following list of functionalities programs listed below for the atari breakout game. For a reference of the
Can someone help me using java create the following list of functionalities programs listed below for the atari breakout game.
For a reference of the type of game use https://www.atari.com/arcade#!/arcade/superbreakout/play
class Ball extends GameObject { PVector speed; Ball(float inX, float inY, PVector inSpeed) { super(inX, inY, 25, 25); type = OBJECT_TYPE.BALL; speed = inSpeed; } void Update() { // Check for collision if(x + w/2 > width || x - w/2 height) { gameMan.BallKilled(); } // Adjust x,y by speed x += speed.x; y += speed.y; box.Update(x - w/2,y - h/2); // Draw at x,y fill(0, 0, 255); ellipse(x,y,w,h); } void Delete() { super.Delete(); ballList.remove(this); } void OnCollision(GameObject obj) { if(obj.type == OBJECT_TYPE.PADDLE) { // Work here Paddle p = (Paddle)obj; // When ??????? //speed.x *= -1; float paddleMidX = mouseX; // float paddleMidX = p.x + p.w/2; // speed? if( x >= paddleMidX) { speed.x = abs(speed.x); } else { speed.x = -abs(speed.x); } speed.y = -abs(speed.y); } else if(obj.type == OBJECT_TYPE.BRICK) { // Work here Brick b = (Brick)obj; speed.y = abs(speed.y); } else { speed.y *= -1; } } } GameManager gameMan;
void setup() { size(800, 600); gameMan = new GameManager(); }
void draw() { background(200); gameMan.Update(); }
// Debug tool void keyPressed() { if(key == 't') { if(brickList.size() > 0) { Brick b = brickList.get(0); b.Delete(); } } }
class Brick extends GameObject { Brick(float inX, float inY, float inW, float inH) { super(inX, inY, inW, inH); type = OBJECT_TYPE.BRICK; } void Update() { box.Update(x,y); fill(255, 0, 0); rect(x,y,w,h); } void Delete() { super.Delete(); brickList.remove(this); } void OnCollision(GameObject obj) { this.Delete(); } }
void RunCollisions() { for(int i = 0; i gameObjectList; ArrayList
class GameManager { int lives; int score; GameManager() { lives = 3; gameObjectList = new ArrayList
abstract class GameObject { float x, y, w, h; Hitbox box; OBJECT_TYPE type; GameObject(float inX, float inY, float inW, float inH) { x = inX; y = inY; w = inW; h = inH; box = new Hitbox(x,y,w,h); gameObjectList.add(this); } abstract void Update(); abstract void OnCollision(GameObject obj); void Delete() { gameObjectList.remove(this); } }
class Hitbox { boolean debugMode = true; float x, y, w, h; Hitbox(float inX, float inY, float inW, float inH) { x = inX; y = inY; w = inW; h = inH; } void Update(float inX, float inY) { x = inX; y = inY; if(debugMode == true) { stroke(0,255, 0); noFill(); rect(x, y, w, h); } } }
boolean Collision(Hitbox a, Hitbox b) { float thisTop = a.y; float thisBot = a.y + a.h; float thisLeft = a.x; float thisRight = a.x + a.w; float otherTop = b.y; float otherBot = b.y + b.h; float otherLeft = b.x; float otherRight = b.x + b.w; boolean output = true; if( thisBot otherBot) { output = false; } else if( thisRight otherRight) { output = false; } return output; }
class Paddle extends GameObject {
Paddle(float inX, float inY) { super(inX, inY, 200, 20); type = OBJECT_TYPE.PADDLE; } void Update() { x = mouseX - w/2; box.Update(x,y); fill(0, 0, 255); rect(x,y,w,h); } void OnCollision(GameObject obj) { } }
Lives & Score o At the bottom of the screen l want you display a lives and score to the player. (use the text functionality from the TextAdventure) o Lives Player should start with 3 lives If player loses 3 lives the game starts over Score is reset to 0 o Score Player gets points destroying bricks and beating levels Multiple levels o If the player destroys all the bricks a new level loads in with new bricks (change the color of the bricks as a visual que) o Make 3 levels Correct Ball Bounce o The ball should correctly bounce of the bricks If the ball hits the side of a brick it inverts the ball's x-velocity If the ball hits the top/bottom of a brick it inverts the ball's y velocityStep 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