1 package erland.game.tileadventure.isodiamond;
2
3 import erland.game.tileadventure.*;
4 import erland.game.tileadventure.rect.RectBlockContainerData;
5 import erland.game.GameEnvironmentInterface;
6 import erland.util.SubImageHandler;
7
8 import java.awt.*;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public class IsoDiamondEnvironment implements TileGameEnvironmentInterface {
30 private GameEnvironmentInterface environment;
31 private static final int SQUARE_SIZE_X=32;
32 private static final int SQUARE_SIZE_Y=16;
33 private static final int SQUARE_SIZE_Z=8;
34
35 public IsoDiamondEnvironment(GameEnvironmentInterface environment) {
36 this.environment = environment;
37 }
38 public BlockContainerData createBlockContainer(int offsetX, int offsetY, int sizeX, int sizeY, int sizeZ, int visibleSizeX, int visibleSizeY) {
39 return new IsoDiamondBlockContainerData(offsetX, offsetY, 0,-getSubImageHeight()+SQUARE_SIZE_Y,sizeX,sizeY, sizeZ, SQUARE_SIZE_X, SQUARE_SIZE_Y,SQUARE_SIZE_Z,visibleSizeX,visibleSizeY);
40 }
41
42 public BlockContainerData createBlockContainer(int offsetX, int offsetY, int sizeX, int sizeY, int sizeZ) {
43 BlockContainerData data = createBlockContainer(offsetX, offsetY, sizeX,sizeY, sizeZ, sizeX*(SQUARE_SIZE_X>>1)+sizeY*(SQUARE_SIZE_X>>1),sizeY*(SQUARE_SIZE_Y>>1)+sizeX*(SQUARE_SIZE_Y>>1)+sizeZ*SQUARE_SIZE_Z);
44 data.setScrollingOffsetX(0);
45 data.setScrollingOffsetY(-sizeZ*SQUARE_SIZE_Z);
46 return data;
47 }
48 public BlockContainerData createRectBlockContainer(int offsetX, int offsetY, int sizeX, int sizeY, int sizeZ) {
49 return new RectBlockContainerData(offsetX,offsetY,0,-getSubImageHeight()+SQUARE_SIZE_Y,sizeX,sizeY,sizeZ,getSubImageWidth(),getSubImageHeight(),SQUARE_SIZE_Z,sizeX*getSubImageWidth(),sizeY*getSubImageHeight());
50 }
51 public SubImageHandler createSubImageHandler(Image image) {
52 if(image==null) {
53 image = environment.getImageCreator().createCompatibleImage(getSubImageWidth()*8,getSubImageHeight()*8,Transparency.BITMASK);
54 }
55 return new SubImageHandler(image,getSubImageWidth(),getSubImageHeight(),8,8,0,0
56 }
57
58 public int getSubImageWidth() {
59 return SQUARE_SIZE_X;
60 }
61
62 public int getSubImageHeight() {
63 return SQUARE_SIZE_Z*3+SQUARE_SIZE_Y;
64 }
65
66 public DrawMap createBlockMap() {
67 return new IsoDiamondDrawMap();
68 }
69
70 public String getTileType() {
71 return "isodiamond";
72 }
73 }