View Javadoc

1   package erland.game.tileadventure.rect;
2   
3   import erland.game.tileadventure.*;
4   import erland.game.GameEnvironmentInterface;
5   import erland.util.SubImageHandler;
6   
7   import java.awt.*;
8   
9   /*
10   * Copyright (C) 2004 Erland Isaksson (erland_i@hotmail.com)
11   *
12   * This program is free software; you can redistribute it and/or
13   * modify it under the terms of the GNU General Public License
14   * as published by the Free Software Foundation; either version 2
15   * of the License, or (at your option) any later version.
16   *
17   * This program is distributed in the hope that it will be useful,
18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20   * GNU General Public License for more details.
21   *
22   * You should have received a copy of the GNU General Public License
23   * along with this program; if not, write to the Free Software
24   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25   * 
26   */
27  
28  public class RectEnvironment implements TileGameEnvironmentInterface {
29      private GameEnvironmentInterface environment;
30      private static final int SQUARE_SIZE_X=32;
31      private static final int SQUARE_SIZE_Y=32;
32      private static final int SQUARE_SIZE_Z=8;
33      public RectEnvironment(GameEnvironmentInterface environment) {
34          this.environment = environment;
35      }
36      public BlockContainerData createBlockContainer(int offsetX, int offsetY, int sizeX, int sizeY, int sizeZ, int visibleSizeX, int visibleSizeY) {
37          return new RectBlockContainerData(offsetX, offsetY, 0,0,sizeX,sizeY, sizeZ, SQUARE_SIZE_X, SQUARE_SIZE_Y,SQUARE_SIZE_Z,visibleSizeX,visibleSizeY);
38      }
39  
40      public BlockContainerData createBlockContainer(int offsetX, int offsetY, int sizeX, int sizeY, int sizeZ) {
41          return createBlockContainer(offsetX,offsetY,sizeX,sizeY,sizeZ,SQUARE_SIZE_X*sizeX,SQUARE_SIZE_Y*sizeY);
42      }
43  
44      public BlockContainerData createRectBlockContainer(int offsetX, int offsetY, int sizeX, int sizeY, int sizeZ) {
45          return createBlockContainer(offsetX,offsetY,sizeX,sizeY,sizeZ);
46      }
47      public SubImageHandler createSubImageHandler(Image image) {
48          if(image==null) {
49              image = environment.getImageCreator().createCompatibleImage(getSubImageWidth()*8,getSubImageHeight()*8,Transparency.BITMASK);
50          }
51          return new SubImageHandler(image,getSubImageWidth(),getSubImageHeight(),8,8);
52      }
53  
54      public int getSubImageWidth() {
55          return SQUARE_SIZE_X;
56      }
57  
58      public int getSubImageHeight() {
59          return SQUARE_SIZE_Y;
60      }
61  
62      public DrawMap createBlockMap() {
63          return new RectDrawMap();
64      }
65  
66      public String getTileType() {
67          return "rect";
68      }
69  }