walls render

This commit is contained in:
Vector 2026-07-02 12:31:24 +02:00
parent 6abf958133
commit 3387848daa
5 changed files with 29 additions and 11 deletions

Binary file not shown.

View File

@ -4,8 +4,10 @@ comment0.text=\r\n\ Klasse\ render.\r\n\ \ \r\n\ @author\ \r\n
comment1.params=game comment1.params=game
comment1.target=Render(Game) comment1.target=Render(Game)
comment1.text=---------------Konstruktor--- comment1.text=---------------Konstruktor---
comment2.params=x\ y\ r\ g\ b\ visible comment2.params=wall
comment2.target=void\ drawGhost(int,\ int,\ int,\ int,\ int,\ boolean) comment2.target=void\ drawWall(int[])
comment3.params=x\ y\ open comment3.params=x\ y\ r\ g\ b\ visible
comment3.target=void\ drawPacman(int,\ int,\ boolean) comment3.target=void\ drawGhost(int,\ int,\ int,\ int,\ int,\ boolean)
numComments=4 comment4.params=x\ y\ open
comment4.target=void\ drawPacman(int,\ int,\ boolean)
numComments=5

View File

@ -15,7 +15,19 @@ public class Render {
} }
public void drawWall(int [] wall){
if(wall[0] == wall[2]){
game.strokeWeight(4);
game.stroke(255,255,0);
game.line(wall[0]*game.cellSize,wall[3]*game.cellSize,wall[0]*game.cellSize+game.cellSize ,wall[3]*game.cellSize );
}
else
{
game.strokeWeight(4);
game.stroke(255,255,0);
game.line(wall[0]*game.cellSize+game.cellSize,wall[1]*game.cellSize,wall[3]*game.cellSize ,wall[3]*game.cellSize+game.cellSize);
}
}
public void drawGhost(int x, int y, int r, int g, int b, boolean visible){ public void drawGhost(int x, int y, int r, int g, int b, boolean visible){
game.fill(r,g,b); game.fill(r,g,b);
game.strokeWeight(0); game.strokeWeight(0);
@ -43,7 +55,7 @@ public class Render {
} }
public void drawPacman(int x, int y, boolean open){ public void drawPacman(int x, int y, boolean open){
game.fill(255,255,0); game.fill(255,255,0);
game.strokeWeight(0);
if(open){ if(open){
game.arc(x,y,game.cellSize*0.8f,game.cellSize*0.8f, game.radians(45),game.radians(315)); game.arc(x,y,game.cellSize*0.8f,game.cellSize*0.8f, game.radians(45),game.radians(315));
game.fill(0); game.fill(0);

Binary file not shown.

View File

@ -25,13 +25,16 @@ public class Game extends PApplet{
/*---------------Methoden------*/ /*---------------Methoden------*/
public void settings() { public void settings() {
size(10 * cellSize, 10 * cellSize); size(11 * cellSize, 11 * cellSize);
} }
public void draw() { public void draw() {
background(0); background(0);
pacman.draw(); pacman.draw();
for (int i = 0; i < wall.length; i++) {
render.drawWall(wall[i]);
}
} }
public void keyPressed() { public void keyPressed() {
@ -39,7 +42,6 @@ public class Game extends PApplet{
} }
public boolean wantMove(int ox, int oy, int nx, int ny) { public boolean wantMove(int ox, int oy, int nx, int ny) {
System.out.println(","+ox+","+ oy+","+ nx+","+ ny);
if (ox == nx && oy > ny) { if (ox == nx && oy > ny) {
int a = oy; int a = oy;
oy = ny; oy = ny;
@ -60,8 +62,10 @@ public class Game extends PApplet{
public void populateWalls(){ public void populateWalls(){
wall = new int[][]{ wall = new int[][]{
{0, 0, 0, 1}, {0, 4, 0, 5},
{0, 1, 1, 1}, {0, 5, 0, 6},
{10,4,10,5},
{10,5,10,6},
}; };
} }
} }