/******************************* / Wheel.java / Written by Timothy M. Bailey / Started: March 31, 1998 / Updated: May 5, 1998 / / Wheel of Fortune applet for cs406 class with Dr. Roger Webster / ********************************/ import java.awt.*; import java.applet.*; import java.net.*; import java.util.*; public class Wheel extends Applet implements Runnable { TitlePanel titlePanel; PuzzlePanel puzzlePanel; PlayerPanel playerPanel; ButtonPanel buttonPanel; CardPanel cardPanel; SpinPanel spinPanel; public static final int DONE = 0; public static final int SPIN = 1; int num_puzzles = 88; int num_amounts = 30; int puzzle1, puzzle2, puzzle3, puzzle4, current_puzzle; int vowel_count, letter_count, state, vowel_bell, intro_clip; int curr_spin, gameMoney, matchMoney; int intAmount[] = new int[num_amounts]; Image titleImage, noiseImage, grayImage, pointer, guessx, guesso; Image letters[] = new Image[27]; Image Amount[] = new Image[num_amounts]; Image puzzle_images[][] = new Image[8][15]; char puzzle[][] = new char[8][15]; String puzzles[] = new String[num_puzzles]; String type[] = new String[num_puzzles]; String playerName = new String(""); AudioClip ding, wrong, start, intro, vowel, bankrupt, solve, spin; PuzzleDialog pd; Thread th; Random rand = new Random(), rand2 = new Random(); Frame f = new Frame(""); public void init() { int i, j; LoadSounds(); intro_clip = 0; // intro.play(); LoadImages(); GetPuzzles(); this.setBackground(new Color(11,111,20)); LoginWindow login = new LoginWindow(f, "Wheel of Treasures", this); titlePanel = new TitlePanel(titleImage); puzzlePanel = new PuzzlePanel(puzzle_images); playerPanel = new PlayerPanel(guessx, guesso, playerName); buttonPanel = new ButtonPanel(); cardPanel = new CardPanel(); spinPanel = new SpinPanel(Amount[0], pointer); this.add(titlePanel); this.add(puzzlePanel); this.add(playerPanel); this.add(buttonPanel); this.add(spinPanel); this.add(cardPanel); this.show(); this.repaint(); matchMoney = 0; playerPanel.setMatchMoney(matchMoney); state = DONE; current_puzzle = puzzle1; SetupPuzzle(current_puzzle); } public void start() { if (th == null) { th = new Thread(this); th.start(); } } public void destroy() { try { if (pd.isVisible()) { pd.hide(); pd.dispose(); } } catch (NullPointerException ex) {} } public void run() { } public void paint (Graphics g) { titlePanel.repaint(); puzzlePanel.repaint(); playerPanel.repaint(); buttonPanel.repaint(); cardPanel.repaint(); spinPanel.repaint(); } public void LoadImages() { int i, j; char ch; URL docBase; docBase = getDocumentBase(); MediaTracker tracker = new MediaTracker(this); titleImage = getImage(docBase, "./images/logo2.jpg"); tracker.addImage(titleImage,0); noiseImage = getImage(docBase, "./images/noise.jpg"); tracker.addImage(noiseImage,0); grayImage = getImage(docBase, "./images/gray.jpg"); tracker.addImage(grayImage,0); pointer = getImage(docBase, "./images/pointer.jpg"); tracker.addImage(pointer,0); guessx = getImage(docBase, "./images/guessx.jpg"); tracker.addImage(guessx,0); guesso = getImage(docBase, "./images/guesso.jpg"); tracker.addImage(guesso,0); Amount[0] = getImage(docBase, "./images/100.jpg"); intAmount[0] = 100; Amount[1] = getImage(docBase, "./images/200.jpg"); intAmount[1] = 200; Amount[2] = getImage(docBase, "./images/250.jpg"); intAmount[2] = 250; Amount[3] = getImage(docBase, "./images/300.jpg"); intAmount[3] = 300; Amount[4] = getImage(docBase, "./images/350.jpg"); intAmount[4] = 350; Amount[5] = getImage(docBase, "./images/400.jpg"); intAmount[5] = 400; Amount[6] = getImage(docBase, "./images/450.jpg"); intAmount[6] = 450; Amount[7] = getImage(docBase, "./images/500.jpg"); intAmount[7] = 500; Amount[8] = getImage(docBase, "./images/750.jpg"); intAmount[8] = 750; Amount[9] = getImage(docBase, "./images/1000.jpg"); intAmount[9] = 1000; Amount[10] = getImage(docBase, "./images/1250.jpg"); intAmount[10] = 1250; Amount[11] = getImage(docBase, "./images/1500.jpg"); intAmount[11] = 1500; Amount[12] = getImage(docBase, "./images/2000.jpg"); intAmount[12] = 2000; Amount[13] = getImage(docBase, "./images/2500.jpg"); intAmount[13] = 2500; Amount[14] = getImage(docBase, "./images/bankrupt.jpg"); intAmount[14] = -1; Amount[15] = getImage(docBase, "./images/lose_a_turn.jpg"); intAmount[15] = 0; Amount[16] = Amount[0]; intAmount[16] = intAmount[0]; Amount[17] = Amount[0]; intAmount[17] = intAmount[0]; Amount[18] = Amount[1]; intAmount[18] = intAmount[1]; Amount[19] = Amount[1]; intAmount[19] = intAmount[1]; Amount[20] = Amount[2]; intAmount[20] = intAmount[2]; Amount[21] = Amount[2]; intAmount[21] = intAmount[2]; Amount[22] = Amount[3]; intAmount[22] = intAmount[3]; Amount[23] = Amount[3]; intAmount[23] = intAmount[3]; Amount[24] = Amount[4]; intAmount[24] = intAmount[4]; Amount[25] = Amount[5]; intAmount[25] = intAmount[5]; Amount[26] = Amount[6]; intAmount[26] = intAmount[6]; Amount[27] = Amount[7]; intAmount[27] = intAmount[7]; Amount[28] = Amount[14]; intAmount[28] = intAmount[14]; Amount[29] = Amount[15]; intAmount[29] = intAmount[15]; for (i=0; i<=15; i++) { tracker.addImage(Amount[i],0); } for (ch='a', i=0; ch<='z'; ch++, i++) { letters[i] = getImage(docBase, "./images/"+ch+".jpg"); tracker.addImage(letters[i], 0); } letters[i] = getImage(docBase, "./images/apos.jpg"); tracker.addImage(letters[i], 0); try { tracker.waitForID(0); } catch(InterruptedException e) { e.printStackTrace(); } } public void LoadSounds() { ding = getAudioClip(getCodeBase(), "./sounds/letter.au"); wrong = getAudioClip(getCodeBase(), "./sounds/wrong.au"); intro = getAudioClip(getCodeBase(), "./sounds/intro.au"); start = getAudioClip(getCodeBase(), "./sounds/start.au"); vowel = getAudioClip(getCodeBase(), "./sounds/vowel.au"); bankrupt = getAudioClip(getCodeBase(), "./sounds/bankrupt.au"); solve = getAudioClip(getCodeBase(), "./sounds/solve.au"); spin = getAudioClip(getCodeBase(), "./sounds/spin.au"); } public void GetPuzzles() { puzzles[0] = "game over hit shift and reload to start a new game."; type[0] = "Phrase"; puzzles[1] = "all roads lead to rome."; type[1] = "Phrase"; puzzles[2] = "most likely to succeed."; type[2] = "Phrase"; puzzles[3] = "christmas dinner with all the trimmings."; type[3] = "Phrase"; puzzles[4] = "six to one half a dozen to the other."; type[4] = "Phrase"; puzzles[5] = "throwing the baby out with the bath water."; type[5] = "Phrase"; puzzles[6] = "counting your chickens before they've hatched."; type[6] = "Phrase"; puzzles[7] = "as the crow flies."; type[7] = "Phrase"; puzzles[8] = "beating a dead horse."; type[8] = "Phrase"; puzzles[9] = "comparing apples and oranges."; type[9] = "Phrase"; puzzles[10] = "politics makes for strange bedfellows."; type[10] = "Phrase"; puzzles[11] = "indiana jones and the last crusade."; type[11] = "Title"; puzzles[12] = "doctor jekyll and mister hyde."; type[12] = "Title"; puzzles[13] = "the hunchback of notre dame."; type[13] = "Title"; puzzles[14] = "late night with david letterman."; type[14] = "Title"; puzzles[15] = "a christmas carol."; type[15] = "Title"; puzzles[16] = "the three musketeers."; type[16] = "Title"; puzzles[17] = "the gift of the magi."; type[17] = "Title"; puzzles[18] = "monty python and the holy grail."; type[18] = "Title"; puzzles[19] = "the adventures of huckleberry finn."; type[19] = "Title"; puzzles[20] = "the catcher in the rye."; type[20] = "Title"; puzzles[21] = "college dormitory."; type[21] = "Place"; puzzles[22] = "international airport."; type[22] = "Place"; puzzles[23] = "seattle washington."; type[23] = "Place"; puzzles[24] = "notre dame university."; type[24] = "Place"; puzzles[25] = "showboat casino in atlantic city."; type[25] = "Place"; puzzles[26] = "madison square garden."; type[26] = "Place"; puzzles[27] = "london england."; type[27] = "Place"; puzzles[28] = "mount rushmore."; type[28] = "Place"; puzzles[29] = "the canary islands."; type[29] = "Place"; puzzles[30] = "the sea of tranquility."; type[30] = "Place"; puzzles[31] = "country singer garth brooks."; type[31] = "Person"; puzzles[32] = "philadelphia flyers."; type[32] = "People"; puzzles[33] = "chevy chase."; type[33] = "Person"; puzzles[34] = "the people's court judge ed koch."; type[34] = "Person"; puzzles[35] = "gossip columnist liz smith."; type[35] = "Person"; puzzles[36] = "winston churchill."; type[36] = "Person"; puzzles[37] = "ernest hemingway."; type[37] = "Person"; puzzles[38] = "tarzan king of the apes."; type[38] = "Person"; puzzles[39] = "king henry the eighth."; type[39] = "Person"; puzzles[40] = "carly simon and garfunkle."; type[40] = "Before & After"; puzzles[41] = "chemistry teacher."; type[41] = "Occupation"; puzzles[42] = "washington monument."; type[42] = "Landmark"; puzzles[43] = "bottled water under the bridge."; type[43] = "Before & After"; puzzles[44] = "periodic table manners."; type[44] = "Before & After"; puzzles[45] = "children of the corn tortillas."; type[45] = "Before & After"; puzzles[46] = "greco roman wrestling."; type[46] = "Event"; puzzles[47] = "papal bull fighter."; type[47] = "Before & After"; puzzles[48] = "give me liberty or give me death."; type[48] = "Quotation"; puzzles[49] = "pat and daniel boone."; type[49] = "Same Name"; puzzles[50] = "lookout point of no return."; type[50] = "Before & After"; puzzles[51] = "pumpkin pie with whipped cream."; type[51] = "Things"; puzzles[52] = "apple macintosh computer."; type[52] = "Thing"; puzzles[53] = "chevrolet cavalier."; type[53] = "Thing"; puzzles[54] = "three piece suit."; type[54] = "Thing"; puzzles[55] = "four leaf clover."; type[55] = "Thing"; puzzles[56] = "the loch ness monster."; type[56] = "Thing"; puzzles[57] = "ninety mile an hour fastball."; type[57] = "Thing"; puzzles[58] = "internal combustion engine."; type[58] = "Thing"; puzzles[59] = "the great wall of china."; type[59] = "Thing"; puzzles[60] = "the stanley cup."; type[60] = "Thing"; puzzles[61] = "beggars can't be choosers."; type[61] = "Phrase"; puzzles[62] = "the only thing we have to fear is fear itself."; type[62] = "Quotation"; puzzles[63] = "oh my god the cubs win the pennant."; type[63] = "Quotation"; puzzles[64] = "four score and seven years ago."; type[64] = "Quotation"; puzzles[65] = "winona ryder truck."; type[65] = "Before & After"; puzzles[66] = "filing for bankruptcy."; type[66] = "Event"; puzzles[67] = "gold rush limbaugh."; type[67] = "Before & After"; puzzles[68] = "bud abbott and lou costello."; type[68] = "People"; puzzles[69] = "to be or not to be that is the question."; type[69] = "Quotation"; puzzles[70] = "go ahead make my day."; type[70] = "Quotation"; puzzles[71] = "stuck between a rock and a hard place."; type[71] = "Phrase"; puzzles[72] = "stuck in the middle with you."; type[72] = "Title"; puzzles[73] = "i get by with a little help from my friends."; type[73] = "Quotation"; puzzles[74] = "frankly scarlett i don't give a damn."; type[74] = "Quotation"; puzzles[75] = "little shop of horrors."; type[75] = "Title"; puzzles[76] = "supermodel kathy ireland."; type[76] = "Person"; puzzles[77] = "to bite off your nose to spite your face."; type[77] = "Phrase"; puzzles[78] = "can't see the forest for the trees."; type[78] = "Phrase"; puzzles[79] = "whipped cream of wheat."; type[79] = "Before & After"; puzzles[80] = "wealth of nations."; type[80] = "Title"; puzzles[81] = "communist manifesto."; type[81] = "Title"; puzzles[82] = "gone with the wind."; type[82] = "Title"; puzzles[83] = "a coney island hot dog."; type[83] = "Thing"; puzzles[84] = "falling asleep on the job."; type[84] = "Phrase"; puzzles[85] = "one flew over the cuckoo's nest."; type[85] = "Title"; puzzles[86] = "alfred hitchcock."; type[86] = "Person"; puzzles[87] = "twenty thousand leagues under the sea."; type[87] = "Title"; int nextPuzzle; // do random selection here. nextPuzzle = rand2.nextInt() % num_puzzles; if (nextPuzzle < 0) { nextPuzzle *= -1; } while (nextPuzzle == 0) { nextPuzzle = rand2.nextInt() % num_puzzles; if (nextPuzzle < 0) { nextPuzzle *= -1; } } puzzle1 = nextPuzzle; nextPuzzle = rand2.nextInt() % num_puzzles; if (nextPuzzle < 0) { nextPuzzle *= -1; } while ((nextPuzzle == puzzle1) || (nextPuzzle == 0)) { nextPuzzle = rand2.nextInt() % num_puzzles; if (nextPuzzle < 0) { nextPuzzle *= -1; } } puzzle2 = nextPuzzle; nextPuzzle = rand2.nextInt() % num_puzzles; if (nextPuzzle < 0) { nextPuzzle *= -1; } while ((nextPuzzle == puzzle1) || (nextPuzzle == puzzle2) || (nextPuzzle == 0)) { nextPuzzle = rand2.nextInt() % num_puzzles; if (nextPuzzle < 0) { nextPuzzle *= -1; } } puzzle3 = nextPuzzle; puzzle4 = 0; } public void SetupPuzzle(int puzzle_number) { char ch, word[] = new char[15]; int len, temp_count; int i, j, x, y; // clear the player panel of any garbage and reset the count playerPanel.spinWorth = ""; playerPanel.letterCount = ""; playerPanel.resetGuess(); playerPanel.repaint(); // if this is the first puzzle, make sure intro won't play anymore if (intro_clip == 0) { try { th.sleep(17000); intro_clip = 1; } catch (InterruptedException e) {} } // turn all letters into noise images to "clear" board for (i=0; i<8; i++) { for (j=0; j<15; j++) { puzzle_images[i][j] = noiseImage; puzzle[i][j] = ' '; } } puzzlePanel.repaint(); vowel_count = 0; letter_count = 0; vowel_bell = 0; // show the type of puzzle puzzlePanel.puzzleType = type[puzzle_number]; // layout the puzzle -- no words spanning 2 lines, etc. x = 0; y = 0; temp_count = 0; len = puzzles[puzzle_number].length(); for (i=0; i (15-x)) { x = 0; y++; } for (int w=x; w