-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tiles.java
58 lines (52 loc) · 1.44 KB
/
Tiles.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import greenfoot.*;
/**
* The Tiles class, to allow tiles to walk on in the GameWorld.
*
* @author Matthew Hillier
* @version 1.0
*/
public class Tiles extends Movers
{
protected String name; //The Tile's name
protected int worldX; //The Tile's X coordinate
protected int worldY; //The Tile's Y coordinate
/**
* Creates a new Tile.
* @param inName The name of the tile
* @param sheetX The image's X coordinate.
* @param sheetY The image's Y coordinate.
* @param tileSetNum The tileSet id.
* @param inWorldX The X coordinate in the world.
* @param inWorldY The Y coordinate in the world.
*/
public Tiles(String inName, int sheetX, int sheetY, int tileSetNum, int inWorldX, int inWorldY)
{
name = inName;
GreenfootImage currentImage = new GreenfootImage(48, 48);
currentImage.drawImage(new GreenfootImage("TileSet" + tileSetNum + ".png"), sheetX * -48, sheetY * -48);
setImage(currentImage);
worldX = inWorldX;
worldY = inWorldY;
}
/**
* Returns the name of the Tile.
*/
public String getName()
{
return name;
}
/**
* Returns the X coordinate of the Tile.
*/
public int getWorldX()
{
return worldX;
}
/**
* Returns the Y coordinate of the Tile.
*/
public int getWorldY()
{
return worldY;
}
}