Last change
on this file since b2d7893 was b2d7893, checked in by Dmitry Portnoy <dmp1488@…>, 4 years ago |
Change all file paths to work from inside a JAR and update the makefile to correctly build the project
|
-
Property mode
set to
100644
|
File size:
993 bytes
|
Line | |
---|
1 | package main;
|
---|
2 |
|
---|
3 | import java.awt.image.BufferedImage;
|
---|
4 | import java.io.IOException;
|
---|
5 |
|
---|
6 | import javax.imageio.ImageIO;
|
---|
7 |
|
---|
8 | public class MapElement {
|
---|
9 |
|
---|
10 | private BufferedImage img;
|
---|
11 | private boolean passable;
|
---|
12 |
|
---|
13 | public MapElement(BufferedImage img, boolean passable) {
|
---|
14 | this.img = img;
|
---|
15 | this.passable = passable;
|
---|
16 | }
|
---|
17 |
|
---|
18 | public MapElement(String imgFile, boolean passable) {
|
---|
19 | try {
|
---|
20 | this.img = ImageIO.read(getClass().getResource("/images/" + imgFile));
|
---|
21 | this.passable = passable;
|
---|
22 | } catch (Exception ioe) {
|
---|
23 | System.out.println("Failed to load image " + imgFile);
|
---|
24 | ioe.printStackTrace();
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | public MapElement(MapElement copy) {
|
---|
29 | this.img = copy.img;
|
---|
30 | this.passable = copy.passable;
|
---|
31 | }
|
---|
32 |
|
---|
33 | public BufferedImage getImg() {
|
---|
34 | return this.img;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public boolean isPassable() {
|
---|
38 | return this.passable;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public void setImg(BufferedImage img) {
|
---|
42 | this.img = img;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public void setPassable(boolean passable) {
|
---|
46 | this.passable = passable;
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.