diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e10e727 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.metadata/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6d143aa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cSpell.words": [ + "Pacman", + "pdlo" + ] +} \ No newline at end of file diff --git a/Pacman/.classpath b/Pacman/.classpath new file mode 100644 index 0000000..dddf7ec --- /dev/null +++ b/Pacman/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Pacman/.gitignore b/Pacman/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Pacman/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Pacman/.project b/Pacman/.project new file mode 100644 index 0000000..0a52e7e --- /dev/null +++ b/Pacman/.project @@ -0,0 +1,28 @@ + + + Pacman + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1712395080124 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Pacman/.settings/org.eclipse.core.resources.prefs b/Pacman/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Pacman/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Pacman/.settings/org.eclipse.jdt.core.prefs b/Pacman/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f2525a8 --- /dev/null +++ b/Pacman/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/Pacman/src/fr/eseo/e3e/pdlo/entities/Bonus.java b/Pacman/src/fr/eseo/e3e/pdlo/entities/Bonus.java new file mode 100644 index 0000000..8142430 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/entities/Bonus.java @@ -0,0 +1,27 @@ +package fr.eseo.e3e.pdlo.entities; + +import fr.eseo.e3e.pdlo.utils.Direction; + +public class Bonus extends Entity { + + private boolean collected; + private int value; + + public Bonus(int x, int y) { + super(x, y); + this.collected = false; + } + + public void collect() { + this.collected = true; + + } + public int getValue(){ + return this.value; + } + + @Override + public void move(Direction direction) { + + } +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/entities/Entity.java b/Pacman/src/fr/eseo/e3e/pdlo/entities/Entity.java new file mode 100644 index 0000000..5ff34bc --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/entities/Entity.java @@ -0,0 +1,36 @@ +/** + * + */ +package fr.eseo.e3e.pdlo.entities; + +import fr.eseo.e3e.pdlo.utils.Direction; + +/** + * + */ +public abstract class Entity { + protected int x, y; + + public Entity(int x, int y) { + this.x = x; + this.y = y; + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public abstract void move(Direction direction); +} \ No newline at end of file diff --git a/Pacman/src/fr/eseo/e3e/pdlo/entities/Ghost.java b/Pacman/src/fr/eseo/e3e/pdlo/entities/Ghost.java new file mode 100644 index 0000000..91620e3 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/entities/Ghost.java @@ -0,0 +1,30 @@ +/** + * + */ +package fr.eseo.e3e.pdlo.entities; + +import fr.eseo.e3e.pdlo.utils.Direction; + +/** + * + */ +public class Ghost extends Entity { + private boolean isScared; + + public Ghost(int x, int y) { + super(x, y); + } + + + public void moveRamdomly(Direction direction) { + + } + public void chasePacman(){} + + + @Override + public void move(Direction direction) { + throw new UnsupportedOperationException("Unimplemented method 'move'"); + } + +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/entities/PacMan.java b/Pacman/src/fr/eseo/e3e/pdlo/entities/PacMan.java new file mode 100644 index 0000000..a82081f --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/entities/PacMan.java @@ -0,0 +1,38 @@ +/** + * + */ +package fr.eseo.e3e.pdlo.entities; + +import fr.eseo.e3e.pdlo.utils.Coordonnees; +import fr.eseo.e3e.pdlo.utils.Direction; + +/** + * + */ +public class PacMan extends Entity { + private int score; + private Coordonnees position; + private boolean dead = false; + + public PacMan(int x, int y) { + super(x, y); + this.score = 0; + } + + @Override + public void move(Direction direction) { + + } + + public void eatBonus(Bonus bonus) { + this.score+=bonus.getValue(); + + } + public void die() { + this.dead = true; + } + + public boolean isDead() { + return dead; + } +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/gui/GamePanel.java b/Pacman/src/fr/eseo/e3e/pdlo/gui/GamePanel.java new file mode 100644 index 0000000..44ebaae --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/gui/GamePanel.java @@ -0,0 +1,86 @@ +package fr.eseo.e3e.pdlo.gui; + +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.BasicStroke; + +import fr.eseo.e3e.pdlo.levels.Maze; + +public class GamePanel extends JPanel { + private final Maze maze; + + + private final Color mazeColor = new Color(5, 100, 5); + private final Color dotColor = Color.YELLOW; + + public GamePanel() { + + short[] levelData = { + 19, 26, 26, 26, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 22, + 21, 0, 0, 0, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 20, + 21, 0, 0, 0, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 20, + 21, 0, 0, 0, 17, 16, 16, 24, 16, 16, 16, 16, 16, 16, 20, + 17, 18, 18, 18, 16, 16, 20, 0, 17, 16, 16, 16, 16, 16, 20, + 17, 16, 16, 16, 16, 16, 20, 0, 17, 16, 16, 16, 16, 24, 20, + 25, 16, 16, 16, 24, 24, 28, 0, 25, 24, 24, 16, 20, 0, 21, + 1, 17, 16, 20, 0, 0, 0, 0, 0, 0, 0, 17, 20, 0, 21, + 1, 17, 16, 16, 18, 18, 22, 0, 19, 18, 18, 16, 20, 0, 21, + 1, 17, 16, 16, 16, 16, 20, 0, 17, 16, 16, 16, 20, 0, 21, + 1, 17, 16, 16, 16, 16, 20, 0, 17, 16, 16, 16, 20, 0, 21, + 1, 17, 16, 16, 16, 16, 16, 18, 16, 16, 16, 16, 20, 0, 21, + 1, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 20, 0, 21, + 1, 25, 24, 24, 24, 24, 24, 24, 24, 24, 16, 16, 16, 18, 20, + 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 25, 24, 24, 24, 28 + + }; + maze = new Maze(levelData); + setPreferredSize(new Dimension(300, 300)); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + drawMaze((Graphics2D) g); + } + + private void drawMaze(Graphics2D g2d) { + short[] screenData = maze.getScreenData(); + int blockSize = maze.getBlockSize(); + int nBlocks = maze.getNBlocks(); + int screenSize = nBlocks * blockSize; + + int i = 0; + for (int y = 0; y < screenSize; y += blockSize) { + for (int x = 0; x < screenSize; x += blockSize) { + g2d.setColor(mazeColor); + g2d.setStroke(new BasicStroke(2)); + + if ((screenData[i] & 1) != 0) { + g2d.drawLine(x, y, x, y + blockSize - 1); + } + + if ((screenData[i] & 2) != 0) { + g2d.drawLine(x, y, x + blockSize - 1, y); + } + + if ((screenData[i] & 4) != 0) { + g2d.drawLine(x + blockSize - 1, y, x + blockSize - 1, y + blockSize - 1); + } + + if ((screenData[i] & 8) != 0) { + g2d.drawLine(x, y + blockSize - 1, x + blockSize - 1, y + blockSize - 1); + } + + if ((screenData[i] & 16) != 0) { + g2d.setColor(dotColor); + g2d.fillRect(x + 11, y + 11, 2, 2); + } + + i++; + } + } + } +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/gui/GameWindow.java b/Pacman/src/fr/eseo/e3e/pdlo/gui/GameWindow.java new file mode 100644 index 0000000..8c88d26 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/gui/GameWindow.java @@ -0,0 +1,24 @@ +package fr.eseo.e3e.pdlo.gui; + +import javax.swing.JFrame; +import javax.swing.WindowConstants; + +public class GameWindow extends JFrame { + private GamePanel gamePanel; + + public GameWindow() { + setTitle("PacMan Game"); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setResizable(false); + + gamePanel = new GamePanel(); + add(gamePanel); + pack(); + setLocationRelativeTo(null); + setVisible(true); + } + + public static void main(String[] args) { + new GameWindow(); + } +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/levels/Cell.java b/Pacman/src/fr/eseo/e3e/pdlo/levels/Cell.java new file mode 100644 index 0000000..d4d5048 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/levels/Cell.java @@ -0,0 +1,59 @@ +/** + * + */ +package fr.eseo.e3e.pdlo.levels; + +import fr.eseo.e3e.pdlo.utils.CellType; + +/** + * + */ +public class Cell { + private boolean isWall; + private boolean hasBonus; + private boolean hasGhost; + private CellType type; + + + public Cell(boolean isWall) { + this.isWall = isWall; + this.hasBonus = false; + this.hasGhost = false; + } + public boolean isWalkable() { + return this.type == CellType.PATH || this.type == CellType.BONUS || this.type == CellType.SUPER_BONUS; + } + + + public boolean isWall() { + return isWall; + } + + public void setWall(boolean isWall) { + this.isWall = isWall; + } + public CellType getType() { + return type; + } + + public void setType(CellType type) { + this.type = type; + } + + public boolean hasBonus() { + return hasBonus; + } + + public void setBonus(boolean hasBonus) { + this.hasBonus = hasBonus; + } + + public boolean hasGhost() { + return hasGhost; + } + + public void setGhost(boolean hasGhost) { + this.hasGhost = hasGhost; + } + +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/levels/Maze.java b/Pacman/src/fr/eseo/e3e/pdlo/levels/Maze.java new file mode 100644 index 0000000..45fa98d --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/levels/Maze.java @@ -0,0 +1,25 @@ +package fr.eseo.e3e.pdlo.levels; + +public class Maze { + public static final int BLOCK_SIZE = 24; + public static final int N_BLOCKS = 15; + public static final int SCREEN_SIZE = N_BLOCKS * BLOCK_SIZE; + private final short[] screenData; + + + public Maze(short[] screenData) { + this.screenData = screenData; + } + + public int getBlockSize() { + return BLOCK_SIZE; + } + + public int getNBlocks() { + return N_BLOCKS; + } + + public short[] getScreenData() { + return screenData; + } +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down1.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down1.png new file mode 100644 index 0000000..fa6b768 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down1.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down2.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down2.png new file mode 100644 index 0000000..be8e24f Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down2.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down3.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down3.png new file mode 100644 index 0000000..9f3a025 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/down3.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/gameOver.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/gameOver.png new file mode 100644 index 0000000..dad7ddc Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/gameOver.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/ghost.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/ghost.png new file mode 100644 index 0000000..84ecf01 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/ghost.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left1.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left1.png new file mode 100644 index 0000000..18e1582 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left1.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left2.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left2.png new file mode 100644 index 0000000..5272b45 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left2.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left3.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left3.png new file mode 100644 index 0000000..dcc00ba Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/left3.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/maze.map b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/maze.map new file mode 100644 index 0000000..1ff1551 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/maze.map @@ -0,0 +1,36 @@ + + + +++++++++++++++++++++++++++++ ++............++............+ ++.++++.+++++.++.+++++.++++.+ ++*+ +.+ +.++.+ +.+ +*+ ++.++++.+++++.++.+++++.++++.+ ++..........................+ ++.++++.++.++++++++.++.++++.+ ++.++++.++.++++++++.++.++++.+ ++......++....++....++......+ +++++++.+++++ ++ +++++.++++++ + +.+++++ ++ +++++.+ + +.++ ++.+ + +.++ +++--+++ ++.+ +++++++.++ + + ++.++++++ + . + + . +++++++.++ + + ++.++++++ + +.++ ++++++++ ++.+ + +.++ ++.+ + +.++ ++++++++ ++.+ +++++++.++ ++++++++ ++.++++++ ++............++............+ ++.++++.+++++.++.+++++.++++.+ ++.++++.+++++.++.+++++.++++.+ ++*..++....... .......++..*+ ++++.++.++.++++++++.++.++.+++ ++++.++.++.++++++++.++.++.+++ ++......++....++....++......+ ++.++++++++++.++.++++++++++.+ ++.++++++++++.++.++++++++++.+ ++..........................+ +++++++++++++++++++++++++++++ + + diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/pacman.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/pacman.png new file mode 100644 index 0000000..e1ed87e Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/pacman.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right1.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right1.png new file mode 100644 index 0000000..3ed04d6 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right1.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right2.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right2.png new file mode 100644 index 0000000..b20263c Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right2.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right3.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right3.png new file mode 100644 index 0000000..c8ce554 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/right3.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/titleScreen.jpg b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/titleScreen.jpg new file mode 100644 index 0000000..067ccc7 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/titleScreen.jpg differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up1.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up1.png new file mode 100644 index 0000000..9ef859f Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up1.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up2.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up2.png new file mode 100644 index 0000000..206cf8a Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up2.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up3.png b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up3.png new file mode 100644 index 0000000..cf9ccbf Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/up3.png differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/walled_maze.map b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/walled_maze.map new file mode 100644 index 0000000..ccd9b53 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/walled_maze.map @@ -0,0 +1,36 @@ + + + +3666666666666436666666666664 +5............55............5 +5.3664.36664.55.36664.3664.5 +5*5 5.5 5.55.5 5.5 5*5 +5.1662.16662.12.16662.1662.5 +5..........................5 +5.3664.34.36666664.34.3664.5 +5.1662.55.16643662.55.1662.5 +5......55....55....55......5 +166664.51664 55 36625.366662 + 5.53662 12 16645.5 + 5.55 55.5 + 5.55 36677664 55.5 +666662.12 5 5 12.166666 + . 5 5 . +666664.34 5 5 34.366666 + 5.55 16666662 55.5 + 5.55 55.5 + 5.55 36666664 55.5 +366662.12 16643662 12.166664 +5............55............5 +5.3664.36664.55.36664.3664.5 +5.1645.16662.12.16662.5362.5 +5*..55....... .......55..*5 +164.55.34.36666664.34.55.362 +362.12.55.16643662.55.12.164 +5......55....55....55......5 +5.3666621664.55.3662166664.5 +5.1666666662.12.1666666662.5 +5..........................5 +1666666666666666666666666662 + + diff --git a/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/winScreen.jpg b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/winScreen.jpg new file mode 100644 index 0000000..6d18584 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/ressources/images/winScreen.jpg differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/screen/TitleScreen.class b/Pacman/src/fr/eseo/e3e/pdlo/screen/TitleScreen.class new file mode 100644 index 0000000..dcd2d65 Binary files /dev/null and b/Pacman/src/fr/eseo/e3e/pdlo/screen/TitleScreen.class differ diff --git a/Pacman/src/fr/eseo/e3e/pdlo/screen/TitleScreen.java b/Pacman/src/fr/eseo/e3e/pdlo/screen/TitleScreen.java new file mode 100644 index 0000000..2f76cc5 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/screen/TitleScreen.java @@ -0,0 +1,58 @@ +package fr.eseo.e3e.pdlo.screen; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class TitleScreen extends JPanel implements KeyListener { + + private Image titleImage; + public TitleScreen() { + + titleImage = new ImageIcon(getClass().getResource("../ressources/images/titleScreen.jpg")).getImage(); + addKeyListener(this); + setFocusable(true); + setPreferredSize(new Dimension(titleImage.getWidth(null), titleImage.getHeight(null))); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.drawImage(titleImage, 0, 0, this); + } + + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_N) { + System.out.println("Création du labyrinthe..."); + + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + + public void setFrame(JFrame frame) { + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> { + JFrame frame = new JFrame("Pac-Man"); + TitleScreen titleScreen = new TitleScreen(); + titleScreen.setFrame(frame); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(titleScreen); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + } +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/utils/CellType.java b/Pacman/src/fr/eseo/e3e/pdlo/utils/CellType.java new file mode 100644 index 0000000..ca1ceaf --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/utils/CellType.java @@ -0,0 +1,6 @@ +package fr.eseo.e3e.pdlo.utils; + +public enum CellType { + WALL, PATH, BONUS, SUPER_BONUS, GHOST_SPAWN, PACMAN_SPAWN + +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/utils/Coordonnees.java b/Pacman/src/fr/eseo/e3e/pdlo/utils/Coordonnees.java new file mode 100644 index 0000000..b374385 --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/utils/Coordonnees.java @@ -0,0 +1,39 @@ +/** + * + */ + +/** + * + */ +package fr.eseo.e3e.pdlo.utils; + +public class Coordonnees { + private int x; + private int y; + + public Coordonnees(int x, int y) { + this.x = x; + this.y = y; + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + @Override + public String toString() { + return "(" + x + ", " + y + ")"; + } +} diff --git a/Pacman/src/fr/eseo/e3e/pdlo/utils/Direction.java b/Pacman/src/fr/eseo/e3e/pdlo/utils/Direction.java new file mode 100644 index 0000000..3f72dff --- /dev/null +++ b/Pacman/src/fr/eseo/e3e/pdlo/utils/Direction.java @@ -0,0 +1,30 @@ +package fr.eseo.e3e.pdlo.utils; + +import java.awt.event.KeyEvent; + +public enum Direction { + UP(KeyEvent.VK_UP), + DOWN(KeyEvent.VK_DOWN), + LEFT(KeyEvent.VK_LEFT), + RIGHT(KeyEvent.VK_RIGHT); + + private final int keyCode; + + Direction(int keyCode) { + this.keyCode = keyCode; + } + + public int getKeyCode() { + return keyCode; + } + + + public static Direction fromKeyCode(int keyCode) { + for (Direction direction : Direction.values()) { + if (direction.getKeyCode() == keyCode) { + return direction; + } + } + return null; + } +}