1 package erland.game.tileadventure.rect;
2
3 import erland.game.tileadventure.IrregularBlockContainerInterface;
4 import erland.game.tileadventure.BlockContainerData;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class RectBlockContainerData extends BlockContainerData {
26 private int blockDrawingOffsetX;
27 private int blockDrawingOffsetY;
28 public RectBlockContainerData(int offsetX, int offsetY, int blockDrawingOffsetX, int blockDrawingOffsetY, int sizeX, int sizeY,int sizeZ, int squareSizeX,int squareSizeY,int squareSizeZ, int visibleSizeX, int visibleSizeY) {
29 super(offsetX,offsetY,sizeX,sizeY,sizeZ, squareSizeX,squareSizeY,squareSizeZ,visibleSizeX,visibleSizeY);
30 }
31
32 public int getDrawingPositionX(float x, float y, float z)
33 {
34 return getOffsetX() + blockDrawingOffsetX - getScrollingOffsetX() + getPositionX(x,y,z);
35 }
36 public int getDrawingPositionY(float x, float y, float z)
37 {
38 return getOffsetY() + blockDrawingOffsetY - getScrollingOffsetY() + getPositionY(x,y,z);
39 }
40 public int getPositionX(float x, float y, float z)
41 {
42 return (int)(getSquareSizeX()*x);
43 }
44 public int getPositionY(float x, float y, float z)
45 {
46 return (int)(getSquareSizeY()*y);
47 }
48 public boolean getVisible(float posX, float posY,float posZ)
49 {
50 if((getPositionX(posX,posY,posZ)+getSquareSizeX())>getScrollingOffsetX() && getPositionX(posX,posY,posZ)<(getScrollingOffsetX()+getDrawingSizeX())) {
51 if((getPositionY(posX,posY,posZ)+getSquareSizeY())>getScrollingOffsetY() && getPositionY(posX,posY,posZ)<(getScrollingOffsetY()+getDrawingSizeY())) {
52 return true;
53 }
54 }
55 return false;
56 }
57
58 public int getPixelDrawingPositionX(float x, float y, float z) {
59 return getDrawingPositionX(x,y,z);
60 }
61
62 public int getPixelDrawingPositionY(float x, float y, float z) {
63 return getDrawingPositionY(x,y,z);
64 }
65 /***
66 * Get the horizontal scrolling size
67 * @return The horizontal scrolling offset (Pixel coordinates)
68 */
69 public int getScrollingSizeX()
70 {
71 return getSizeX()*getSquareSizeX();
72 }
73
74 /***
75 * Get the vertical scrolling size
76 * @return The vertical scrolling size (Pixel coordinates)
77 */
78 public int getScrollingSizeY()
79 {
80 return getSizeY()*getSquareSizeY();
81 }
82 public int getBlockPositionX(int x, int y, int z) {
83 return (x+getScrollingOffsetX()-getOffsetX())/getSquareSizeX();
84 }
85
86 public int getBlockPositionY(int x, int y, int z) {
87 return (y+getScrollingOffsetY()-getOffsetY())/getSquareSizeY();
88 }
89 }