资源简介
这个是塔防游戏的添加注释
代码片段和文件信息
package ui;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import javax.swing.Jframe;
public class baseframe extends Jframe implements MouseMotionListener {
/**
* 窗体宽
*/
private int w;
/**
* 窗体长
*/
private int h;
private int gameLocationX;
private int gameLocationY;
private int gameW;
private int gameH;
private int squaresSize;
private int focusX;
private int focusY;
int x y;
public baseframe() {
init();
this.setBounds(100 100 w h);
this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
this.setVisible(true);
this.addMouseMotionListener(this);
}
private void init() {
w = 800;
h = 600;
gameLocationX = 50;
gameLocationY = 50;
gameW = 700;
gameH = 400;
focusX = -100;
focusY = -100;
squaresSize = 50;
}
public void paint(Graphics gr) {
BufferedImage image = new BufferedImage(w h
BufferedImage.TYPE_3BYTE_BGR);
Graphics g2 = image.getGraphics();
g2.setColor(Color.white);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 14; j++) {
g2.drawRect(j * squaresSize + gameLocationX i * squaresSize
+ gameLocationY squaresSize squaresSize);
}
}
g2.setColor(Color.green);
g2.fillRect(focusX focusY squaresSize squaresSize);
gr.drawImage(image 0 0 this);
}
public static void main(String[] args) {
new baseframe();
}
public void mouseDragged(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseMoved(MouseEvent e) {
int x = e.getX();
int y = e.getY();
if (x > gameLocationX && x < gameLocationX + gameW && y > gameLocationY
&& y < gameLocationY + gameH) {
focusX = (x - gameLocationX) / squaresSize * squaresSize
+ squaresSize;
focusY = (y - gameLocationY) / squaresSize * squaresSize
+ squaresSize;
} else {
focusX = -100;
focusY = -100;
}
repaint();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-12-06 14:20 tower\
目录 0 2012-12-06 14:20 tower\TowerDefense1.1\
文件 226 2012-12-06 14:20 tower\TowerDefense1.1\.classpath
文件 371 2012-12-06 14:20 tower\TowerDefense1.1\.project
目录 0 2012-12-06 14:20 tower\TowerDefense1.1\bin\
目录 0 2012-12-06 14:20 tower\TowerDefense1.1\bin\ui\
文件 2410 2012-12-06 14:20 tower\TowerDefense1.1\bin\ui\ba
目录 0 2012-12-06 14:20 tower\TowerDefense1.1\src\
目录 0 2012-12-06 14:20 tower\TowerDefense1.1\src\ui\
文件 1972 2012-12-06 14:20 tower\TowerDefense1.1\src\ui\ba
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\
文件 226 2012-12-06 14:20 tower\TowerDefense1.2\.classpath
文件 371 2012-12-06 14:20 tower\TowerDefense1.2\.project
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\bin\
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\bin\control\
文件 769 2012-12-06 14:20 tower\TowerDefense1.2\bin\control\ba
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\bin\data\
文件 3575 2012-12-06 14:20 tower\TowerDefense1.2\bin\data\ba
文件 350 2012-12-06 14:20 tower\TowerDefense1.2\bin\data\Data.class
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\bin\model\
文件 615 2012-12-06 14:20 tower\TowerDefense1.2\bin\model\Ball.class
文件 2209 2012-12-06 14:20 tower\TowerDefense1.2\bin\model\Fighter.class
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\bin\thread\
文件 1445 2012-12-06 14:20 tower\TowerDefense1.2\bin\thread\FighterThread.class
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\bin\ui\
文件 3635 2012-12-06 14:20 tower\TowerDefense1.2\bin\ui\ba
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\src\
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\src\control\
文件 394 2012-12-06 14:20 tower\TowerDefense1.2\src\control\ba
目录 0 2012-12-06 14:20 tower\TowerDefense1.2\src\data\
文件 5297 2012-12-06 14:20 tower\TowerDefense1.2\src\data\ba
............此处省略240个文件信息
- 上一篇:java一个调色程序jar
- 下一篇:Java网络编程大作业,实现聊天室功能
相关资源
- Java网络编程大作业,实现聊天室功能
- java一个调色程序jar
- java小游戏
- java几何图形
- 京东苏宁爬虫java源码
- Java实现RSA加密解密数字证书生成与验
- java反编译exe
- Java图片压缩带EXIF信息
- Java基于UDP传输协议的简单聊天室
- Java把十进制转成二进制任意进制的程
- 教你java和C++的jni编程
- java画类图工具Tiny UML
- 基于JAVA的Tree树形菜单管理系统源代码
- java1.7版本API中文版最新
- ueditor java开发前后端分离 后端代码
- Java实现远程控制技术
- 获取百度网盘真实地址(java编写)
- 随机路点移动模型RWPJava代码
- 通信系统java
- java 九宫格拼图
- java 显示一个图像的轮廓
- MQTT消息队列mosquitto的java方式实现客户
- Java记事本源码和课程设计报告
- java-client-5.0.0-SNAPSHOT.jar
- 将JTable中的数据保存到Excel中
- 读取Excel数据到JTable
- Java多线程自动播放图片的小程序
- JAVA播放器的源代码 5个写法
-
Java 数据结构 ap
plet演示 - cmpp2.0 java实现
评论
共有 条评论