Shell.java
上传用户:xueping400
上传日期:2022-02-08
资源大小:888k
文件大小:1k
- import java.awt.Graphics;
- import java.awt.Image;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- public class Shell extends MoveObject{
-
- private static String path = "src/image/pop02.gif";
- private static Image image ;
- private DIR dir;
-
- static{
- try {
- image = ImageIO.read(new File(path));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public Shell(int x, int y , DIR dir){
- this.width = 30;
- this.height = 30;
- this.x = x;
- this.y = y;
- this.dir = dir;
- }
-
- public void move() {
- DirStep ds = hmDir.get(this.dir);
- this.x += 20 * ds.getXstep();
- this.y += 20 * ds.getYstep();
- }
-
- public boolean isLive(){
- if(this.x < 0 || this.x > PlaneFrame.WINDOW_WIDTH ||this.y < 0 || this.y > PlaneFrame.WINDOW_HEIGHT){
- return false;
- }
- return true;
- }
-
- public void paint(Graphics g){
- g.drawImage(image,this.x,this.y,this.width,this.height,null);
- move();
- }
- }