Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with my code, I am figuring out how to create a balloon game and I need help, I have photos to also help

Need help with my code, I am figuring out how to create a balloon game and I need help, I have photos to also help with what is needed to do, The code should be written in java with the template, Please use the java template and code have added. Also note to please use the constructor and fields I am using. Not HTML or CSS, just java pleaseimage text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

import ecs100.*; import java.util.*; import java.awt.Color;

/** YOUR DOCUMENTATION COMMENT */ public class BalloonGame {

private int numBalloons = 20; // default. private ArrayList active; // The list of active balloons private ArrayList burst; // The list of burst balloons

// Fields /*# YOUR CODE HERE */

/** YOUR DOCUMENTATION COMMENT */ public void setupGUI(){ UI.setWindowSize(600,600); UI.addButton("New Game", this::restartGame); UI.addButton("New Game", this::restartGame); UI.addButton("Lock Score", this::lockScore); UI.setMouseListener(this::doMouse); UI.setDivider(0.0); }

/** YOUR DOCUMENTATION COMMENT */ public void restartGame(){ /*# YOUR CODE HERE */

}

/** YOUR DOCUMENTATION COMMENT */ public void doMouse(String action, double x, double y){

}

public void lockScore(){ } public void setSize(){ } public void findBalloonOn(double x, double y){ } public void calculateScore(){ } public void redraw(){ } public void endGame(){ }

public static void main(String[] arguments){ BalloonGame bg = new BalloonGame(); bg.setupGUI(); }

}

The user interface of Bal loonGame has two buttons: - the New Game button should start a new game; - the Lock Score button will stop the current game and update the highest score if the current score is better. The program also responds to mouse clicks -.- clicking on a Balloon should make it grow a bit, but if it touches another balloon, they are both "burst". The score is updated on each step and displayed in the text message panel (using UI . printMessage ( ...)). Clicking on space between the balloons does nothing. The Bal loon class is written for you completely, and you do not need to change it. Make sure you read it carefully so that you know what methods you can call on a Bal loon object. Core You are to complete the following: - The se tupgUI () method to set up the interface with two buttons and listening to the mouse. - A restartGame () method which starts a new game by constructing a new set of active Balloons at random positions. Note that it is OK for the core if some of the Balloons are initially touching or overlapping. - A doMouse (...) method to respond to mouse releases. This is the core of the game. It must find the Balloon (if any) at the given mouse position. If there is one, it must expand the balloon check whether it is now touching any another balloon. If it is touching, it should pop the two balloons. It should then calculate and report the new score. You should not try to put everything inside the restartGame and doMouse methods: you should make additional "helper" methods. You can design it how you choose, but some example methods that might be helpful are - setsize(double size) - findBalloon0n(double x, double y) - findTouching (Balloon balloon) - calculatescore() - redraw() - endGame() Make sure you document all your methods clearly. Run the demo and make sure you know what you are required to do. Note also that there are useful methods in the Bal loon class; do not duplicate their code. Completion - Add a slider to control the number of balloons for the next game. - The doMouse method should check whether there is just one or no active Balloons. If so, it should end the game and store the score in a highscore field, if the current score is better than the current highest score. It should also report the highest score. - Respond to the "Lock Score" button. Fix restartGame to ensure that none of the balloons is overlapping at the start of the game. This game does not remain interesting for very long. Can you improve on the game design to make a more attention-keeping version? Some possible ideas: - Improve the game mechanics. Eg, if you expand a balloon and it touches more than one balloon, the demo version only pops one of the touched balloons. Is this a good decision? would the game be improved by making it burst all the balloons it is touching? - Make different kinds of balloons. Eg, some balloons might "explode" and burst the three closest balloons around them when the player clicks the balloon. (Is it better or worse for the player to know which balloons are exploders?) - Make some balloons expand as long "tube balloons" rather than circles. - You might give the user a limited number of "nudges" that would allow them to drag a balloon by a small distance. - Rather than the user clicking balloons to make them expand, make a little fly that runs around the screen, which the user controls with keys. If the fly touches a balloon, the balloon will expand (and push the fly away so it doesn't expand it again immediately)

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

Students also viewed these Databases questions

Question

Evaluate employees readiness for training. page 275

Answered: 1 week ago