Merge branch 'main' of https://git.goegy.online/m.meiringer/Pacman
This commit is contained in:
commit
a5e0b2d32a
BIN
Pacman.class
Normal file
BIN
Pacman.class
Normal file
Binary file not shown.
12
Pacman.ctxt
Normal file
12
Pacman.ctxt
Normal 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
31
Pacman.java
Normal 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);
|
||||
}
|
||||
}
|
||||
BIN
game.class
BIN
game.class
Binary file not shown.
@ -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
|
||||
|
||||
26
game.java
26
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},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user