update
This commit is contained in:
101
DEV.2.1/test/Direction.java
Normal file
101
DEV.2.1/test/Direction.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* La classe <code>Direction</code> est utilisée pour signifier une orientation possible
|
||||
* parmi les quatre points cardinaux.
|
||||
*
|
||||
* @version 1.1
|
||||
* @author Luc Hernandez
|
||||
*/
|
||||
public class Direction {
|
||||
|
||||
/**
|
||||
* Constante pointant vers le nord (c'est à dire vers le haut de l'écran).
|
||||
*/
|
||||
public static final Direction NORD = new Direction(+0, -1);
|
||||
|
||||
/**
|
||||
* Constante pointant vers le sud (c'est à dire vers le bas de l'écran).
|
||||
*/
|
||||
public static final Direction SUD = new Direction(+0, +1);
|
||||
|
||||
/**
|
||||
* Constante pointant vers l'est (c'est à dire vers la droite de l'écran).
|
||||
*/
|
||||
public static final Direction EST = new Direction(+1, +0);
|
||||
|
||||
/**
|
||||
* Constante pointant vers l'ouest (c'est à dire vers la gauche de l'écran).
|
||||
*/
|
||||
public static final Direction OUEST = new Direction(-1, +0);
|
||||
|
||||
/**
|
||||
* Composante horizontale de la direction (-1, 0 ou 1).
|
||||
*/
|
||||
private int decalageX;
|
||||
|
||||
/**
|
||||
* Composante verticale de la direction (-1, 0 ou 1).
|
||||
*/
|
||||
private int decalageY;
|
||||
|
||||
/**
|
||||
* Constructeur uniquement destiné à la création des constantes publiques.
|
||||
*
|
||||
* @param x l'abcisse (-1, 0 ou 1)
|
||||
* @param y l'ordonnée (-1, 0 ou 1)
|
||||
*/
|
||||
private Direction(int x, int y) {
|
||||
this.decalageX = x;
|
||||
this.decalageY = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la composante horizontale de la direction.
|
||||
*
|
||||
* @return la composante horizontale de la direction (-1, 0 ou 1)
|
||||
*/
|
||||
public int getDecalageX() {
|
||||
return this.decalageX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la composante verticale de la direction.
|
||||
*
|
||||
* @return la composante verticale de la direction (-1, 0 ou 1)
|
||||
*/
|
||||
public int getDecalageY() {
|
||||
return this.decalageY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la direction produite par un quart de tour dans le sens horaire.
|
||||
*
|
||||
* @return la nouvelle direction
|
||||
*/
|
||||
public Direction quartDeTour() {
|
||||
if (this == Direction.NORD)
|
||||
return Direction.EST;
|
||||
else if (this == Direction.EST)
|
||||
return Direction.SUD;
|
||||
else if (this == Direction.SUD)
|
||||
return Direction.OUEST;
|
||||
else // if (this == Direction.OUEST)
|
||||
return Direction.NORD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la direction produite par un quart de tour dans le sens anti-horaire.
|
||||
*
|
||||
* @return la nouvelle direction
|
||||
*/
|
||||
public Direction quartDeTourAnti() {
|
||||
if (this == Direction.NORD)
|
||||
return Direction.OUEST;
|
||||
else if (this == Direction.EST)
|
||||
return Direction.NORD;
|
||||
else if (this == Direction.SUD)
|
||||
return Direction.EST;
|
||||
else // if (this == Direction.OUEST)
|
||||
return Direction.SUD;
|
||||
}
|
||||
|
||||
}
|
||||
8
DEV.2.1/test/test.1/Fenetre.java
Normal file
8
DEV.2.1/test/test.1/Fenetre.java
Normal file
@@ -0,0 +1,8 @@
|
||||
public class Fenetre extends JFrame {
|
||||
public Fenetre() {
|
||||
super("SameGame");
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
this.setSize()
|
||||
}
|
||||
}
|
||||
6
DEV.2.1/test/test.1/Main.java
Normal file
6
DEV.2.1/test/test.1/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void mmain(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
26
DEV.2.1/test/test.1/PaintFenetre.java
Normal file
26
DEV.2.1/test/test.1/PaintFenetre.java
Normal file
@@ -0,0 +1,26 @@
|
||||
import.javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class PaintFenetre extends JPanel {
|
||||
|
||||
private Image MenuDebut;
|
||||
public PaintFenetre() {
|
||||
super();
|
||||
this.MenuDebut = Toolkit.getDefaultToolkit().getImage("../image/MenuDebut.jpg");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
|
||||
if(this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
secondPinceau.clearRect(0, 0, this.getWidth(), this.getHeight());
|
||||
secondPinceau.drawImage(this.Menu, this.getWidth(), this.getHeight(), this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user