Skip to content

Commit

Permalink
Updated Level.java and Tile.java to be compatible with the new image …
Browse files Browse the repository at this point in the history
…loader.
  • Loading branch information
svenar-nl committed Sep 2, 2016
1 parent 9573991 commit a7455cf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
5 changes: 5 additions & 0 deletions Java/src/me/winspeednl/libz/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public void loadMap(String[] mapData, int w, int h, Tile[] tileList, int s) {
}
}

private Tile createTile(Sprite sprite, int x, int y, int w, int h, double rot, boolean isSolid, boolean flipX, boolean flipY) {
Tile tile = new Tile(sprite, x, y, w, h, isSolid, Math.toRadians(rot), flipX, flipY);
return tile;
}

public int getWidth() {
return width;
}
Expand Down
55 changes: 41 additions & 14 deletions Java/src/me/winspeednl/libz/level/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;

import me.winspeednl.libz.image.Sprite;

Expand All @@ -12,10 +13,10 @@ public class Tile {
double rot;
private boolean isSolid, flipX = false, flipY = false;
private int[] pixels;
private String sprite;
private Sprite sprite;

public Tile(String sprite, int x, int y, int w, int h, boolean isSolid, double rot, boolean flipX, boolean flipY) {
this.sprite = sprite;
public Tile(String path, int x, int y, int w, int h, boolean isSolid, double rot, boolean flipX, boolean flipY) {
this.sprite = new Sprite(path, 0, 0, w, h);
this.x = x;
this.y = y;
this.w = w;
Expand All @@ -25,10 +26,23 @@ public Tile(String sprite, int x, int y, int w, int h, boolean isSolid, double r
this.flipX = flipX;
this.flipY = flipY;

pixels = new Sprite(sprite, 0, 0, w, h).pixels;
pixels = sprite.pixels;
}
public Tile(Sprite sprite, int x, int y, int w, int h, boolean isSolid, double rot, boolean flipX, boolean flipY) {
this.sprite = sprite.path;
this.sprite = sprite;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.isSolid = isSolid;
this.rot = rot;
this.flipX = flipX;
this.flipY = flipY;

pixels = sprite.pixels;
}
public Tile(File file, int x, int y, int w, int h, boolean isSolid, double rot, boolean flipX, boolean flipY) {
this.sprite = new Sprite(file, 0, 0, w, h);
this.x = x;
this.y = y;
this.w = w;
Expand All @@ -41,8 +55,8 @@ public Tile(Sprite sprite, int x, int y, int w, int h, boolean isSolid, double r
pixels = sprite.pixels;
}

public Tile(String sprite, int x, int y, int w, int h, boolean isSolid) {
this.sprite = sprite;
public Tile(String path, int x, int y, int w, int h, boolean isSolid) {
this.sprite = new Sprite(path, 0, 0, w, h);
this.x = x;
this.y = y;
this.w = w;
Expand All @@ -52,11 +66,24 @@ public Tile(String sprite, int x, int y, int w, int h, boolean isSolid) {
this.flipX = false;
this.flipY = false;

pixels = new Sprite(sprite, 0, 0, w, h).pixels;
pixels = sprite.pixels;
}

public Tile(Sprite sprite, int x, int y, int w, int h, boolean isSolid) {
this.sprite = sprite.path;
this.sprite = sprite;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.isSolid = isSolid;
this.rot = 0.0;
this.flipX = false;
this.flipY = false;

pixels = sprite.pixels;
}
public Tile(File file, int x, int y, int w, int h, boolean isSolid) {
this.sprite = new Sprite(file, 0, 0, w, h);
this.x = x;
this.y = y;
this.w = w;
Expand Down Expand Up @@ -193,17 +220,17 @@ public void setSolid(boolean isSolid) {
this.isSolid = isSolid;
}

public String getSprite() {
public Sprite getSprite() {
return sprite;
}

public void setSprite(String sprite) {
this.sprite = sprite;
pixels = new Sprite(sprite, 0, 0, w, h).pixels;
public void setSprite(String path) {
this.sprite = new Sprite(path, 0, 0, w, h);
pixels = sprite.pixels;
}

public void setSprite(Sprite sprite) {
this.sprite = sprite.path;
this.sprite = sprite;
pixels = sprite.pixels;
}

Expand Down

0 comments on commit a7455cf

Please sign in to comment.