dernière modifs
This commit is contained in:
parent
21744392ca
commit
b0f9825d94
@ -14,12 +14,14 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
import modeles.Salle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nicolas
|
* @author nicolas
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
||||||
|
public char nb;
|
||||||
public JeuSalle() {
|
public JeuSalle() {
|
||||||
setTitle("Labyrinthe");
|
setTitle("Labyrinthe");
|
||||||
setSize(1200,600);
|
setSize(1200,600);
|
||||||
@ -50,10 +52,15 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
System.out.println("keyPressed");
|
//System.out.println("keyPressed");
|
||||||
int code=e.getKeyCode();
|
int codeint =e.getKeyCode();
|
||||||
String key =e.getKeyText(code);
|
|
||||||
System.out.println(key);
|
//int codeint=Character.getNumericValue(e.getKeyText(code));
|
||||||
|
//System.out.println(codeint);
|
||||||
|
//String key =e.getKeyText(code);
|
||||||
|
//System.out.println(key);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -70,6 +77,9 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent e) {
|
public void keyTyped(KeyEvent e) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
nb = e.getKeyChar();
|
||||||
|
System.out.println(nb);
|
||||||
|
//System.out.println(nb);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -81,5 +91,12 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public char toucheint() {
|
||||||
|
System.out.println("sortie"+nb);
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
public void cacher(JPanel panel) {
|
||||||
|
panel.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,8 @@ import org.eclipse.swt.SWT;
|
|||||||
public class jeu extends JFrame implements ActionListener {
|
public class jeu extends JFrame implements ActionListener {
|
||||||
JButton continuer =new JButton("Continuer");
|
JButton continuer =new JButton("Continuer");
|
||||||
JButton nouvelle = new JButton("Nouvelle Partie");
|
JButton nouvelle = new JButton("Nouvelle Partie");
|
||||||
|
public JeuSalle salle;
|
||||||
|
public JPanel panel;
|
||||||
public jeu() throws IOException {
|
public jeu() throws IOException {
|
||||||
super();
|
super();
|
||||||
build();
|
build();
|
||||||
@ -89,26 +91,45 @@ public class jeu extends JFrame implements ActionListener {
|
|||||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Object source=arg0.getSource();
|
Object source=arg0.getSource();
|
||||||
|
choix(source);
|
||||||
if(source==nouvelle) {
|
if(source==nouvelle) {
|
||||||
|
//JPanel panel = new JPanel();
|
||||||
Menu menu = new Menu();
|
Menu menu = new Menu();
|
||||||
Labyrinthe lab=menu.nouvellePartie();
|
Labyrinthe lab=menu.nouvellePartie();
|
||||||
JeuSalle salle = new JeuSalle();
|
JeuSalle salle = new JeuSalle();
|
||||||
Marche marche= (Marche) lab.listePorte.get(0).getSalle1();
|
Marche marche= (Marche) lab.listePorte.get(0).getSalle1();
|
||||||
salle.ecrire(marche.creerObjetsAVendre(lab));
|
panel =salle.ecrire(marche.creerObjetsAVendre(lab));
|
||||||
repaint();
|
repaint();
|
||||||
//Bug
|
//Bug
|
||||||
//Personnage perso = menu.menuSelection(lab);
|
//Personnage perso = menu.menuSelection(lab);
|
||||||
//System.out.println();
|
//System.out.println();
|
||||||
salle.ecrire(menu.textePerso(lab));
|
panel =salle.ecrire(menu.textePerso(lab));
|
||||||
|
//salle.cacher(panel);
|
||||||
|
//menu.menuSelection(lab);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(source==continuer) {
|
if(source==continuer) {
|
||||||
Menu menu = new Menu();
|
Menu menu = new Menu();
|
||||||
Labyrinthe lab = menu.continuer();
|
Labyrinthe lab = menu.continuer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Labyrinthe choix(Object source) {
|
||||||
|
if(source==nouvelle) {
|
||||||
|
Menu menu = new Menu();
|
||||||
|
Labyrinthe lab=menu.nouvellePartie();
|
||||||
|
return lab;
|
||||||
|
}
|
||||||
|
if(source==nouvelle) {
|
||||||
|
Menu menu = new Menu();
|
||||||
|
Labyrinthe lab = menu.continuer();
|
||||||
|
return lab;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ public class main {
|
|||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
|
public jeu fenetre;
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
SwingUtilities.invokeLater(new Runnable(){
|
SwingUtilities.invokeLater(new Runnable(){
|
||||||
|
@ -68,7 +68,7 @@ public class Menu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Personnage menuSelection(Labyrinthe lab) {
|
public Personnage menuSelection(Labyrinthe lab, JeuSalle salle) {
|
||||||
System.out.println("Bonjour Etranger, je suis le narrateur de votre histoire. Comment dois-je vous appeler ? ");
|
System.out.println("Bonjour Etranger, je suis le narrateur de votre histoire. Comment dois-je vous appeler ? ");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Personnage per : lab.listePersonnage) {
|
for (Personnage per : lab.listePersonnage) {
|
||||||
@ -77,7 +77,8 @@ public class Menu {
|
|||||||
|
|
||||||
Personnage pers;
|
Personnage pers;
|
||||||
try{
|
try{
|
||||||
pers =lab.listePersonnage.get(Clavier.entrerClavierInt());
|
pers =lab.listePersonnage.get(salle.nb);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
System.out.println("Le personnage dont vous me parlez n'existe pas.");
|
System.out.println("Le personnage dont vous me parlez n'existe pas.");
|
||||||
|
Loading…
Reference in New Issue
Block a user