gold.java

来自「一个基于Java的小游戏」· Java 代码 · 共 31 行

JAVA
31
字号

import java.awt.*;

public class Gold {

	//The random position of gold.
	private int xGold ;
	private int yGold ;

	//The size of gole.
	private final int SIZE = 5;

	public Gold(int x, int y) {
		xGold = x;
		yGold = y;
	}

	//Display the gold in the random position.
	public void draw(Graphics g){
		g.setColor(Color.ORANGE);
		g.fillOval(xGold - SIZE, yGold - SIZE, SIZE * 2, SIZE * 2);
	}

	//information about the current gold.
	public int getCentreX(){
		return xGold;
	}
	public int getCentreY(){
		return yGold;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?