?? point.java
字號:
import java.util.Random;
import javax.microedition.lcdui.Graphics;
public class Point
{
public int x , y ;
Random r = new Random() ;
public Point(Snake s)
{
reset(s) ;
}
public void render(Graphics g)
{
g.setColor(0x6BF578) ;
g.fillArc(x , y , Snake.V , Snake.V , 0 , 360) ;
}
public void reset(Snake s) // 保證 我的點 不在蛇身上
{
boolean c = true ;
while(c)
{
x = Math.abs(r.nextInt() % (240 - Snake.V)) ;
y = Math.abs(r.nextInt() % (310 - Snake.V)) ;
c = s.isHit(x , y) ;
}
}
public boolean isHit(int _x , int _y)
{
if(Math.abs(x - _x) < Snake.V &&Math.abs(y - _y) < Snake.V)
{
return true ;
}
else
{
return false ;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -