java 补充Egg 代码
import java.awt.Color;import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.Random;
public class Egg {
public int getRow() {
return row;
}
public void setRow(int row) {
this.row = row;
}
public int getCol() {
return col;
}
public void setCol(int col) {
this.col = col;
}
int row,col;
int w = Yard.BLOCK_SIZE;
int h = Yard.BLOCK_SIZE;
private static Random r = new Random();
public Egg(int row, int col) {
super();
this.row = row;
this.col = col;
}
public Egg() {
this(r.nextInt(Yard.ROWS-3)+3,r.nextInt(Yard.COLS));
}
public void reAppear() {
this.row = r.nextInt(Yard.ROWS-3)+3;
this.col = r.nextInt(Yard.COLS);
}
public Rectangle getRect() {
return new Rectangle(Yard.BLOCK_SIZE*col,Yard.BLOCK_SIZE*row,w,h);
}
public void draw(Graphics g) {
Color c = g.getColor();
g.setColor(Color.GREEN);
g.fillOval(Yard.BLOCK_SIZE*col, Yard.BLOCK_SIZE*row, w, h);
g.setColor(c);
}
}
昨天没有发帖子今天补上了拿来给大家分享 我也是刚刚写完的啊 有什么不对的 希望大家可以指出来!:keai
这JAVA代码是做什么用的,不太明白 sumile 发表于 2016-11-14 22:45
这JAVA代码是做什么用的,不太明白
这是我每天更新的一个贪吃蛇游戏代码,请多多支持。{:1_1:}
页:
[1]