package com.java4_18.snak05; import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; public class Food { int row; int col; Food(){ row = 10; col = 10; } public void draw(Graphics g) { g.setColor(Color.RED); g.fillRect(col*Config.span, row*Config.span, Config.span, Config.span); } //食物的位置 public Rectangle getFoodRectangle(){ return new Rectangle(col*Config.span, row*Config.span, Config.span, Config.span); } public void repair(){ row = (int)(Math.floor(Math.random()*22)); col = (int)(Math.floor(Math.random()*35)); } }
最近下载更多