Browse Source

creation of the drawable Element class

pull/1/head
jrtechs 8 years ago
parent
commit
6a68387ed9
1 changed files with 43 additions and 0 deletions
  1. +43
    -0
      src/tanks/DrawableElement.java

+ 43
- 0
src/tanks/DrawableElement.java View File

@ -0,0 +1,43 @@
/*
5-21-16
jeffery R
super class for every object in DynamicBinding
allows for every object to have an image that can be drawn
every object will also have a (x,y) cordinate on the screen
*/
package tanks;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
public abstract class DrawableElement
{
//fields
public String imageLocation;
public int x,y;
public BufferedImage img;
//draws img onto the screen
public void Draw(Graphics g)
{
g.drawImage(img, x, y, null);
}
//loads the image from the disk into the Buffered image img
public void LoadImage()
{
img = null;
try
{
img = ImageIO.read(getClass().getResourceAsStream(imageLocation));
//img = ImageIO.read(new File(imageLoc));
}
catch(IOException e)
{
System.out.println(e.toString());
}
}
}

Loading…
Cancel
Save