Package org.newdawn.slick

Examples of org.newdawn.slick.SpriteSheet


  @Override
  public void init(GameContainer container) throws SlickException {
    land = new Image("textures/land.jpg");
    plane = new Image("textures/plane.png");
    SpriteSheet sheet = new SpriteSheet("textures/sprites.png", 32, 32);
    sprites = sheet.getSprite(1, 0);
  }
View Full Code Here


    }
  }

  public Animation animation(String string) {
    try {
      return new Animation(new SpriteSheet(fRootDir + "/" + string + ".png", 32, 32), 100);
    } catch (Exception e) {
      System.err.println("Couldn't find resource: " + string);
      return null;
    }
  }
View Full Code Here

    }
  }
 
  public SpriteSheet spritesheet(String string, int x, int y) {
    try {
      return new SpriteSheet(fRootDir + "/" + string + ".png", x, y);
    } catch (Exception e) {
      System.err.println("Couldn't find resource: " + string);
      return null;
    }
  }
View Full Code Here

    // This 4 digit number is considered as a binary number/
    // Converted into integer, it gives the tile ID!
    int tileID = Integer.valueOf(String.valueOf(data), 2);

    Image image = ImageManager.getGfx("roads");
    SpriteSheet sp = new SpriteSheet(image, 32, 32);

    return sp.getSprite(tileID, 0);
  }
View Full Code Here

    scoreTable = new Image("img/sctable.gif",false,Image.FILTER_NEAREST);
    gameOver = new Image("img/GO.gif",false,Image.FILTER_NEAREST);
    timer = new Image("img/timer.gif",false,Image.FILTER_NEAREST);
    ammo = new Image("img/spearamm.gif",false,Image.FILTER_NEAREST);
 
    ammonum = new SpriteSheet(new Image("img/spearammn.gif",false,Image.FILTER_NEAREST), 32, 32);
    cutscene = new SpriteSheet(new Image("img/stry.png",false,Image.FILTER_NEAREST), 320, 240);

    playerWalk = new Animation(new SpriteSheet(new Image("img/playerwalk.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    playerAttack = new Animation(new SpriteSheet(new Image("img/playerattack.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    playerAttack.setLooping(false);
    deerWalk = new Animation(new SpriteSheet(new Image("img/deerwalk.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    deerAttack = new Animation(new SpriteSheet(new Image("img/deerattack.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    deerAttack.setLooping(false);
    bearWalk = new Animation(new SpriteSheet(new Image("img/bearwalk.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    bearAttack = new Animation(new SpriteSheet(new Image("img/bearattack.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    bearAttack.setLooping(false);
    heart =  new Animation(new SpriteSheet(new Image("img/heart.gif",false,Image.FILTER_NEAREST), 32, 32),200);
    spearWalk = new Animation(new SpriteSheet(new Image("img/playerwalkspear.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    spearFly = new Animation(new SpriteSheet(new Image("img/spearfly.gif",false,Image.FILTER_NEAREST), 32, 32),300);
    spearAttack = new Animation(new SpriteSheet(new Image("img/spearthrow.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    spearAttack.setLooping(false);
    playerDyin = new Animation(new SpriteSheet(new Image("img/pldyn.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    playerDyin.setLooping(false);
    deerDyin = new Animation(new SpriteSheet(new Image("img/deerdyn.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    deerDyin.setLooping(false);
    bearDyin  = new Animation(new SpriteSheet(new Image("img/beardyn.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    bearDyin.setLooping(false);

    plStep = new Sound("snd/plStep.wav");
    deerStp = new Sound("snd/deerwlk.wav");
    bearStp= new Sound("snd/berWalk.wav");
View Full Code Here

    }
  }
 
  private void loadExternalImages(String src, int w, int h) {
    try {
      fSheet = new SpriteSheet("tilesets/" + src, 32, 32);
      fCount = fSheet.getHeight() / 2;
    } catch (SlickException e) {
      System.err.println("Failed to load source " + src);
    }   
  }
View Full Code Here

        }
        n++;
      }
      image.getGraphics().flush();
      fCount = n;
      fSheet = new SpriteSheet(image, 32, 32);
    } catch (SlickException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   *
   * @param image
   *            The image to use for this tileset
   */
  public void setTileSetImage(Image image) {
    tiles = new SpriteSheet(image, tileWidth, tileHeight, tileSpacing,
        tileMargin);
    tilesAcross = tiles.getHorizontalCount();
    tilesDown = tiles.getVerticalCount();

    if (tilesAcross <= 0) {
View Full Code Here

   * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
   */
  public void init(GameContainer container) throws SlickException {
    // load the sprites and tiles, note that underneath the texture
    // will be shared between the sprite sheet and tilemap
    SpriteSheet sheet = new SpriteSheet("testdata/scroller/sprites.png",32,32);
    // load the tilemap created the TileD tool
    map = new TiledMap("testdata/scroller/map.tmx");
   
    // build a collision map based on tile properties in the TileD map
    blocked = new boolean[map.getWidth()][map.getHeight()];
    for (int x=0;x<map.getWidth();x++) {
      for (int y=0;y<map.getHeight();y++) {
        int tileID = map.getTileId(x, y, 0);
        String value = map.getTileProperty(tileID, "blocked", "false");
        if ("true".equals(value)) {
          blocked[x][y] = true;
        }
      }
    }
   
    // caculate some layout values for rendering the tilemap. How many tiles
    // do we need to render to fill the screen in each dimension and how far is
    // it from the centre of the screen
    widthInTiles = container.getWidth() / TILE_SIZE;
    heightInTiles = container.getHeight() / TILE_SIZE;
    topOffsetInTiles = heightInTiles / 2;
    leftOffsetInTiles = widthInTiles / 2;
   
    // create the player sprite based on a set of sprites from the sheet loaded
    // above (tank tracks moving)
    player = new Animation();
    for (int frame=0;frame<7;frame++) {
      player.addFrame(sheet.getSprite(frame,1), 150);
    }
    player.setAutoUpdate(false);

    // update the vector of movement based on the initial angle
    updateMovementVector();
View Full Code Here

   */
  public void init(GameContainer container) throws SlickException {
    image = new Image("testdata/rocket.png");
    back = new Image("testdata/sky.jpg");
    font = new AngelCodeFont("testdata/hiero.fnt","testdata/hiero.png");
    SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
    homer = new Animation(sheet, 0,0,7,0,true,150,true);
  }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.SpriteSheet

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.