Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Since the advent of polygons to draw game objects and move gaming fully into thr

ID: 3685565 • Letter: S

Question

Since the advent of polygons to draw game objects and move gaming fully into three dimensions, there has been much debate about whether certain games would be better using sprites instead of polygons. For instances, many "2D" fighting games, games in which players only move in two dimensions, are moving from traditional hand-drawn sprites to rendered 3D models using polygons. Choose a game that uses one of these techniques (polygons or sprites), and detail why you think it would be better if it used the other. Reading the posts from the other students, reply to at least two and describe whether you agree or disagree with them.

Explanation / Answer

import java.util.*; import javax.swing.*; public class CoinFlipTest { public static void main(String[] args) { int select, rand, result; String selectvalues[] = {"Heads", "Tails"}; String coinSides=null, userGuess=null; /** Instantiate an array list for storing outcomes. **/ ArrayList outcomes = new ArrayList(); for (int i=0; i 0 } else { userGuess = "wrong"; outcomes.add(1); // if wrong => 1 } /** Display a result. **/ JOptionPane.showMessageDialog(null, "The result is " + coinSides + "! " + "Your guess is " + userGuess +"!", "Result", JOptionPane.INFORMATION_MESSAGE); } /** Display the odds **/ JOptionPane.showMessageDialog(null, "Your odds of getting the right guess are " + calculateOdds(outcomes), "Your Odds", JOptionPane.INFORMATION_MESSAGE); } /** Generate a random value for flip of a coin. **/ private static int generateRandomValue() { int r = (int) (Math.random()*2); return r; } /** Calculate user odds. **/ private static float calculateOdds(ArrayList list) { int numOfRightAnswers=0, numOfWrongAnswers=0; Iterator it = list.iterator(); while(it.hasNext()) { Integer e = (Integer) (it.next()); if (e == 0) { numOfRightAnswers++; } else { numOfWrongAnswers++; } } // odds = the number of desirable outcomes/the number of undesirable outcomes return (float) numOfRightAnswers/numOfWrongAnswers; } }