diff --git a/Pacman.class b/Pacman.class new file mode 100644 index 0000000..92be23d Binary files /dev/null and b/Pacman.class differ diff --git a/Pacman.ctxt b/Pacman.ctxt new file mode 100644 index 0000000..511ca36 --- /dev/null +++ b/Pacman.ctxt @@ -0,0 +1,12 @@ +#BlueJ class context +comment0.target=Pacman +comment0.text=\r\n\ Klasse\ Pacman.\r\n\ \ \r\n\ @author\ \r\n +comment1.params=game +comment1.target=Pacman(Game) +comment1.text=---------------Konstruktor--- +comment2.params=keyCode +comment2.target=void\ keyPressed(int) +comment2.text=---------------Methoden------ +comment3.params= +comment3.target=void\ draw() +numComments=4 diff --git a/Pacman.java b/Pacman.java new file mode 100644 index 0000000..22a502e --- /dev/null +++ b/Pacman.java @@ -0,0 +1,31 @@ + +/** + * Klasse Pacman. + * + * @author + */ +public class Pacman { + /*---------------Attribute-----*/ + int x; + int y; + Game game; + int gameFrame; + + /*---------------Konstruktor---*/ + public Pacman(Game game) { + x = 20; y = 20; + this.game = game; + } + + /*---------------Methoden------*/ + public void keyPressed(int keyCode) { + if (keyCode == game.LEFT) { + x += game.cellSize; + } + } + + public void draw() { + gameFrame++; + game.render.drawPacman(x, y, (gameFrame/12) % 2 == 0); + } +} diff --git a/game.class b/game.class index c1fa65a..b40726a 100644 Binary files a/game.class and b/game.class differ diff --git a/game.ctxt b/game.ctxt index ff04ada..0a87090 100644 --- a/game.ctxt +++ b/game.ctxt @@ -8,4 +8,10 @@ comment2.target=void\ settings() comment2.text=---------------Methoden------ comment3.params= comment3.target=void\ draw() -numComments=4 +comment4.params= +comment4.target=void\ keyPressed() +comment5.params= +comment5.target=boolean\ wantMove() +comment6.params= +comment6.target=void\ populateWalls() +numComments=7 diff --git a/game.java b/game.java index 9851396..3e9e8fc 100644 --- a/game.java +++ b/game.java @@ -4,26 +4,48 @@ * * @author */ +import java.util.*; import processing.core.PApplet; public class Game extends PApplet{ /*---------------Attribute-----*/ int cellSize = 40; Render render; + Pacman pacman; + + int[][] wall; /*---------------Konstruktor---*/ public Game() { String[] processingArgs = {"MySketch"}; PApplet.runSketch(processingArgs, this); render = new Render(this); + pacman = new Pacman(this); + populateWalls(); } /*---------------Methoden------*/ public void settings() { - size(10 * cellSize, 10*cellSize); + size(10 * cellSize, 10 * cellSize); } public void draw() { - + background(0); + pacman.draw(); + } + + public void keyPressed() { + pacman.keyPressed(keyCode); + } + + public boolean wantMove() { + return true; + } + + public void populateWalls(){ + wall = new int[][]{ + {0, 0, 0, 1}, + {0, 1, 1, 1}, + }; } }