A HUGE THANK YOU IN ADVANCE FOR THE HELP!! C++ Class- INTRO TO DATA STRUCTURES -
ID: 3576175 • Letter: A
Question
A HUGE THANK YOU IN ADVANCE FOR THE HELP!!
C++ Class- INTRO TO DATA STRUCTURES - USING CORONA SDK!!
This will be another lua game. We will be using the Corona simulator. The original game was written by Gary Sims for Android Authority
Here are the rules for the game as it is.
You start out with no points, the goal is to get to 500 points. If your score gets below zero, you lose.
There are three kinds of balloons.
-Red: If you click on it, 100 points are added to your score, and a little “Boom” appears. If you miss it, one point is taken from your score.
-Green: if you click on it, 10 points are added to your score, nothing appears. If you miss it, one point is taken from your score.
-Black: If you click it, your score it cut in half, a little “Ouch!” appears, but if you miss it, nothing is taken from your score.
This is how I would like you to revise the game…
The basic rules remain the same. You start out with no points, the goal is to get to 500 points. If your score gets below zero, you lose.
Red: don’t change it. Green: Have the “Boom” appear when it is clicked. (Keep it the same otherwise.)
Black: Keep it the same.
Yellow: Yes, yellow, that’s the main change. Add a yellow balloon (the image file “yellow.png”, is included.)
Around half of the time, when you click on the yellow balloon, it will add 10 points to your score, some of the time it will take away 10 points. If you miss it, one point will be taken away. Have the “boom” appear when the points are added, and “Ouch!” when they are taken away.
There are at least two ways to go about this, you could use a random number generator, or you can make two different kinds of yellow balloons. Here is what you will get, a zip file, game 2.zip. It is in the course files folder.
Explanation / Answer
If the game should be in Android,we have to take an integer to store the points which always chages after every balloons clicked.
The logic should be like:
Int points = 0;
Button blackBalloon;
Button greenBalloon;
Button redBalloon;
Button yellowBalloon;
blackBalloon = (Button) findViewById(R.id.black);
redBalloon = (Button) findViewById(R.id.red);
yellowBalloon = (Button) findViewById(R.id.yellow);
greenBalloon = (Button) findViewById(R.id.green);
blackBalloon.setOnClickListener(new OnClicklistener(
public void onClick(){
points = points/2;
builder.setMessage("OUCH!!");
if( points < 0)
Toast.makeText(context,"GAME OVER",Length.long).show;
}
));
greenBalloon.setOnClickListener(new OnClicklistener(
public void onClick(){
points = points + 10;
if( points < 0)
Toast.makeText(context,"GAME OVER",Length.long).show;
}
));
redBalloon.setOnClickListener(new OnClicklistener(
public void onClick(){
points = points + 100;
builder.setMessage("BOOM!!");
if( points < 0)
Toast.makeText(context,"GAME OVER",Length.long).show;
}
));
yellowBalloon.setOnClickListener(new OnClicklistener(
public void onClick(){
if(cond1)
points = points + 10;
else
points = points - 10;
if( points < 0)
Toast.makeText(context,"GAME OVER",Length.long).show;
}
));
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.