Package org.newdawn.slick

Examples of org.newdawn.slick.SlickException


    try {
      fire = ParticleIO.loadConfiguredSystem("testdata/system.xml");
      trail = ParticleIO.loadConfiguredSystem("testdata/smoketrail.xml");
     
    } catch (IOException e) {
      throw new SlickException("Failed to load particle systems", e);
    }
    image = new Image("testdata/rocket.png");
 
    spawnRocket();
  }
View Full Code Here


      Document doc = builder.parse(in);
      Element docElement = doc.getDocumentElement();
     
      String orient = docElement.getAttribute("orientation");
      if (!orient.equals("orthogonal")) {
        throw new SlickException("Only orthogonal maps supported, found: "+orient);
      }
     
      width = Integer.parseInt(docElement.getAttribute("width"));
      height = Integer.parseInt(docElement.getAttribute("height"));
      tileWidth = Integer.parseInt(docElement.getAttribute("tilewidth"));
      tileHeight = Integer.parseInt(docElement.getAttribute("tileheight"));
     
      // now read the map properties
      Element propsElement = (Element) docElement.getElementsByTagName("properties").item(0);
      if (propsElement != null) {
        NodeList properties = propsElement.getElementsByTagName("property");
        if (properties != null) {
          props = new Properties();
          for (int p = 0; p < properties.getLength();p++) {
            Element propElement = (Element) properties.item(p);
           
            String name = propElement.getAttribute("name");
            String value = propElement.getAttribute("value");   
            props.setProperty(name, value);
          }
        }
      }
     
      if (loadTileSets) {
        TileSet tileSet = null;
        TileSet lastSet = null;
       
        NodeList setNodes = docElement.getElementsByTagName("tileset");
        for (int i=0;i<setNodes.getLength();i++) {
          Element current = (Element) setNodes.item(i);
         
          tileSet = new TileSet(this, current);
          tileSet.index = i;
         
          if (lastSet != null) {
            lastSet.setLimit(tileSet.firstGID-1);
          }
          lastSet = tileSet;
         
          tileSets.add(tileSet);
        }
      }
     
      NodeList layerNodes = docElement.getElementsByTagName("layer");
      for (int i=0;i<layerNodes.getLength();i++) {
        Element current = (Element) layerNodes.item(i);
        Layer layer = new Layer(this, current);
        layer.index = i;
       
        layers.add(layer);
      }
     
      // acquire object-groups
      NodeList objectGroupNodes = docElement.getElementsByTagName("objectgroup");
          
      for (int i=0;i<objectGroupNodes.getLength();i++) {
        Element current = (Element) objectGroupNodes.item(i);
        ObjectGroup objectGroup = new ObjectGroup(current);
        objectGroup.index = i;
             
        objectGroups.add(objectGroup);
      }
    } catch (Exception e) {
      Log.error(e);
      throw new SlickException("Failed to parse tilemap", e);
    }
  }
View Full Code Here

        Document doc = builder.parse(in);
        Element docElement = doc.getDocumentElement();
        element = docElement; //(Element) docElement.getElementsByTagName("tileset").item(0);
      } catch (Exception e) {
        Log.error(e);
        throw new SlickException("Unable to load or parse sourced tileset: "+this.map.tilesLocation+"/"+source);
      }
    }
        String tileWidthString = element.getAttribute("tilewidth");
        String tileHeightString = element.getAttribute("tileheight");
        if(tileWidthString.length() == 0 || tileHeightString.length() == 0) {
            throw new SlickException("TiledMap requires that the map be created with tilesets that use a " +
                    "single image.  Check the WiKi for more complete information.");
        }
    tileWidth = Integer.parseInt(tileWidthString);
    tileHeight = Integer.parseInt(tileHeightString);
   
View Full Code Here

                        }
                    }
                }
      } catch (IOException e) {
        Log.error(e);
        throw new SlickException("Unable to decode base 64 block");
      }
    } else {
      throw new SlickException("Unsupport tiled map type: "+encoding+","+compression+" (only gzip base64 supported)");
    }
  }
View Full Code Here

  }

  public void update(GameContainer container, StateBasedGame game, int delta)
      throws SlickException {
    if (container == null)
      throw new SlickException("no container set");

    // store the current delta in ME for anyone who's interested in it.
    ME.delta = delta;

    // add new entities
View Full Code Here

   * @throws SlickException
   */
  public static void update(GameContainer container, StateBasedGame game,
      int delta) throws SlickException {
    if (container == null)
      throw new SlickException("no container set");
    if (world == null)
      throw new SlickException("no world set");

    // special key handling
    if (keyToggleDebug != -1) {
      if (container.getInput().isKeyPressed(keyToggleDebug)) {
        debugEnabled = !debugEnabled;
View Full Code Here

   * @throws SlickException
   */
  public static void render(GameContainer container, StateBasedGame game,
      Graphics g) throws SlickException {
    if (container == null)
      throw new SlickException("no container set");
    if (world == null)
      throw new SlickException("no world set");

    if (scaleX != 1 || scaleY != 1)
      g.scale(scaleX, scaleY);

    // render debug stuff
View Full Code Here

          glyphPageHeight = Integer.parseInt(value);
        } else if (name.equals("effect.class")) {
          try {
            effects.add(Class.forName(value).newInstance());
          } catch (Exception ex) {
            throw new SlickException("Unable to create effect instance: " + value, ex);
          }
        } else if (name.startsWith("effect.")) {
          // Set an effect value on the last added effect.
          name = name.substring(7);
          ConfigurableEffect effect = (ConfigurableEffect)effects.get(effects.size() - 1);
          List values = effect.getValues();
          for (Iterator iter = values.iterator(); iter.hasNext();) {
            Value effectValue = (Value)iter.next();
            if (effectValue.getName().equals(name)) {
              effectValue.setString(value);
              break;
            }
          }
          effect.setValues(values);
        }
      }
      reader.close();
    } catch (Exception ex) {
      throw new SlickException("Unable to load Hiero font file: " + hieroFileRef, ex);
    }
  }
View Full Code Here

   * @throws SlickException Indicates a failure during copy or a invalid particle system to be duplicated
   */
  public ParticleSystem duplicate() throws SlickException {
    for (int i=0;i<emitters.size();i++) {
      if (!(emitters.get(i) instanceof ConfigurableEmitter)) {
        throw new SlickException("Only systems contianing configurable emitters can be duplicated");
      }
    }
 
    ParticleSystem theCopy = null;
    try {
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      ParticleIO.saveConfiguredSystem(bout, this);
      ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
      theCopy = ParticleIO.loadConfiguredSystem(bin);
    } catch (IOException e) {
      Log.error("Failed to duplicate particle system");
      throw new SlickException("Unable to duplicated particle system", e);
    }
   
    return theCopy;
  }
View Full Code Here

  }

  private void setBaseDirectory(String baseDirectory) throws SlickException {
    Log.debug("Setting base directory to " + baseDirectory);
    if (baseDirectory == null || baseDirectory.isEmpty()) {
      throw new SlickException("Could not find required BaseDir element.");
    }
    baseDir = baseDirectory;
    if (!baseDir.endsWith("/")) {
      baseDir += "/";
    }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.SlickException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.