View Javadoc

1   package erland.game.tileadventure.rect;
2   /*
3    * Copyright (C) 2004 Erland Isaksson (erland_i@hotmail.com)
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18   *
19   */
20  
21  import erland.game.tileadventure.*;
22  
23  import java.awt.*;
24  import java.util.Vector;
25  
26  public class RectDrawMap extends DrawMap {
27      public void draw(Graphics g) {
28          BitmapObject.drawCount = 0;
29          MapObjectContainerInterface[] maps = getMaps();
30          if(maps.length>0) {
31              MapObjectContainerInterface main = (MapObjectContainerInterface) maps[0];
32              for(int z=0;z<main.getSizeZ();z++) {
33                  for(int y=0;y<main.getSizeY();y++) {
34                      for(int x=0;x<main.getSizeX();x++) {
35                          drawTile(maps, x, y, z, g);
36                      }
37                  }
38              }
39          }
40      }
41  
42      private void drawTile(MapObjectContainerInterface[] maps, int x, int y, int z, Graphics g) {
43          MapObjectInterface obj = maps[0].getBlock(x,y,z);
44          if(obj!=null) {
45              obj.draw(g);
46          }
47          for(int i=1;i<maps.length;i++) {
48              MapObjectContainerInterface map = (MapObjectContainerInterface) maps[i];
49              obj = map.getBlock(x,y,z);
50              if(obj!=null) {
51                  obj.draw(g);
52              }
53          }
54      }
55  }
56