Skip to content
Snippets Groups Projects
Commit 17fc3e80 authored by Azurlors's avatar Azurlors
Browse files

Mise à jour classe UML

parent ddc001bb
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<artifactId>MAVENProject</artifactId> <artifactId>MAVENProject</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
......
...@@ -5,52 +5,25 @@ import engine.GameController; ...@@ -5,52 +5,25 @@ import engine.GameController;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
public class Controller { public class Controller implements GameController{
} /*
* commande en cours
*/
/**
package model;
import java.awt.event.KeyEvent;
import engine.Cmd;
import engine.GameController;
* @author Horatiu Cirstea, Vincent Thomas
*
* controleur de type KeyListener
*
public class PacmanController implements GameController {
* commande en cours
private Cmd commandeEnCours; private Cmd commandeEnCours;
/*
* construction du controleur par defaut le controleur n'a pas de commande
*/
* construction du controleur par defaut le controleur n'a pas de commande public Controller() {
public PacmanController() {
this.commandeEnCours = Cmd.IDLE; this.commandeEnCours = Cmd.IDLE;
} }
* quand on demande les commandes, le controleur retourne la commande en
* cours
*
* @return commande faite par le joueur
public Cmd getCommand() { public Cmd getCommand() {
return this.commandeEnCours; return this.commandeEnCours;
} }
@Override @Override
* met a jour les commandes en fonctions des touches appuyees
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
switch (e.getKeyChar()) { switch (e.getKeyChar()) {
...@@ -67,24 +40,16 @@ public class PacmanController implements GameController { ...@@ -67,24 +40,16 @@ public class PacmanController implements GameController {
this.commandeEnCours = Cmd.JUMP; this.commandeEnCours = Cmd.JUMP;
break; break;
} }
} }
@Override @Override
* met a jour les commandes quand le joueur relache une touche
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
this.commandeEnCours = Cmd.IDLE; this.commandeEnCours = Cmd.IDLE;
} }
@Override @Override
* ne fait rien
public void keyTyped(KeyEvent e) { public void keyTyped(KeyEvent e) {
} }
} }
**/ \ No newline at end of file
\ No newline at end of file
...@@ -7,40 +7,15 @@ import java.io.BufferedReader; ...@@ -7,40 +7,15 @@ import java.io.BufferedReader;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
public class Jeu { public class Jeu implements Game{
}
public Jeu(String source) {
/**
package model;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import engine.Cmd;
import engine.Game;
* @author Horatiu Cirstea, Vincent Thomas
*
* Version avec personnage qui peut se deplacer. A completer dans les
* versions suivantes.
*
public class PacmanGame implements Game {
* constructeur avec fichier source pour le help
*
public PacmanGame(String source) {
BufferedReader helpReader; BufferedReader helpReader;
try { try {
helpReader = new BufferedReader(new FileReader(source)); helpReader = new BufferedReader(new FileReader(source));
String ligne; String line;
while ((ligne = helpReader.readLine()) != null) { while ((line = helpReader.readLine()) != null) {
System.out.println(ligne); System.out.println(line);
} }
helpReader.close(); helpReader.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -48,27 +23,25 @@ public class PacmanGame implements Game { ...@@ -48,27 +23,25 @@ public class PacmanGame implements Game {
} }
} }
* faire evoluer le jeu suite a une commande
*
* @param commande
@Override @Override
public void evolve(Cmd commande) { public void evolve(Cmd commande) {
System.out.println("Execute "+commande); System.out.println("Execute "+commande);
if (commande == Cmd.LEFT) { switch (commande) {
case LEFT:
break;
case RIGHT:
break;
case JUMP:
break;
case IDLE:
break;
} }
} }
* verifier si le jeu est fini
@Override @Override
public boolean isFinished() { public boolean isFinished() {
// le jeu n'est jamais fini // le jeu n'est jamais fini
return false; return false;
} }
} }
**/ \ No newline at end of file
...@@ -5,44 +5,14 @@ import engine.GamePainter; ...@@ -5,44 +5,14 @@ import engine.GamePainter;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
public class Painter { public class Painter implements GamePainter{
}
/**
package model;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import engine.GamePainter;
* @author Horatiu Cirstea, Vincent Thomas
*
* afficheur graphique pour le game
*
public class PacmanPainter implements GamePainter {
* la taille des cases
protected static final int WIDTH = 1000; protected static final int WIDTH = 1000;
protected static final int HEIGHT = 100; protected static final int HEIGHT = 100;
public Painter() {
* appelle constructeur parent
*
* @param game
* le jeutest a afficher
public PacmanPainter() {
} }
* methode redefinie de Afficheur retourne une image du jeu
@Override @Override
public void draw(BufferedImage im) { public void draw(BufferedImage im) {
Graphics2D crayon = (Graphics2D) im.getGraphics(); Graphics2D crayon = (Graphics2D) im.getGraphics();
...@@ -59,6 +29,4 @@ public class PacmanPainter implements GamePainter { ...@@ -59,6 +29,4 @@ public class PacmanPainter implements GamePainter {
public int getHeight() { public int getHeight() {
return HEIGHT; return HEIGHT;
} }
} }
**/
\ No newline at end of file
package start; package start;
import model.PacmanPainter; import jeu.Painter;
import engine.GameEngineGraphical; import engine.GameEngineGraphical;
import model.PacmanController; import jeu.Controller;
import model.PacmanGame; import jeu.Jeu;
/** /**
* lancement du moteur avec le jeu * lancement du moteur avec le jeu
...@@ -13,9 +13,9 @@ public class Main { ...@@ -13,9 +13,9 @@ public class Main {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
// creation du jeu particulier et de son afficheur // creation du jeu particulier et de son afficheur
PacmanGame game = new PacmanGame("helpFilePacman.txt"); Jeu game = new Jeu("helpFilePacman.txt");
PacmanPainter painter = new PacmanPainter(); Painter painter = new Painter();
PacmanController controller = new PacmanController(); Controller controller = new Controller();
// classe qui lance le moteur de jeu generique // classe qui lance le moteur de jeu generique
GameEngineGraphical engine = new GameEngineGraphical(game, painter, controller); GameEngineGraphical engine = new GameEngineGraphical(game, painter, controller);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment