Commit e6028fac authored by Colin Thomas's avatar Colin Thomas

Adapting Graphics Map to enable the use of Animations in TileSprite

parent 1f5a9b71
package graphics.guiSkeleton.mapManagement;
import graphics.guiSkeleton.sprites.Displayable;
import graphics.guiSkeleton.tileSpriteLinker.TileSprite;
import java.awt.image.BufferedImage;
......@@ -17,9 +18,9 @@ public class GraphicsMap {
private final int Height;
private final int Width;
private BufferedImage[][] Sprites;
private Displayable[][] Sprites;
public GraphicsMap(int w, int h, BufferedImage[][] s)
public GraphicsMap(int w, int h, Displayable[][] s)
{
Width = w;
Height = h;
......@@ -32,7 +33,7 @@ public class GraphicsMap {
{
throw new ArrayIndexOutOfBoundsException("Trying to get tile sprite at "+x+" , "+y+" but map has dimension "+Height+" , "+Width+"(unit = 1/4 tile)");
}
return Sprites[x][y];
return Sprites[x][y].getSpriteImage();
}
public int getMapPixelHeight()
......
......@@ -4,6 +4,7 @@ package graphics.guiSkeleton.mapManagement;
import java.awt.image.BufferedImage;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.sprites.Displayable;
import graphics.guiSkeleton.tileSpriteLinker.TileSprite;
import graphics.guiSkeleton.tileSpriteLinker.TileSpriteLinker;
......@@ -28,7 +29,7 @@ public abstract class MapDrawer {
int mapDHeight = 2 * mapHeight;
TileSpriteLinker tsl = TileSpriteLinker.getInstance();
BufferedImage[][] sprites = new BufferedImage[mapDHeight][mapDWidth];
Displayable[][] sprites = new Displayable[mapDHeight][mapDWidth];
for (int i = 0 ; i < mapHeight; i++)
{
for (int j = 0 ; j < mapWidth; j++)
......@@ -47,7 +48,7 @@ public abstract class MapDrawer {
}
}
// Getting the sprites via the tileSpriteLinker
BufferedImage[][] linkedSprites = tsl.getSpriteOfTile(map.getTileAt(j,i).getType(),tileMask);
Displayable[][] linkedSprites = tsl.getSpriteOfTile(map.getTileAt(j,i).getType(),tileMask);
for (int k = 0; k < 2; k++)
{
for (int l = 0; l < 2; l++)
......
......@@ -75,6 +75,7 @@ public class Animation implements Serializable, Displayable
{
globalCounter++;
}
public BufferedImage getSpriteImage()
{
while (localCounter < globalCounter)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment