资源简介
java 课程设计大作业 写的塔防小游戏(含完整注释)并且包含历次版本,可以学到是如何制作出一款游戏的

代码片段和文件信息
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 2018-06-20 21:38 TowerDefense1.1\
文件 226 2012-12-06 14:20 TowerDefense1.1\.classpath
文件 371 2012-12-06 14:20 TowerDefense1.1\.project
目录 0 2018-06-20 21:38 TowerDefense1.1\bin\
目录 0 2018-06-20 21:38 TowerDefense1.1\bin\ui\
文件 2410 2012-12-06 14:20 TowerDefense1.1\bin\ui\ba
目录 0 2018-06-20 21:38 TowerDefense1.1\src\
目录 0 2018-06-20 21:38 TowerDefense1.1\src\ui\
文件 1972 2012-12-06 14:20 TowerDefense1.1\src\ui\ba
目录 0 2018-06-20 21:38 TowerDefense1.2\
文件 226 2012-12-06 14:20 TowerDefense1.2\.classpath
文件 371 2012-12-06 14:20 TowerDefense1.2\.project
目录 0 2018-06-20 21:38 TowerDefense1.2\bin\
目录 0 2018-06-20 21:38 TowerDefense1.2\bin\control\
文件 769 2012-12-06 14:20 TowerDefense1.2\bin\control\ba
目录 0 2018-06-20 21:38 TowerDefense1.2\bin\data\
文件 3575 2012-12-06 14:20 TowerDefense1.2\bin\data\ba
文件 350 2012-12-06 14:20 TowerDefense1.2\bin\data\Data.class
目录 0 2018-06-20 21:38 TowerDefense1.2\bin\model\
文件 615 2012-12-06 14:20 TowerDefense1.2\bin\model\Ball.class
文件 2209 2012-12-06 14:20 TowerDefense1.2\bin\model\Fighter.class
目录 0 2018-06-20 21:38 TowerDefense1.2\bin\thread\
文件 1445 2012-12-06 14:20 TowerDefense1.2\bin\thread\FighterThread.class
目录 0 2018-06-20 21:38 TowerDefense1.2\bin\ui\
文件 3635 2012-12-06 14:20 TowerDefense1.2\bin\ui\ba
目录 0 2018-06-20 21:38 TowerDefense1.2\src\
目录 0 2018-06-20 21:38 TowerDefense1.2\src\control\
文件 394 2012-12-06 14:20 TowerDefense1.2\src\control\ba
目录 0 2018-06-20 21:38 TowerDefense1.2\src\data\
文件 5297 2012-12-06 14:20 TowerDefense1.2\src\data\ba
文件 160 2012-12-06 14:20 TowerDefense1.2\src\data\Data.java
............此处省略238个文件信息
相关资源
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
- [免费]java实现有障碍物的贪吃蛇游戏
- java Servlet投票实例
- 操作系统作业 (pv,作业管理,等5个
评论
共有 条评论