Right now Im about to go nts I have to get this done. I will send via PayPal $8 to the first one to post back full code for this. I have included suedo code and refernced the proper images I need the identifiers (like score health days etc, to be able to be used throughout the applet) Here is the code so far dont worry about images just use blanks for now cause i can realign the buttons and whatnot tro make that work i need this bad.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class Outlaw extends java.applet.Applet
{
private static Button startButton = new Button ("Start Game"),
fightButton = new Button ("Fight!!!!11"),
healthButton = new Button ("Health!"),
weaponButton = new Button ("Weapon"),
endGame = new Button ("End Game!");
private static Label lblLabel = new Label ("");
int rndnum;
int health = 100;
int weapon = 0;
int police = 5;
int player = 4;
int score = 0;
int days = 30;
String charname, gunname;
Image healthPic;
Image titlePic;
public void init ()
{
setLayout (null);
add (startButton);
add (fightButton);
add (healthButton);
add (weaponButton);
add (endGame);
add (lblLabel);
lblLabel.setVisible (false);
fightButton.setVisible (false);
healthButton.setVisible (false);
weaponButton.setVisible (false);
endGame.setVisible (false);
lblLabel.setBounds (150, 1, 200, 30);
startButton.setBounds (1, 20, 100, 30);
fightButton.setBounds (1, 60, 100, 30);
healthButton.setBounds (1, 100, 100, 30);
weaponButton.setBounds (1, 140, 100, 30);
endGame.setBounds (1, 180, 100, 30);
healthPic = getImage (getCodeBase (), "health.jpg");
titlePic = getImage (getCodeBase (), "title.jpg");
weaponPic = getImage (getCodeBase (), "weapon.jpg");
fightPic = getImage (getCodeBase (), "fight.jpg");
selectPic = getImage (getCodeBase (), "select.jpg");
// Add an action listener to the button
// Check class below
startButton.addActionListener (new buttonEventManager (1));
fightButton.addActionListener (new buttonEventManager (2));
healthButton.addActionListener (new buttonEventManager (3));
weaponButton.addActionListener (new buttonEventManager (4));
endGame.addActionListener (new buttonEventManager (5));
} // init method
public void paint (Graphics g)
{
Font f = new Font("Small Fonts", Font.BOLD, 15);
screen.setFont(f);
g.drawImage(titlePic, 10, 1, this);
}
public static void StartGame ()
{
lblLabel.setText ("Game Started");
score = 0
health = 100
days = 30
lblLabel.setVisible (true);
startButton.setVisible (false);
fightButton.setVisible (true);
healthButton.setVisible (true);
weaponButton.setVisible (true);
endGame.setVisible (true);
}
public static void Fight ()
{
lblLabel.setText ("The Fight starts!");
//Random Generator 1-5+weapon if x>=3 then x = 3
You Killed x Crooked Cops in bottom with new lbl other label shows score health days
//Random Generator 1-50
You lost y health
If health <=0 then outlaw.endGame
days--
score = score + x (cops killed)
health = health - y
if days <= 0 then outlaw.endgame
lblLabel.setText (Score + " "+Health+" Days:"+days);
}
public static void Health ()
{
lblLabel.setText ("The FHeltht starts!");
//random generator 1-100
health = health + x
if health>=150 then health = 150
days--
score = score + x (cops killed)
health = health - y
if days <= 0 then outlaw.endgame
lblLabel.setText (Score + " "+Health+" Days:"+days);
}
public static void Weapon ()
{
lblLabel.setText ("The Wepon starts!");
//random generator 1-30
if x<4 then weapon = weapon + 1
if x<2 then weapon = weapon + 1
days = days - 1
}
public static void EndGame ()
{
lblLabel.setText ("Game Ends!");
startButton.setVisible (true);
fightButton.setVisible (false);
healthButton.setVisible (false);
weaponButton.setVisible (false);
endGame.setVisible (false);
}
} // Outlaw class
/*
* Class that will manage Button Events
*/
class buttonEventManager implements ActionListener
{
// Button ID for the Button
int ButtonID;
// Constructor
public buttonEventManager (int ID)
{
ButtonID = ID;
}
// Check Button ID and perform according action
public void actionPerformed (ActionEvent e)
{
switch (ButtonID)
{
case 1:
Outlaw.StartGame ();
break;
case 2:
Outlaw.Fight ();
break;
case 3:
Outlaw.Health ();
break;
case 4:
Outlaw.Weapon ();
break;
case 5:
Outlaw.EndGame ();
break;
}
}
}
Question
insurektion
Right now Im about to go nts I have to get this done. I will send via PayPal $8 to the first one to post back full code for this. I have included suedo code and refernced the proper images I need the identifiers (like score health days etc, to be able to be used throughout the applet) Here is the code so far dont worry about images just use blanks for now cause i can realign the buttons and whatnot tro make that work i need this bad.
import java.applet.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; public class Outlaw extends java.applet.Applet { private static Button startButton = new Button ("Start Game"), fightButton = new Button ("Fight!!!!11"), healthButton = new Button ("Health!"), weaponButton = new Button ("Weapon"), endGame = new Button ("End Game!"); private static Label lblLabel = new Label (""); int rndnum; int health = 100; int weapon = 0; int police = 5; int player = 4; int score = 0; int days = 30; String charname, gunname; Image healthPic; Image titlePic; public void init () { setLayout (null); add (startButton); add (fightButton); add (healthButton); add (weaponButton); add (endGame); add (lblLabel); lblLabel.setVisible (false); fightButton.setVisible (false); healthButton.setVisible (false); weaponButton.setVisible (false); endGame.setVisible (false); lblLabel.setBounds (150, 1, 200, 30); startButton.setBounds (1, 20, 100, 30); fightButton.setBounds (1, 60, 100, 30); healthButton.setBounds (1, 100, 100, 30); weaponButton.setBounds (1, 140, 100, 30); endGame.setBounds (1, 180, 100, 30); healthPic = getImage (getCodeBase (), "health.jpg"); titlePic = getImage (getCodeBase (), "title.jpg"); weaponPic = getImage (getCodeBase (), "weapon.jpg"); fightPic = getImage (getCodeBase (), "fight.jpg"); selectPic = getImage (getCodeBase (), "select.jpg"); // Add an action listener to the button // Check class below startButton.addActionListener (new buttonEventManager (1)); fightButton.addActionListener (new buttonEventManager (2)); healthButton.addActionListener (new buttonEventManager (3)); weaponButton.addActionListener (new buttonEventManager (4)); endGame.addActionListener (new buttonEventManager (5)); } // init method public void paint (Graphics g) { Font f = new Font("Small Fonts", Font.BOLD, 15); screen.setFont(f); g.drawImage(titlePic, 10, 1, this); } public static void StartGame () { lblLabel.setText ("Game Started"); score = 0 health = 100 days = 30 lblLabel.setVisible (true); startButton.setVisible (false); fightButton.setVisible (true); healthButton.setVisible (true); weaponButton.setVisible (true); endGame.setVisible (true); } public static void Fight () { lblLabel.setText ("The Fight starts!"); //Random Generator 1-5+weapon if x>=3 then x = 3 You Killed x Crooked Cops in bottom with new lbl other label shows score health days //Random Generator 1-50 You lost y health If health <=0 then outlaw.endGame days-- score = score + x (cops killed) health = health - y if days <= 0 then outlaw.endgame lblLabel.setText (Score + " "+Health+" Days:"+days); } public static void Health () { lblLabel.setText ("The FHeltht starts!"); //random generator 1-100 health = health + x if health>=150 then health = 150 days-- score = score + x (cops killed) health = health - y if days <= 0 then outlaw.endgame lblLabel.setText (Score + " "+Health+" Days:"+days); } public static void Weapon () { lblLabel.setText ("The Wepon starts!"); //random generator 1-30 if x<4 then weapon = weapon + 1 if x<2 then weapon = weapon + 1 days = days - 1 } public static void EndGame () { lblLabel.setText ("Game Ends!"); startButton.setVisible (true); fightButton.setVisible (false); healthButton.setVisible (false); weaponButton.setVisible (false); endGame.setVisible (false); } } // Outlaw class /* * Class that will manage Button Events */ class buttonEventManager implements ActionListener { // Button ID for the Button int ButtonID; // Constructor public buttonEventManager (int ID) { ButtonID = ID; } // Check Button ID and perform according action public void actionPerformed (ActionEvent e) { switch (ButtonID) { case 1: Outlaw.StartGame (); break; case 2: Outlaw.Fight (); break; case 3: Outlaw.Health (); break; case 4: Outlaw.Weapon (); break; case 5: Outlaw.EndGame (); break; } } }Link to comment
Share on other sites
9 answers to this question
Recommended Posts