Fenetre 2 en cours mais bug, keylister en cours fonctionnel mais non connecté au boundary
This commit is contained in:
parent
eea9162ef4
commit
21744392ca
85
JAVA/PROJET-PMT_STRI1A/src/gui/JeuSalle.java
Normal file
85
JAVA/PROJET-PMT_STRI1A/src/gui/JeuSalle.java
Normal file
@ -0,0 +1,85 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package gui;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
* @author nicolas
|
||||
*
|
||||
*/
|
||||
public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
||||
|
||||
public JeuSalle() {
|
||||
setTitle("Labyrinthe");
|
||||
setSize(1200,600);
|
||||
setLocationRelativeTo(null);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
//setContentPane(ecrire("test"));
|
||||
//JScrollPane test = new JScrollPane();
|
||||
//setContentPane(test);
|
||||
this.setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
public JPanel ecrire(String str) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new FlowLayout());
|
||||
JLabel label = new JLabel(str);
|
||||
panel.add(label);
|
||||
this.setFocusable(true);
|
||||
this.setContentPane(panel);
|
||||
this.addKeyListener(this);
|
||||
this.requestFocus();
|
||||
|
||||
return panel;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
|
||||
*/
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
System.out.println("keyPressed");
|
||||
int code=e.getKeyCode();
|
||||
String key =e.getKeyText(code);
|
||||
System.out.println(key);
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
|
||||
*/
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
||||
*/
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -8,8 +8,10 @@ import java.awt.Color;
|
||||
|
||||
import gui.Boutton;
|
||||
import modeles.Labyrinthe;
|
||||
import modeles.Marche;
|
||||
import modeles.Menu;
|
||||
import modeles.Objet;
|
||||
import modeles.Personnage;
|
||||
import gui.Background;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
@ -92,6 +94,14 @@ public class jeu extends JFrame implements ActionListener {
|
||||
if(source==nouvelle) {
|
||||
Menu menu = new Menu();
|
||||
Labyrinthe lab=menu.nouvellePartie();
|
||||
JeuSalle salle = new JeuSalle();
|
||||
Marche marche= (Marche) lab.listePorte.get(0).getSalle1();
|
||||
salle.ecrire(marche.creerObjetsAVendre(lab));
|
||||
repaint();
|
||||
//Bug
|
||||
//Personnage perso = menu.menuSelection(lab);
|
||||
//System.out.println();
|
||||
salle.ecrire(menu.textePerso(lab));
|
||||
}
|
||||
if(source==continuer) {
|
||||
Menu menu = new Menu();
|
||||
|
@ -23,7 +23,9 @@ public class main {
|
||||
public void run(){
|
||||
//On crée une nouvelle instance de notre JDialog
|
||||
jeu fenetre = null;
|
||||
|
||||
try {
|
||||
|
||||
fenetre = new jeu();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
@ -9,7 +9,7 @@ public class Labyrinthe {
|
||||
protected List<Personnage> listePersonnage=new ArrayList<Personnage>();
|
||||
protected List<Arme> listeArme= new ArrayList<Arme>();
|
||||
protected List<Armure> listeArmure=new ArrayList<Armure>();
|
||||
protected List<Porte> listePorte=new ArrayList<Porte>();
|
||||
public List<Porte> listePorte=new ArrayList<Porte>();
|
||||
protected List<Monstre> listeMonstre=new ArrayList<Monstre>();
|
||||
|
||||
public Labyrinthe() {
|
||||
|
@ -19,17 +19,18 @@ public class Marche extends Salle {
|
||||
public String creerObjetsAVendre(Labyrinthe lab) {
|
||||
String listeSarme="";
|
||||
String listeSarmure="";
|
||||
String listeobjet="";
|
||||
String listeobjet="<html>";
|
||||
int i = 0;
|
||||
int j =0;
|
||||
|
||||
for (Arme arme : lab.listeArme) listeSarme +=i++ +") "+ arme.getNom() + " au prix de : " + arme.getPrix()+"\n";
|
||||
|
||||
for (Armure armure : lab.listeArmure) listeSarmure +=j++ +") "+ armure.getNom()+ " au prix de : " + armure.getPrix()+"\n";
|
||||
for (Arme arme : lab.listeArme) listeSarme += "<br>" + i++ +") "+ arme.getNom() + " au prix de : " + arme.getPrix()+"</br>";
|
||||
|
||||
for (Armure armure : lab.listeArmure) listeSarmure += "<br>"+ j++ +") "+ armure.getNom()+ " au prix de : " + armure.getPrix()+"</br>";
|
||||
|
||||
|
||||
listeobjet = "Armes :\n" + listeSarme + "\nArmures :\n" + listeSarmure;
|
||||
|
||||
listeobjet ="<html>" + "Armes :\n" + listeSarme +"<br></br>"+ "\nArmures :\n" + listeSarmure;
|
||||
listeobjet=listeobjet+"</html>";
|
||||
return listeobjet;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
package modeles;
|
||||
|
||||
import gui.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
public class Menu {
|
||||
@ -140,12 +140,25 @@ public class Menu {
|
||||
}
|
||||
public Labyrinthe nouvellePartie() {
|
||||
System.out.println("Nouvelle partie!");
|
||||
|
||||
return new Labyrinthe();
|
||||
}
|
||||
|
||||
public Labyrinthe continuer() {
|
||||
System.out.println("Continuer");
|
||||
Generateur ge = new Generateur();
|
||||
return ge.labyrinthe();
|
||||
}
|
||||
public String textePerso(Labyrinthe lab) {
|
||||
String str ="<html>";
|
||||
str = str + "<br>Bonjour Etranger, je suis le narrateur de votre histoire. Comment dois-je vous appeler ? </br>";
|
||||
int i = 0;
|
||||
for (Personnage per : lab.listePersonnage) {
|
||||
str =str + "<br>" + (i++ + ") "+per.getNom())+"</br>";
|
||||
}
|
||||
str=str+"</html>";
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user