This commit is contained in:
Vector 2026-06-25 12:37:10 +02:00
commit a5e0b2d32a
6 changed files with 74 additions and 3 deletions

BIN
Pacman.class Normal file

Binary file not shown.

12
Pacman.ctxt Normal file
View File

@ -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

31
Pacman.java Normal file
View File

@ -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);
}
}

Binary file not shown.

View File

@ -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

View File

@ -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},
};
}
}