package Mario_7_12;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
public class Enemy implements Runnable{
private Thread tr;
private List imagesL = new ArrayList<>();//图像集合
private List imagesR = new ArrayList<>();//图像集合
private volatile int index;//当前显示的图片索引
private volatile int posx,posy,dx,dy;//位置和水平速度,竖直方向速度
private int width,height;//大小
private int l,r,up,down;//运动范围
private volatile boolean diretL,directUp;//运动方向
private int switchN;
/*
* 构造函数
* */
public Enemy(int posx, int posy,int dx, int dy, List imagesL,List imagesR,
int width, int height,int l,int r,int up, int down){
this.posx = posx;
this.posy = posy;
this.imagesL = imagesL;
this.imagesR = imagesR;
this.width = width;
this.height = height;
this.l = l;
this.r = r;
this.up = up;
this.down = down;
diretL = false;
directUp = false;
this.dx = dx;
this.dy = dy;
index = 0;
switchN = 5;
tr = new Thread(this);
tr.start();//启动线程
}
/*
* 在线程中运动
* */
@Override
public void run(){
while(true){
posy += dy;
posx += dx;
//判断边界
if(posxr) {posx = r-width;dx = -dx; diretL = true;}
if(posydown){posy = down - height; dy = -dy; directUp = true;}
switchN--;
if(switchN == 0){
index = (index+1)%2;//切换图片
switchN = 5;
}
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*
* 得到当前的图片
* */
public BufferedImage getImage(){
if(diretL)
return imagesL.get(index);
else
return imagesR.get(index);
}
/*
* 得到x坐标
* */
public int getX(){
return posx;
}
/*
* 得到y坐标
* */
public int getY(){
return posy;
}
/*
* 得到宽
* */
public int getWidth(){
return width;
}
/*
* 得到高
* */
public int getHeight(){
return height;
}
}
2. 障碍物类Object
障碍物的信息比较简单,只需要知道它的位置和大小。
package Mario_7_12;
import java.awt.image.BufferedImage;
public class Object {
private int l,r,up,down;//边界
private BufferedImage image;//图像
public Object(int l, int r, int up, int down, BufferedImage image){
this.l = l;
this.r = r;
this.up = up;
this.down = down;
this.image = image;
}
public int getL(){
return l;
}
public int getR(){
return r;
}
public int getUp(){
return up;
}
public int getDown(){
return down;
}
public BufferedImage getImage(){
return image;
}
}
3.背景类Background
随着我们的移动我们的背景也要随之改变
一个背景中有独有的背景图片、障碍物、敌人
因此我们把背景包装成一个类
package Mario_7_12;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
public class Background {
private BufferedImage bgImage = null;//背景图片
private int sort;//第几个场景
private List allEnemies = new ArrayList();//敌人
private List
4.界面类中的run方法
因为在MFrame里面绘制图片,因此背景信息需要在这里画出来
增加的属性:
private Background bg;//背景 private int bgIndex;//第几个背景
run方法:
/*
* 在线程里面绘制图片
* */
@Override
public void run() {
// TODO Auto-generated method stub
List enemies = bg.getEnemies();
List objects = bg.getObjects();
while(true){
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Image bgimg = new ImageIcon(bg.getBgImage()).getImage();//背景图片
buffg.drawImage(bgimg, 0,0, null);
buffg.drawImage(mario.getImage(), mario.posx, mario.posy, 50, 100, null);//马里奥
//敌人
for(int i=0; i
Annotation: 译为注释或注解
An annotation, in the Java computer programming language, is a form of syntactic metadata that can be added to Java source code. Classes, methods, variables, pa
定义:pageStart 起始页,pageEnd 终止页,pageSize页面容量
oracle分页:
select * from ( select mytable.*,rownum num from (实际传的SQL) where rownum<=pageEnd) where num>=pageStart
sqlServer分页:
 
hello.hessian.MyCar.java
package hessian.pojo;
import java.io.Serializable;
public class MyCar implements Serializable {
private static final long serialVersionUID = 473690540190845543
回顾简单的数据库权限等命令;
解锁用户和锁定用户
alter user scott account lock/unlock;
//system下查看系统中的用户
select * dba_users;
//创建用户名和密码
create user wj identified by wj;
identified by
//授予连接权和建表权
grant connect to
/*
*访问ORACLE
*/
--检索单行数据
--使用标量变量接收数据
DECLARE
v_ename emp.ename%TYPE;
v_sal emp.sal%TYPE;
BEGIN
select ename,sal into v_ename,v_sal
from emp where empno=&no;
dbms_output.pu
public class IncDecThread {
private int j=10;
/*
* 题目:用JAVA写一个多线程程序,写四个线程,其中二个对一个变量加1,另外二个对一个变量减1
* 两个问题:
* 1、线程同步--synchronized
* 2、线程之间如何共享同一个j变量--内部类
*/
public static