⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 player.java

📁 java tutorial all about java game design
💻 JAVA
字号:
import java.awt.Graphics;
import java.awt.Color;

public class Player
{
	// Variables
	private int x_pos;
	private int y_pos;

	public Player(int x, int y)
	{
		x_pos = x;
		y_pos = y;
	}

	public void moveX(int speed)
	{
		x_pos += speed;
	}

	public Shot generateShot()
	{
		Shot shot = new Shot(x_pos, y_pos);

		return shot;
	}

	public void drawPlayer(Graphics g)
	{
		g.setColor(Color.red);
		int [] x_poly = {x_pos, x_pos - 10, x_pos, x_pos + 10};
		int [] y_poly = {y_pos, y_pos + 15, y_pos + 10, y_pos + 15};
		g.fillPolygon(x_poly, y_poly, 4);
	}
}

⌨️ 快捷键说明

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