package org.cloudbus.cloudsim.codes.mygame.leiting.src;

import javax.swing.*;
import java.awt.*;

/**
 * ClassName Plane
 * Description
 * Create by HW
 * Date 2022/4/5 13:02
 */
public class Plane extends Thread{
    public int x=230,y=800;
    int width=25,length=40;
    int speed=5;
    Image img=new ImageIcon("E:\\研究生\\研究生\\论文\\cloudsim学习文档\\cloudsim-5 (2).0\\modules\\cloudsim\\src\\main\\java\\org\\cloudbus\\cloudsim\\codes\\mygame\\leiting\\image/10012.png").getImage();

    //定义上下左右
    boolean up,down,right,left;


    public Plane() {
    }

    public Plane(int x, int y, int width, int length, int speed, Image img) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.length = length;
        this.speed = speed;
        this.img = img;
    }

    @Override
    public void run() {
        while(true){
            if (up && y >=40){
                y-=speed;
            }
            if (y<=1200){
                if(down){
                    y+=speed;
                }
            }
            if (left){
                    x-=speed;
            }
            if (right){
                    x+=speed;
            }
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
