📄 freshman.java
字号:
pane2 = new player2D2(this, field);
repaint();
getContentPane().add(pane, BorderLayout.NORTH);
getContentPane().add(field, BorderLayout.CENTER);
getContentPane().add(pane2, BorderLayout.SOUTH);
field.m_runner.start();field.n_runner.start();
m_dataLife();
runner = new Thread() {
public void run(){
while (true) {
if(tie == 0) {sec--; tie = 9;}
else {tie--;}
pane.lbl50.setText(" "+sec+" : "+tie+" ");repaint();
pane2.lbl50.setText(" "+sec+" : "+tie+" ");repaint();
if((sec == 0)&(tie == 0)) //JOptionPane for the game over
{ gameOver();
}
try{
Thread.sleep(Delay);
} catch(InterruptedException e){ }
}
}
}; //Fin du Thread m_runner
runner.start();
}
WindowListener wndCloser = new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ System.exit(0);}
};
addWindowListener(wndCloser);
pack();
setResizable(false);
setVisible(true);
}}
public static void main(String argv[])
{
new FreshMan();
}
public void m_dataLife(){
/* if(chois[responses] == chois[0]) {
if(m_data == Level.m_data3 || m_data == Level.m_data4||m_data == Level.m_data5) {
field.n_runner.stop(); field.b_runner.stop(); field.life = 1;
field.oneup.setText(" x "+field.life); }
if(m_data == Level.m_data2) {
field.life = 2; field.oneup.setText(" x "+field.life); }}
else{ */
if(m_data == Level.m_data3||m_data == Level.m_data4||m_data == Level.m_data5||m_data == Level.m_data6||m_data == Level.m_data7) {
field.b_runner.stop(); field.life = 1; field.life2 = 1;
field.oneup.setText(" x "+field.life); field.oneup2.setText(" x "+field.life2);}
if(m_data == Level.m_data2) {
field.life = 2; field.life2 = 2;
field.oneup.setText(" x "+field.life); field.oneup2.setText(" x "+field.life2);}}
//}
public void pause(){field.m_runner.suspend();field.n_runner.suspend();runner.suspend();}
public void resume(){field.m_runner.resume();field.n_runner.resume();runner.resume();}
public void actionPerformed(ActionEvent e)
{
if (e.getSource () == menuGameNew) newGame();
//menuGameNew_actionPerformed();
if (e.getSource () == menuGameExit)
System.exit(0);
if (e.getSource () == menuGamePause)
pause();
if (e.getSource () == menuGameResume)
resume();
//if (e.getSource () == menuOptionsLevel)
//if (e.getSource () == LevelChoice)
// menuOptionsLevel_actionPerformed();
//if (e.getSource () == menuOptionsPlayer)
// menuOptionsPlayer_actionPerformed();
//if (e.getSource () == menuOptionsName)
// menuOptionsName_actionPerformed();
if (e.getSource () == menuHelpAbout)
menuHelpAbout_actionPerformed();
if (e.getSource () == menuHelpInstruction)
menuHelpInstrucion_actionPerformed();
}
public void menuOptionsLevel_actionPerformed(){
if(LevelChoice.getSelectedIndex() == 0) {m_data = Level.m_data0;};
if(LevelChoice.getSelectedIndex() == 1) {m_data = Level.m_data1;};
if(LevelChoice.getSelectedIndex() == 2) {m_data = Level.m_data2;};
if(LevelChoice.getSelectedIndex() == 3) {m_data = Level.m_data3;};
if(LevelChoice.getSelectedIndex() == 4) {m_data = Level.m_data4;};
if(LevelChoice.getSelectedIndex() == 5) {m_data = Level.m_data5;};
if(LevelChoice.getSelectedIndex() == 6) {m_data = Level.m_data6;};
if(LevelChoice.getSelectedIndex() == 7) {m_data = Level.m_data7;};
//if(LevelChoice.getSelectedIndex() == 8) {getContentPane().removeAll();getContentPane().add(new Tower());}
}
//public void menuGameNew_actionPerformed(){
//if(chois[responses] == chois[0]) {field.m_runner.stop();newGame();}
//else {field.m_runner.stop();field.n_runner.stop();newGame();}
// }
/*public void menuOptionsLevel_actionPerformed()
{ //Here are the JOption Pane for the Difficulty
JComboBox LevelChoice = new JComboBox () ;
for (int i=0; i<=5; i++) LevelChoice.addItem ("Level " + i) ;
LevelChoice.setEditable(false);
JComboBox[] choices = { LevelChoice };
int response3=JOptionPane.showOptionDialog(null, "PLEASE CHOOSE YOUR LEVEL : ",
"Choix Du Level", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("michelle1.jpg"), choices, choices[0]);
if(LevelChoice.getSelectedIndex() == 0) {m_data = Level.m_data0;};
if(LevelChoice.getSelectedIndex() == 1) {m_data = Level.m_data1;};
if(LevelChoice.getSelectedIndex() == 2) {m_data = Level.m_data2;};
if(LevelChoice.getSelectedIndex() == 3) {m_data = Level.m_data3;};
if(LevelChoice.getSelectedIndex() == 4) {m_data = Level.m_data4;};
if(LevelChoice.getSelectedIndex() == 5) {m_data = Level.m_data5;}; }*/
public int menuOptionsPlayer_actionPerformed()
{ //Choix du nombe de joueurs "SEE ABOVE"
int responses=0;
/*int responses=JOptionPane.showOptionDialog(this, null,
"Number Of Players", 0, JOptionPane.QUESTION_MESSAGE,
ImageOf.menuOptionsPlayer_actionPerformed, chois, chois[1]);
return responses;*/
if(PlayerChoice.getSelectedIndex() == 0) {responses=0;};
if(PlayerChoice.getSelectedIndex() == 1) {responses=1;};
return responses;
}
public void menuOptionsName_actionPerformed()
{ if(chois[responses] == chois[0]) {
//Here are the JOption Pane for Fresh-Man, the Player 1
JPanel pa = new JPanel();JLabel la = new JLabel("MY NAME IS : ");
final JTextField te = new JTextField(" ",20);pa.setLayout(new GridLayout(2,1));
pa.add(la); pa.add(te);
String[] choice = { "START"};
int response1=JOptionPane.showOptionDialog(this, pa,
"FIRST PLAYER", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("Annick3.jpg"), choice, choice[0]);
if(choice[response1] == null) lbl10.setText("PLAYER 1");
else lbl10.setText(" "+te.getText().toUpperCase()+" ");
lbl10.setShearFactor(0.3);
lbl10.setForeground(Color.blue);lbl10.setStroke(new BasicStroke(5f));}
else { //Here are the JOption Pane for Fresh-Man, the Player 1
JPanel pa = new JPanel();JLabel la = new JLabel("MY NAME IS : ");
final JTextField te = new JTextField(" ",20);pa.setLayout(new GridLayout(2,1));
pa.add(la); pa.add(te);
String[] choice = { "START"};
int response1=JOptionPane.showOptionDialog(this, pa,
"FIRST PLAYER", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("Annick3.jpg"), choice, choice[0]);
if(choice[response1] == null) lbl10.setText("PLAYER 1");
else lbl10.setText(" "+te.getText().toUpperCase()+" ");
lbl10.setShearFactor(0.3);
lbl10.setForeground(Color.blue);lbl10.setStroke(new BasicStroke(5f));
//Here are the JOption Pane for Pac-Man, the Player 2
JPanel pa2 = new JPanel();JLabel la2 = new JLabel("MEIN NAME IST : ");
final JTextField te2 = new JTextField(" ",20);pa2.setLayout(new GridLayout(2,1));
pa2.add(la2); pa2.add(te2);
String[] choice2 = { "START"};
int response12=JOptionPane.showOptionDialog(this, pa2,
"SECOND PLAYER", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("will3jpg.jpg"), choice2, choice2[0]);
if(choice2[response12] == null) lbl102.setText("PLAYER 2");
else lbl102.setText(" "+te2.getText().toUpperCase()+" ");
lbl102.setShearFactor(0.3);
lbl102.setForeground(Color.red);lbl102.setStroke(new BasicStroke(5f));
/* //Here are the JOption Pane for El-Man, the Player 3
JPanel pa3 = new JPanel();JLabel la3 = new JLabel("PLEASE TAPE YOUR NAME : ");
final JTextField te2 = new JTextField(" ",20);pa2.setLayout(new GridLayout(2,1));
pa3.add(la3); pa3.add(te3);
String[] choice3 = { "START"};
int response13=JOptionPane.showOptionDialog(this, pa3,
"THIRD PLAYER", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("will3jpg.jpg"), choice3, choice3[0]);
if(choice3[response13] == null) lbl103.setText("PLAYER 3");
else lbl102.setText(" "+te2.getText().toUpperCase()+" ");
lbl102.setShearFactor(0.3);
lbl102.setForeground(Color.blue);lbl102.setStroke(new BasicStroke(5f));
*/}
}
public void menuHelpAbout_actionPerformed()
{
ab.setVisible(true);
}
public void menuHelpInstrucion_actionPerformed()
{ String[] choi = { "ENGLISH","FRANCAIS","DEUTSCH"};
int response=JOptionPane.showOptionDialog(this, "Choose Your Language :" ,
"LANGUAGE", 0, JOptionPane.QUESTION_MESSAGE,
null, choi, choi[0]);
if(chois[responses] == chois[0]) {
//Help
if(choi[response] == choi[0]) {
final String[] cho = { " G O !!! "};
final int respon=JOptionPane.showOptionDialog(this,
"What's Up "+lbl10.getText()+",\nU've got a blue Ferrari , Take care!\nUse the multi-directional keys Left,Up,Right,Down to move.\n You have to catch all the blue men and avoid touching the red women before the time ends.\nDon't worried about the others Ferrari.\nBlue men give u 1 point and red women remove u 1 point too.\nU can also accelerate, use P.\nGood Luck!" ,
"H E L P", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("annickAu57bis.jpg"), cho, cho[0]);}
if(choi[response] == choi[2]) {
final String[] cho = { " G O !!! "};
final int respon=JOptionPane.showOptionDialog(this,
"Hallo "+lbl10.getText()+",\nSie haben eine blaue Ferrari, passen Sie gut darauf.\nBenutzen Sie die Left,Up,Right,Down keys von Tastatur zum Bewegen.\nSie sollen alle blaue M鋘ner holen, und vermeiden die roten Frauen zu holen.\nMachen Sie sich keine Sorgen auf die anderen Ferrari.\nDie blauen geben Ihnen jeweils 1 Punkt und die Roten -1.\nZum Beschleunigen, dr點ken Sie P.\nViel Gl點k!" ,
"H E L P", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("annickAu57bis.jpg"), cho, cho[0]);}
if(choi[response] == choi[1]) {
final String[] cho = { " G O !!! "};
final int respon=JOptionPane.showOptionDialog(this,
"Bonjour "+lbl10.getText()+",\nVous avez a votre disposition une Ferrari bleue, prenez en bien soin.\nPour vous deplacer utilisez les touches multidirectionelles.\n Votre Objectif est de recuperer tous les hommes bleus en evitant les femmes rouges avant la fin du temps.\nNe vous preoccupez pas des autres Ferraris.\nLes bleus vous donnent 1 point et les rouges vous enlevent autant\nPour accelerer appuyez sur P.\nBonne Chance!" ,
"H E L P", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("annickAu57bis.jpg"), cho, cho[0]);} }
else { //Help
//1P
if(choi[response] == choi[0]) {
final String[] cho = { " G O !!! "};
final int respon=JOptionPane.showOptionDialog(this,
"What's Up "+lbl10.getText()+",\nU've got a blue Ferrari , Take care!\nUse the multi-directional keys Left,Up,Right,Down to move.\n You have to catch all the blue men and avoid touching the red women before the time ends.\nU have to be faster and craftier than ur Opponent to win the Game.\nBlue men give u 1 point and red women remove u 1 point too.\nU can also accelerate, use P.\nGood Luck!" ,
"H E L P", 0, JOptionPane.QUESTION_MESSAGE,
new ImageIcon("annickAu57.jpg"), cho, cho[0]);}
if(choi[response] == choi[2]) {
final String[] cho = { " G O !!! "};
final int respon=JOptionPane.showOptionDialog(this,
"Hallo "+lbl10.getText()+",\nSie haben eine blaue Ferrari, passen Sie gut darauf.\nBenutzen Sie die Left,Up,Right,Down keys von Tastatur zum Bewegen.\nSie sollen alle blaue M鋘ner holen, und vermeiden die roten Frauen zu holen.\nSie sollen schneller und kluger als die rote Ferrari.\nDie blauen geben Ihnen jeweils 1 Punkt und die Roten -1.\nZum Beschleunigen, dr點ken Sie P.\nViel Spa
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -