egg.java
来自「用java开发的贪吃蛇程序」· Java 代码 · 共 44 行
JAVA
44 行
package com.bjsxt.snake;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
public class Egg {
private int row, col;
public int getCol() {
return col;
}
public void setCol(int col) {
this.col = col;
}
public int getRow() {
return row;
}
public void setRow(int row) {
this.row = row;
}
public Egg(int row, int col) {
this.row = row;
this.col = col;
}
public void draw(Graphics g) {
Color c = g.getColor();
g.setColor(Color.RED);
g.fillOval(col*Yard.BLOCK_SIZE, row*Yard.BLOCK_SIZE, Yard.BLOCK_SIZE, Yard.BLOCK_SIZE);
g.setColor(c);
}
public Rectangle getRect() {
return new Rectangle(col*Yard.BLOCK_SIZE, row*Yard.BLOCK_SIZE, Yard.BLOCK_SIZE, Yard.BLOCK_SIZE);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?