commit 25c3d018051bd7de06e582d1633ee4a8e753eaaf parent baff240f93d3a2ab6ec262516fecb19311863495 Author: mpizzzle <michael.770211@gmail.com> Date: Fri, 1 Mar 2019 23:34:07 +0000 mv CaveGame files Diffstat:
48 files changed, 562 insertions(+), 601 deletions(-)
diff --git a/CaveGame/1ST ROOM.gif b/CaveGame/Assets/1ST ROOM.gif Binary files differ. diff --git a/CaveGame/AlbumArtSmall.jpg b/CaveGame/Assets/AlbumArtSmall.jpg Binary files differ. diff --git a/CaveGame/AlbumArt_{5A46157A-FA0D-4BB0-A4D7-98AC60E53D2A}_Large.jpg b/CaveGame/Assets/AlbumArt_{5A46157A-FA0D-4BB0-A4D7-98AC60E53D2A}_Large.jpg Binary files differ. diff --git a/CaveGame/AlbumArt_{5A46157A-FA0D-4BB0-A4D7-98AC60E53D2A}_Small.jpg b/CaveGame/Assets/AlbumArt_{5A46157A-FA0D-4BB0-A4D7-98AC60E53D2A}_Small.jpg Binary files differ. diff --git a/CaveGame/Folder.jpg b/CaveGame/Assets/Folder.jpg Binary files differ. diff --git a/CaveGame/GAME COMPLETE.gif b/CaveGame/Assets/GAME COMPLETE.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS A.gif b/CaveGame/Assets/GAMER PICKS A.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS B THEN A.gif b/CaveGame/Assets/GAMER PICKS B THEN A.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS B THEN B THEN A THEN B.gif b/CaveGame/Assets/GAMER PICKS B THEN B THEN A THEN B.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS B THEN B THEN A.gif b/CaveGame/Assets/GAMER PICKS B THEN B THEN A.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS B THEN B THEN B.gif b/CaveGame/Assets/GAMER PICKS B THEN B THEN B.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS B THEN B THEN C.gif b/CaveGame/Assets/GAMER PICKS B THEN B THEN C.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS B THEN B.gif b/CaveGame/Assets/GAMER PICKS B THEN B.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS B.gif b/CaveGame/Assets/GAMER PICKS B.gif Binary files differ. diff --git a/CaveGame/GAMER PICKS C.gif b/CaveGame/Assets/GAMER PICKS C.gif Binary files differ. diff --git a/CaveGame/Gamer picks b) then b) then a) then a) then a).gif b/CaveGame/Assets/Gamer picks b) then b) then a) then a) then a).gif Binary files differ. diff --git a/CaveGame/Gamer picks b) then b) then a) then a) then b).gif b/CaveGame/Assets/Gamer picks b) then b) then a) then a) then b).gif Binary files differ. diff --git a/CaveGame/Gamer picks b) then b) then a) then a).gif b/CaveGame/Assets/Gamer picks b) then b) then a) then a).gif Binary files differ. diff --git a/CaveGame/Bridge.java b/CaveGame/Bridge.java @@ -1,35 +0,0 @@ -package CaveGame; - -public class Bridge implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public Bridge (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.bridge; - myParent.showStatus("On the Bridge"); - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACbridge; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myArea.repaint(); - } - - public CaveInterface processA() { - // do nothing - return(this); - } - - public CaveInterface processB() { - // do nothing - return(this); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/Cave2.java b/CaveGame/Cave2.java @@ -1,35 +0,0 @@ -package CaveGame; - -public class Cave2 implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public Cave2 (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.secondCave; - myParent.showStatus("In the second Cave"); - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACsecondCave; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myArea.repaint(); - } - - public CaveInterface processA() { - // do nothing - return(this); - } - - public CaveInterface processB() { - // do nothing - return(this); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/CaveArea.java b/CaveGame/CaveArea.java @@ -1,106 +0,0 @@ -package CaveGame; - -import java.awt.*; -import java.applet.AudioClip; -import java.net.*; - -public class CaveArea extends Panel { - - CaveGame myApplet = null; - Image title[] = new Image[10]; - MediaTracker mt=null; - Image firstRoom, leftDoor, firstCave; - Image river, bridge; - Image cavern, hole, rope; - Image hotRoom, secondCave, gameComplete; - Image currentImage; - - AudioClip ACfirstRoom, ACleftDoor, ACfirstCave; - AudioClip ACriver, ACbridge; - AudioClip ACcavern, AChole, ACrope; - AudioClip AChotRoom, ACsecondCave, ACgameComplete; - AudioClip currentMusic; - - public CaveArea(CaveGame parent) { - mt=new MediaTracker(parent); - myApplet = parent; - - firstRoom = load(parent, "1ST ROOM.gif"); - leftDoor = load(parent, "GAMER PICKS A.gif"); - firstCave = load(parent, "GAMER PICKS C.gif"); - river = load(parent, "GAMER PICKS B.gif"); - bridge = load(parent, "GAMER PICKS B THEN A.gif"); - cavern = load(parent, "GAMER PICKS B THEN B.gif"); - hole = load(parent, "GAMER PICKS B THEN B THEN B.gif"); - rope = load(parent, "GAMER PICKS B THEN B THEN C.gif"); - hotRoom = load(parent, "GAMER PICKS B THEN B THEN A.gif"); - secondCave = load(parent, "GAMER PICKS B THEN B THEN A THEN B.gif"); - gameComplete = load(parent, "GAME COMPLETE.gif"); - - ACfirstRoom = loadSound(parent, "The Prophecy.mp3"); - ACleftDoor = loadSound(parent, "The Black Rider.mp3"); - ACfirstCave = loadSound(parent, "The Shadow of the Past.mp3"); - ACriver = loadSound(parent, "The Great River.mp3"); - ACbridge = loadSound(parent, "Flight to the Ford.mp3"); - ACcavern = loadSound(parent, "A Journey in the Dark.mp3"); - AChole = loadSound(parent, "A Knife in the Dark.mp3"); - ACrope = loadSound(parent, "Amon Hen.mp3"); - AChotRoom = loadSound(parent, "The Bridge of Khazad Dhum.mp3"); - ACsecondCave = loadSound(parent, "The Treason of Isengard.mp3"); - ACgameComplete = loadSound(parent, "Concerning Hobbits.mp3"); - - } - - Image load(CaveGame parent, String picture) { - Image im = parent.getImage(myApplet.getCodeBase(), "CaveGame\\" + picture); - checkImage(im, picture); - return(im); - } - - AudioClip loadSound(CaveGame parent, String soundfile) { - AudioClip s = null; - s = parent.getAudioClip(myApplet.getCodeBase(), "CaveGame\\"+soundfile); - checkAudio(s, soundfile); - return (s); - } - - void checkAudio(AudioClip ac, String name) { - if (ac == null) System.out.println("Audio Clip Not found: "+name.toString()); - } - - void checkImage(Image image, String name) { - if (mt != null) { - mt.addImage(image,0); - try { - mt.waitForID(0,5000); - } - catch (InterruptedException ie) { - // nothing to do - } - if (mt.isErrorID(0)) System.out.println("Image Not found: "+name.toString()); - } - } - - public synchronized void paint (Graphics g) { - if (myApplet == null) return; - final int w = getBounds().width; - final int h = getBounds().height; - g.setColor(Color.white); - FontMetrics fm = getFontMetrics(getFont()); - - g.setColor(Color.black); - int asc = fm.getAscent() + 4; - - g.drawImage(currentImage, 0, 0,Color.white, null); - - } - - public void showTitle(Graphics g) { - for (int i = 0; i < 10; i++) { - g.drawImage(title[i], myApplet.getBounds().width/2, getBounds().height/2,Color.white, null); - try {Thread.sleep(50);} - catch (Exception e) {} - } - } - -}- \ No newline at end of file diff --git a/CaveGame/CaveFrame.java b/CaveGame/CaveFrame.java @@ -1,10 +0,0 @@ -package CaveGame; - -import java.awt.Frame; - -public class CaveFrame extends Frame { - - public CaveFrame() { - setBounds(200, 200, 200, 150); - } -}- \ No newline at end of file diff --git a/CaveGame/CaveGame.java b/CaveGame/CaveGame.java @@ -1,85 +0,0 @@ -//* Copyright (c) Mary Percival 2003 */ -/* CaveGame game Created December 2003 */ - -package CaveGame; - -import java.awt.*; -import java.awt.event.*; -import java.applet.*; - -public class CaveGame extends Applet implements KeyListener { - - static boolean finished = false; - CaveArea area; - CaveInterface currentCavern; - - // ************************************************************* - public void init() { - - setLayout(null); - setBackground(Color.white); - - area = new CaveArea(this); - add(area); - - FontMetrics fm = getFontMetrics(getFont()); - area.setVisible(true); - area.setBounds(0,0,getBounds().width,getBounds().height); - - addKeyListener(this); - area.addKeyListener(this); - area.requestFocus(); - start(); - } - - public void start() { - currentCavern = new FirstRoom(this, area); - currentCavern.display(); - area.repaint(); - showStatus("CaveGame Started"); - } - - public void finished() { - finished = true; - System.exit(0); - } - - public String getAppletInfo() { - return ("CaveGame Game"); - } - - // this class will use just the key pressed event - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_A) { - currentCavern = currentCavern.processA(); - currentCavern.display(); - area.repaint(); - } - else if (e.getKeyCode() == KeyEvent.VK_B) { - currentCavern = currentCavern.processB(); - currentCavern.display(); - area.repaint(); - } - else if (e.getKeyCode() == KeyEvent.VK_C) { - currentCavern = currentCavern.processC(); - currentCavern.display(); - area.repaint(); - } - else if (e.getKeyCode() == KeyEvent.VK_ENTER) { - start(); - area.repaint(); - } - } - - synchronized void die() { - showStatus("The Player is dead. Press the Enter key to restart"); - finished = true; - } - - public void keyReleased(KeyEvent e) { - } - - public void keyTyped(KeyEvent e) { - } - -}- \ No newline at end of file diff --git a/CaveGame/CaveInterface.java b/CaveGame/CaveInterface.java @@ -1,10 +0,0 @@ -package CaveGame; - -public interface CaveInterface { - // interface that each cavern implements - void display(); - CaveInterface processA(); - CaveInterface processB(); - CaveInterface processC(); - -}- \ No newline at end of file diff --git a/CaveGame/Cavern.java b/CaveGame/Cavern.java @@ -1,32 +0,0 @@ -package CaveGame; - -public class Cavern implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public Cavern (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.cavern; - myParent.showStatus("In the Cavern"); - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACcavern; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myArea.repaint(); - } - - public CaveInterface processA() { - return(new HotRoom(myParent, myArea)); - } - - public CaveInterface processB() { - return(new Hole(myParent, myArea)); - } - - public CaveInterface processC() { - return(new Rope(myParent, myArea)); - } -}- \ No newline at end of file diff --git a/CaveGame/FirstCave.java b/CaveGame/FirstCave.java @@ -1,35 +0,0 @@ -package CaveGame; - -public class FirstCave implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public FirstCave (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.firstCave; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACfirstCave; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("In the First Cave"); - myArea.repaint(); - } - - public CaveInterface processA() { - // do nothing - return(this); - } - - public CaveInterface processB() { - // do nothing - return(this); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/FirstRoom.java b/CaveGame/FirstRoom.java @@ -1,32 +0,0 @@ -package CaveGame; - -public class FirstRoom implements CaveInterface{ - CaveGame myParent; - CaveArea myArea; - - public FirstRoom(CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.firstRoom; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACfirstRoom; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("Just Inside the Entrance"); - myArea.repaint(); - } - - public CaveInterface processA() { - return new LeftDoor(myParent, myArea); - } - - public CaveInterface processB() { - return new River(myParent, myArea); - } - - public CaveInterface processC() { - return new FirstCave(myParent, myArea); - } -}- \ No newline at end of file diff --git a/CaveGame/Hole.java b/CaveGame/Hole.java @@ -1,35 +0,0 @@ -package CaveGame; - -public class Hole implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public Hole (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.hole; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.AChole; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("In the Hole"); - myArea.repaint(); - } - - public CaveInterface processA() { - // do nothing - return(this); - } - - public CaveInterface processB() { - // do nothing - return(this); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/HotRoom.java b/CaveGame/HotRoom.java @@ -1,33 +0,0 @@ -package CaveGame; - -public class HotRoom implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public HotRoom (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.hotRoom; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.AChotRoom; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("In the Hot Room"); - myArea.repaint(); - } - - public CaveInterface processA() { - return(new WayOut(myParent, myArea)); - } - - public CaveInterface processB() { - return(new Cave2(myParent, myArea)); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/LeftDoor.java b/CaveGame/LeftDoor.java @@ -1,35 +0,0 @@ -package CaveGame; - -public class LeftDoor implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public LeftDoor(CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.leftDoor; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACleftDoor; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("Through the Left Door"); - myArea.repaint(); - } - - public CaveInterface processA() { - // do nothing - return(this); - } - - public CaveInterface processB() { - // do nothing - return(this); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/River.java b/CaveGame/River.java @@ -1,33 +0,0 @@ -package CaveGame; - -public class River implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public River (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.river; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACriver; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("By the River"); - myArea.repaint(); - } - - public CaveInterface processA() { - return(new Bridge(myParent, myArea)); - } - - public CaveInterface processB() { - return(new Cavern(myParent, myArea)); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/Rope.java b/CaveGame/Rope.java @@ -1,35 +0,0 @@ -package CaveGame; - -public class Rope implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public Rope (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.rope; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACrope; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("Down the Rope"); - myArea.repaint(); - } - - public CaveInterface processA() { - // do nothing - return(this); - } - - public CaveInterface processB() { - // do nothing - return(this); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/WayOut.java b/CaveGame/WayOut.java @@ -1,35 +0,0 @@ -package CaveGame; - -public class WayOut implements CaveInterface { - CaveGame myParent; - CaveArea myArea; - - public WayOut (CaveGame parent, CaveArea area) { - myParent = parent; - myArea = area; - } - - public void display() { - myArea.currentImage = myArea.gameComplete; - if (myArea.currentMusic != null) myArea.currentMusic.stop(); - myArea.currentMusic = myArea.ACgameComplete; - if (myArea.currentMusic != null) myArea.currentMusic.loop(); - myParent.showStatus("At the Exit"); - myArea.repaint(); - } - - public CaveInterface processA() { - // do nothing - return(this); - } - - public CaveInterface processB() { - // do nothing - return(this); - } - - public CaveInterface processC() { - // do nothing - return(this); - } -}- \ No newline at end of file diff --git a/CaveGame/desktop.ini b/CaveGame/desktop.ini Binary files differ. diff --git a/CaveGame/src/Bridge.java b/CaveGame/src/Bridge.java @@ -0,0 +1,33 @@ +public class Bridge implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public Bridge (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.bridge; + myParent.showStatus("On the Bridge"); + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACbridge; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myArea.repaint(); + } + + public CaveInterface processA() { + // do nothing + return(this); + } + + public CaveInterface processB() { + // do nothing + return(this); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/Cave2.java b/CaveGame/src/Cave2.java @@ -0,0 +1,33 @@ +public class Cave2 implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public Cave2 (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.secondCave; + myParent.showStatus("In the second Cave"); + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACsecondCave; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myArea.repaint(); + } + + public CaveInterface processA() { + // do nothing + return(this); + } + + public CaveInterface processB() { + // do nothing + return(this); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/CaveArea.java b/CaveGame/src/CaveArea.java @@ -0,0 +1,104 @@ +import java.awt.*; +import java.applet.AudioClip; +import java.net.*; + +public class CaveArea extends Panel { + + CaveGame myApplet = null; + Image title[] = new Image[10]; + MediaTracker mt=null; + Image firstRoom, leftDoor, firstCave; + Image river, bridge; + Image cavern, hole, rope; + Image hotRoom, secondCave, gameComplete; + Image currentImage; + + AudioClip ACfirstRoom, ACleftDoor, ACfirstCave; + AudioClip ACriver, ACbridge; + AudioClip ACcavern, AChole, ACrope; + AudioClip AChotRoom, ACsecondCave, ACgameComplete; + AudioClip currentMusic; + + public CaveArea(CaveGame parent) { + mt=new MediaTracker(parent); + myApplet = parent; + + firstRoom = load(parent, "1ST ROOM.gif"); + leftDoor = load(parent, "GAMER PICKS A.gif"); + firstCave = load(parent, "GAMER PICKS C.gif"); + river = load(parent, "GAMER PICKS B.gif"); + bridge = load(parent, "GAMER PICKS B THEN A.gif"); + cavern = load(parent, "GAMER PICKS B THEN B.gif"); + hole = load(parent, "GAMER PICKS B THEN B THEN B.gif"); + rope = load(parent, "GAMER PICKS B THEN B THEN C.gif"); + hotRoom = load(parent, "GAMER PICKS B THEN B THEN A.gif"); + secondCave = load(parent, "GAMER PICKS B THEN B THEN A THEN B.gif"); + gameComplete = load(parent, "GAME COMPLETE.gif"); + + ACfirstRoom = loadSound(parent, "The Prophecy.mp3"); + ACleftDoor = loadSound(parent, "The Black Rider.mp3"); + ACfirstCave = loadSound(parent, "The Shadow of the Past.mp3"); + ACriver = loadSound(parent, "The Great River.mp3"); + ACbridge = loadSound(parent, "Flight to the Ford.mp3"); + ACcavern = loadSound(parent, "A Journey in the Dark.mp3"); + AChole = loadSound(parent, "A Knife in the Dark.mp3"); + ACrope = loadSound(parent, "Amon Hen.mp3"); + AChotRoom = loadSound(parent, "The Bridge of Khazad Dhum.mp3"); + ACsecondCave = loadSound(parent, "The Treason of Isengard.mp3"); + ACgameComplete = loadSound(parent, "Concerning Hobbits.mp3"); + + } + + Image load(CaveGame parent, String picture) { + Image im = parent.getImage(myApplet.getCodeBase(), "CaveGame\\" + picture); + checkImage(im, picture); + return(im); + } + + AudioClip loadSound(CaveGame parent, String soundfile) { + AudioClip s = null; + s = parent.getAudioClip(myApplet.getCodeBase(), "CaveGame\\"+soundfile); + checkAudio(s, soundfile); + return (s); + } + + void checkAudio(AudioClip ac, String name) { + if (ac == null) System.out.println("Audio Clip Not found: "+name.toString()); + } + + void checkImage(Image image, String name) { + if (mt != null) { + mt.addImage(image,0); + try { + mt.waitForID(0,5000); + } + catch (InterruptedException ie) { + // nothing to do + } + if (mt.isErrorID(0)) System.out.println("Image Not found: "+name.toString()); + } + } + + public synchronized void paint (Graphics g) { + if (myApplet == null) return; + final int w = getBounds().width; + final int h = getBounds().height; + g.setColor(Color.white); + FontMetrics fm = getFontMetrics(getFont()); + + g.setColor(Color.black); + int asc = fm.getAscent() + 4; + + g.drawImage(currentImage, 0, 0,Color.white, null); + + } + + public void showTitle(Graphics g) { + for (int i = 0; i < 10; i++) { + g.drawImage(title[i], myApplet.getBounds().width/2, getBounds().height/2,Color.white, null); + try {Thread.sleep(50);} + catch (Exception e) {} + } + } + +}+ \ No newline at end of file diff --git a/CaveGame/src/CaveGame.java b/CaveGame/src/CaveGame.java @@ -0,0 +1,83 @@ +//* Copyright (c) Mary Percival 2003 */ +/* CaveGame game Created December 2003 */ + +import java.awt.*; +import java.awt.event.*; +import java.applet.*; + +public class CaveGame extends JPanel implements KeyListener { + + static boolean finished = false; + CaveArea area; + CaveInterface currentCavern; + + // ************************************************************* + public void init() { + + setLayout(null); + setBackground(Color.white); + + area = new CaveArea(this); + add(area); + + FontMetrics fm = getFontMetrics(getFont()); + area.setVisible(true); + area.setBounds(0,0,getBounds().width,getBounds().height); + + addKeyListener(this); + area.addKeyListener(this); + area.requestFocus(); + start(); + } + + public void start() { + currentCavern = new FirstRoom(this, area); + currentCavern.display(); + area.repaint(); + showStatus("CaveGame Started"); + } + + public void finished() { + finished = true; + System.exit(0); + } + + public String getAppletInfo() { + return ("CaveGame Game"); + } + + // this class will use just the key pressed event + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_A) { + currentCavern = currentCavern.processA(); + currentCavern.display(); + area.repaint(); + } + else if (e.getKeyCode() == KeyEvent.VK_B) { + currentCavern = currentCavern.processB(); + currentCavern.display(); + area.repaint(); + } + else if (e.getKeyCode() == KeyEvent.VK_C) { + currentCavern = currentCavern.processC(); + currentCavern.display(); + area.repaint(); + } + else if (e.getKeyCode() == KeyEvent.VK_ENTER) { + start(); + area.repaint(); + } + } + + synchronized void die() { + showStatus("The Player is dead. Press the Enter key to restart"); + finished = true; + } + + public void keyReleased(KeyEvent e) { + } + + public void keyTyped(KeyEvent e) { + } + +}+ \ No newline at end of file diff --git a/CaveGame/src/CaveInterface.java b/CaveGame/src/CaveInterface.java @@ -0,0 +1,8 @@ +public interface CaveInterface { + // interface that each cavern implements + void display(); + CaveInterface processA(); + CaveInterface processB(); + CaveInterface processC(); + +}+ \ No newline at end of file diff --git a/CaveGame/src/Cavern.java b/CaveGame/src/Cavern.java @@ -0,0 +1,30 @@ +public class Cavern implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public Cavern (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.cavern; + myParent.showStatus("In the Cavern"); + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACcavern; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myArea.repaint(); + } + + public CaveInterface processA() { + return(new HotRoom(myParent, myArea)); + } + + public CaveInterface processB() { + return(new Hole(myParent, myArea)); + } + + public CaveInterface processC() { + return(new Rope(myParent, myArea)); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/FirstCave.java b/CaveGame/src/FirstCave.java @@ -0,0 +1,33 @@ +public class FirstCave implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public FirstCave (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.firstCave; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACfirstCave; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("In the First Cave"); + myArea.repaint(); + } + + public CaveInterface processA() { + // do nothing + return(this); + } + + public CaveInterface processB() { + // do nothing + return(this); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/FirstRoom.java b/CaveGame/src/FirstRoom.java @@ -0,0 +1,30 @@ +public class FirstRoom implements CaveInterface{ + CaveGame myParent; + CaveArea myArea; + + public FirstRoom(CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.firstRoom; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACfirstRoom; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("Just Inside the Entrance"); + myArea.repaint(); + } + + public CaveInterface processA() { + return new LeftDoor(myParent, myArea); + } + + public CaveInterface processB() { + return new River(myParent, myArea); + } + + public CaveInterface processC() { + return new FirstCave(myParent, myArea); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/Hole.java b/CaveGame/src/Hole.java @@ -0,0 +1,33 @@ +public class Hole implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public Hole (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.hole; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.AChole; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("In the Hole"); + myArea.repaint(); + } + + public CaveInterface processA() { + // do nothing + return(this); + } + + public CaveInterface processB() { + // do nothing + return(this); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/HotRoom.java b/CaveGame/src/HotRoom.java @@ -0,0 +1,31 @@ +public class HotRoom implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public HotRoom (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.hotRoom; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.AChotRoom; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("In the Hot Room"); + myArea.repaint(); + } + + public CaveInterface processA() { + return(new WayOut(myParent, myArea)); + } + + public CaveInterface processB() { + return(new Cave2(myParent, myArea)); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/LeftDoor.java b/CaveGame/src/LeftDoor.java @@ -0,0 +1,33 @@ +public class LeftDoor implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public LeftDoor(CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.leftDoor; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACleftDoor; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("Through the Left Door"); + myArea.repaint(); + } + + public CaveInterface processA() { + // do nothing + return(this); + } + + public CaveInterface processB() { + // do nothing + return(this); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/River.java b/CaveGame/src/River.java @@ -0,0 +1,31 @@ +public class River implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public River (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.river; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACriver; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("By the River"); + myArea.repaint(); + } + + public CaveInterface processA() { + return(new Bridge(myParent, myArea)); + } + + public CaveInterface processB() { + return(new Cavern(myParent, myArea)); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/Rope.java b/CaveGame/src/Rope.java @@ -0,0 +1,33 @@ +public class Rope implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public Rope (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.rope; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACrope; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("Down the Rope"); + myArea.repaint(); + } + + public CaveInterface processA() { + // do nothing + return(this); + } + + public CaveInterface processB() { + // do nothing + return(this); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file diff --git a/CaveGame/src/WayOut.java b/CaveGame/src/WayOut.java @@ -0,0 +1,33 @@ +public class WayOut implements CaveInterface { + CaveGame myParent; + CaveArea myArea; + + public WayOut (CaveGame parent, CaveArea area) { + myParent = parent; + myArea = area; + } + + public void display() { + myArea.currentImage = myArea.gameComplete; + if (myArea.currentMusic != null) myArea.currentMusic.stop(); + myArea.currentMusic = myArea.ACgameComplete; + if (myArea.currentMusic != null) myArea.currentMusic.loop(); + myParent.showStatus("At the Exit"); + myArea.repaint(); + } + + public CaveInterface processA() { + // do nothing + return(this); + } + + public CaveInterface processB() { + // do nothing + return(this); + } + + public CaveInterface processC() { + // do nothing + return(this); + } +}+ \ No newline at end of file