📄 cpoint.java
字号:
package worm;import java.awt.*;/** * Title: CPoint.class * Description: main class of snake's body, and food point * Copyright: Copyright (c) 2004 * Company: * @author * @version 1.0 */public class CPoint { /* color of point*/ private Color color; /* x position of point*/ private int x; /* y position of point*/ private int y; /* the radius of the point*/ private int r; /* visible or not*/ private boolean visible; public CPoint() { } public CPoint(int initX, int initY,int initR,Color initCol) { x = initX; y = initY; r = initR; visible = false; color = initCol; } public void show() { this.visible = true; } public void hide() { this.visible = false; } public boolean isVisible() { return visible; }; public int getX() { return x; } public int getY() { return y; } public int getRadius() {return r;} public Color getColor() { return color; } public void setX(int newX) { x = newX; } public void setY(int newY) { y = newY; } public void setRadius(int newR) { this.r = newR; } public void setColor( Color col ) { color = col; } /*paint point in the screen */ public void paint(Graphics g) { /* fill the background in black*/ g.setColor(Color.black); g.fillRect(x-r,y-r,2*r,2*r); /* show the point in it's color*/ if(this.visible) { g.setColor(this.color); g.fillOval(x-r,y-r,2*r,2*r); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -