66 lines
1.4 KiB
Java
Raw Normal View History

2015-02-14 17:48:55 -05:00
package milleniumlegacy;
import java.awt.Color;
import java.awt.Graphics;
2015-02-15 07:38:55 -05:00
import java.awt.image.BufferedImage;
2015-02-14 17:48:55 -05:00
public class Tile
{
int x,y;
char terrain;
boolean up, down, left, right;
int offsetx;
int offsety;
2015-02-15 07:38:55 -05:00
BufferedImage TileImage;
String name;
Animation waterAnimation = new Animation(ImageHandler.waterArray);
public Tile(int x, int y, char terrain, ImageLoader IL)
2015-02-14 17:48:55 -05:00
{
this.x = x;
this.y = y;
this.terrain = terrain;
2015-02-15 07:38:55 -05:00
switch(terrain)
{
case '-':
this.name="1";
TileImage = ImageHandler.Grass;
break;
case 'w':
this.name="2"; //get water
TileImage = ImageHandler.Water;
break;
case 'r':
this.name="5";
TileImage = ImageHandler.Rock;
break;
case 'g':
this.name="4";
TileImage = ImageHandler.Gravel;
break;
case 'c':
this.name="3";
TileImage = ImageHandler.Clay;
break;
}
2015-02-14 17:48:55 -05:00
}
public void Render(Graphics g, int offsetx, int offsety)
{
2015-02-15 07:38:55 -05:00
if (name.equals("2"))
{
g.drawImage(waterAnimation.animate(), x*48 + offsetx- 48, y*48 + offsety - 48, 48,48, null);
}
else if (TileImage != null)
2015-02-14 20:53:36 -05:00
{
2015-02-15 07:38:55 -05:00
g.drawImage(TileImage, x*48 + offsetx- 48, y*48 + offsety - 48, 48,48, null);
2015-02-14 20:53:36 -05:00
}
2015-02-14 17:48:55 -05:00
else
{
2015-02-14 20:53:36 -05:00
g.setColor(Color.blue);
2015-02-15 07:38:55 -05:00
g.drawRect(x*48 + offsetx - 48, y*48 + offsety - 48, 48,48);
2015-02-14 17:48:55 -05:00
}
2015-02-14 20:53:36 -05:00
String draw = "x" + x + "y" + y;
2015-02-15 07:38:55 -05:00
g.setColor(Color.white);
//g.drawString(draw, x*48 + offsetx - 48, y*48 + 8 + offsety - 48);
2015-02-14 17:48:55 -05:00
}
}