⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ghost.java

📁 用Java做的小游戏:Pacman 和小时候玩的吃豆豆一样
💻 JAVA
字号:
import cs101.lang.*;import java.util.*;import java.awt.*;import gaming.*;public abstract class Ghost extends DummyItem implements ScreenObject{       WalledSquare[][] walls;    Pacman pacman ;    boolean  Flag = true;    public abstract void move();    public Ghost(int x, int y, Pacman p )	{	   super( x, y,java.awt.Color.green,2);	   pacman = p;	 }	public int getX() {	return x;    }    public void setX(int xPos){                x = xPos;              }      public void setY(int yPos){                y = yPos;              }                 public int getY() {	return y;     }    public Color getColor() {	return this.color;    }      public Image getImage() {	return this.image;    }       public void Chase(Pacman p)    {       walls = PacmanBoard.getWalls();      if(pacman.getX()<x&&!walls[x][y].hasLeftWall())      x--;//if pacman is at the left of the ghost and there is no wall on the left of the ghost then move to left one step      else if(pacman.getY()<y&&!walls[x][y].hasUpperWall())       y--;//if pacman is at the uppper of the ghost and there is no wall on the upper of the ghost then move to upper one step      else if(pacman.getX()>x&&!walls[x][y].hasRightWall())       x++;//if pacman is at the right of the ghost and there is no wall on the right of the ghost then move to right one step      else if(pacman.getY()>y&&!walls[x][y].hasLowerWall())      y++;//if pacman is at the lower of the ghost and there is no wall on the lower of the ghost then move to lower one step        PacmanBoard.repaint();     } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -