Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package objects;
  2.  
  3. import java.awt.Image;
  4.  
  5. import javax.swing.ImageIcon;
  6.  
  7. @SuppressWarnings("all")
  8. public class Missile {
  9.     int x, y;
  10.     Image image;
  11.     boolean visible;
  12.     int screenWidth = 600;
  13.     int speedMissile = 3;
  14.    
  15.     public Missile(int x, int y){
  16.         ImageIcon ii = new ImageIcon(this.getClass().getResource("/image/missile.png"));
  17.         Image image = ii.getImage();
  18.         visible = true;
  19.         this.x = x;
  20.         this.y = y;
  21.     }
  22.    
  23.     public Image getImage() {
  24.         return image;
  25.     }
  26.  
  27.     public int getX() {
  28.         return x;
  29.     }
  30.  
  31.     public int getY() {
  32.         return y;
  33.     }
  34.  
  35.     public boolean isVisible() {
  36.         return visible;
  37.     }
  38.    
  39.     public void move(){
  40.         x += speedMissile;
  41.         if (x > screenWidth)
  42.             visible = false;
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement