Package org.newdawn.slick

Examples of org.newdawn.slick.Image


        GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE);
      }
     
      // now get the particle pool for this emitter and render all particles that are in use
      ParticlePool pool = (ParticlePool) particlesByEmitter.get(emitter);
      Image image = emitter.getImage();
      if (image == null) {
        image = this.sprite;
      }
     
      if (!emitter.isOriented() && !emitter.usePoints(this)) {
        image.startUse();
      }
     
      for (int i = 0; i < pool.particles.length; i++)
      {
        if (pool.particles[i].inUse())
          pool.particles[i].render();
      }
     
      if (!emitter.isOriented() && !emitter.usePoints(this)) {
        image.endUse();
      }

      // reset additive blend mode
      if (emitter.useAdditive()) {
        GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE_MINUS_SRC_ALPHA);
View Full Code Here


  private void loadSystemParticleImage() {
    AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
            try {
              if (mask != null) {
                sprite = new Image(defaultImageName, mask);
              } else {
                sprite = new Image(defaultImageName);
              }
            } catch (SlickException e) {
              Log.error(e);
              defaultImageName = null;
            }
View Full Code Here

     
      trans = new Color(c);
    }

    if (loadImage) {
      Image image = new Image(map.getTilesLocation()+"/"+ref,false,Image.FILTER_NEAREST,trans);
      setTileSetImage(image);
    }
   
    NodeList pElements = element.getElementsByTagName("tile");
    for (int i=0;i<pElements.getLength();i++) {
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
   
    try {
      bg_sprite = new Image("data/8bitBGgood.gif");
    } catch (SlickException e) {
      e.printStackTrace();
    }
   
    gc.setTargetFrameRate(Constants.FRAME_RATE);
    gc.setVSync(true);
    worldCenterX = gc.getWidth() / 2;
    worldCenterY = gc.getHeight() / 2;
    world = new World();
    world.setIterations(Constants.ITERATIONS);
    world.setGravity(-10);

    p1 = new Player(p1Name);
    p2 = new Player(p2Name);
   
    terrainy = new ImageBuffer(Constants.MAX_WIDTH, Constants.MAX_HEIGHT*2);
   
    terrainBitmap = Noise.GenerateWhiteNoise(Constants.MAX_WIDTH,Constants.MAX_HEIGHT*2);
    terrainBitmap = Noise.GenerateSmoothNoise(terrainBitmap,7);
    terrainBitmap = Noise.GeneratePerlinNoise(terrainBitmap,7);
   
    SlickDisplay();
    terrainyImage = terrainy.getImage();
    createTerrainBody2(-terrainyImage.getWidth()/2, -terrainyImage.getHeight()/2);
   
    for (int i = 0; i < Constants.BEAVERS_PER_TEAM; i++) {
      int[] coord = randomFreeCoordinate(20);
      if (coord[0] < 0) p1.getTeam()[i].setBody(new DynamicBody(new Circle(10.0f), -100*i, 1300));
      else p1.getTeam()[i].setBody(new DynamicBody(new Circle(10.0f), (coord[0]-terrainyImage.getWidth()/2), (coord[1]-terrainyImage.getHeight()/2)));
      p1.getTeam()[i].getBody().setDensity(1);
      p1.getTeam()[i].getBody().setFriction(1000);
      p1.getTeam()[i].getBody().setRestitution(0f);
      p1.getTeam()[i].getBody().setAngularDamping(1f);
      p1.getTeam()[i].getBody().setFixedRotation(true);
      world.add(p1.getTeam()[i].getBody());
    }
   
    for (int i = 0; i < Constants.BEAVERS_PER_TEAM; i++) {
      int[] coord = randomFreeCoordinate(20);
      if (coord[0] < 0) p2.getTeam()[i].setBody(new DynamicBody(new Circle(10.0f), -100*i, 1300));
      else p2.getTeam()[i].setBody(new DynamicBody(new Circle(10.0f), (coord[0]-terrainyImage.getWidth()/2), (coord[1]-terrainyImage.getHeight()/2)));
      p2.getTeam()[i].getBody().setDensity(1);
      p2.getTeam()[i].getBody().setFriction(1000);
      p2.getTeam()[i].getBody().setRestitution(0f);
      p2.getTeam()[i].getBody().setAngularDamping(1f);
      p2.getTeam()[i].getBody().setFixedRotation(true);
      world.add(p2.getTeam()[i].getBody());
    }

    currentPlayer = p1;
   
    //Add the invisible boundary
    boundary = addBoundary(Constants.MAX_WIDTH*2,Constants.MAX_HEIGHT*3);
    boundary.setRestitution(0f);
    world.add(boundary);
    world.addBodyListener(boundary, this);
   
    // load beaver images to use in our animation
    Image beaver = new Image("data/bazooka4.png");
    Image beaver2 = new Image("data/bazooka5.png");
    Image[] frames = {beaver.getFlippedCopy(false, true).getScaledCopy(0.5f), beaver2.getFlippedCopy(false, true).getScaledCopy(0.5f)};
    Image[] frames2 = {beaver.getFlippedCopy(true, true).getScaledCopy(0.5f), beaver2.getFlippedCopy(true, true).getScaledCopy(0.5f)};
    team1Moving = new Animation(frames, 1000, false); // duration in ms
    team1MovingR = new Animation(frames2, 1000, false); // duration in ms
    Image beaver3 = new Image("data/darkBazooka4.png");
    Image beaver4 = new Image("data/darkBazooka5.png");
    Image[] frames3 = {beaver3.getFlippedCopy(false, true).getScaledCopy(0.5f), beaver4.getFlippedCopy(false, true).getScaledCopy(0.5f)};
    Image[] frames4 = {beaver3.getFlippedCopy(true, true).getScaledCopy(0.5f), beaver4.getFlippedCopy(true, true).getScaledCopy(0.5f)};
    team2Moving = new Animation(frames3, 1000, false); // duration in ms
    team2MovingR = new Animation(frames4, 1000, false); // duration in ms
   
    // add the mouse listener
    gc.getInput().addMouseListener(this);
   
    //add two items to the world
    item = new Item[]{new Item(), new Item()};
    item[0].setTypeAmmo();
    item[1].setTypeHP();
    item[0].getBody().setFriction(1000);
    item[1].getBody().setFriction(1000);
    item[0].getBody().setRestitution(0);
    item[1].getBody().setRestitution(0);
    item[0].getBody().setFixedRotation(true);
    item[1].getBody().setFixedRotation(true);
    world.add(item[0].getBody());
    world.add(item[1].getBody());
    world.addBodyListener(item[0].getBody(), this);
    world.addBodyListener(item[1].getBody(), this);
   
    Body currentBeaverBody = currentPlayer.getCurrentBeaver().getBody();
    crosshairAngle = 45;
    crosshair = new StaticBody(new Rectangle(50f,5f),currentBeaverBody.getX(),currentBeaverBody.getY());
    world.add(crosshair);
    crosshair.setRotation(crosshairAngle);
    crosshairImage = new Image("data/crosshair.png").getScaledCopy(0.5f);
    bulletImage = new Image("data/wood.png").getScaledCopy(0.5f);
    healthImage = new Image("data/health.png").getScaledCopy(0.5f);
    ammoImage = new Image("data/ammo.png").getFlippedCopy(false, true).getScaledCopy(0.5f);
    timer(Constants.SECONDS_PER_TURN);
  }
View Full Code Here

      currentPlayer = p2;
    }
   
  ///////////////////////////////////
    try {
      bg_sprite = new Image("data/8bitBGgood.gif");
    } catch (SlickException e) {
      e.printStackTrace();
    }
   
    gc.setTargetFrameRate(Constants.FRAME_RATE);
    gc.setVSync(true);
    worldCenterX = gc.getWidth() / 2;
    worldCenterY = gc.getHeight() / 2;
    world = new World();
    world.setIterations(Constants.ITERATIONS);
    world.setGravity(-10);
   
    terrainy = new ImageBuffer(Constants.MAX_WIDTH, Constants.MAX_HEIGHT*2);
   
    SlickDisplay();
    terrainyImage = terrainy.getImage();
    createTerrainBody2(-terrainyImage.getWidth()/2, -terrainyImage.getHeight()/2);
 
    for (int i = 0; i < Constants.BEAVERS_PER_TEAM; i++) {
      int[] coord = randomFreeCoordinate(20);
      p1.getTeam()[i].setBody(new DynamicBody(new Circle(10.0f), -100*i, 1300));
      p1.getTeam()[i].getBody().setDensity(1);
      p1.getTeam()[i].getBody().setFriction(1000);
      p1.getTeam()[i].getBody().setRestitution(0f);
      p1.getTeam()[i].getBody().setAngularDamping(1f);
      p1.getTeam()[i].getBody().setFixedRotation(true);
      world.add(p1.getTeam()[i].getBody());
    }
   
    for (int i = 0; i < Constants.BEAVERS_PER_TEAM; i++) {
      int[] coord = randomFreeCoordinate(20);
      p2.getTeam()[i].setBody(new DynamicBody(new Circle(10.0f), -100*i, 1300));
      p2.getTeam()[i].getBody().setDensity(1);
      p2.getTeam()[i].getBody().setFriction(1000);
      p2.getTeam()[i].getBody().setRestitution(0f);
      p2.getTeam()[i].getBody().setAngularDamping(1f);
      p2.getTeam()[i].getBody().setFixedRotation(true);
      world.add(p2.getTeam()[i].getBody());
    }
 
 
   
    //Add the invisible boundary
    boundary = addBoundary(Constants.MAX_WIDTH*2,Constants.MAX_HEIGHT*3);
    boundary.setRestitution(0f);
    world.add(boundary);
    world.addBodyListener(boundary, this);
   
    // load beaver images to use in our animation
    Image beaver = new Image("data/bazooka4.png");
    Image beaver2 = new Image("data/bazooka5.png");
    Image[] frames = {beaver.getFlippedCopy(false, true).getScaledCopy(0.5f), beaver2.getFlippedCopy(false, true).getScaledCopy(0.5f)};
    Image[] frames2 = {beaver.getFlippedCopy(true, true).getScaledCopy(0.5f), beaver2.getFlippedCopy(true, true).getScaledCopy(0.5f)};
    team1Moving = new Animation(frames, 1000, false); // duration in ms
    team1MovingR = new Animation(frames2, 1000, false); // duration in ms
    Image beaver3 = new Image("data/darkBazooka4.png");
    Image beaver4 = new Image("data/darkBazooka5.png");
    Image[] frames3 = {beaver3.getFlippedCopy(false, true).getScaledCopy(0.5f), beaver4.getFlippedCopy(false, true).getScaledCopy(0.5f)};
    Image[] frames4 = {beaver3.getFlippedCopy(true, true).getScaledCopy(0.5f), beaver4.getFlippedCopy(true, true).getScaledCopy(0.5f)};
    team2Moving = new Animation(frames3, 1000, false); // duration in ms
    team2MovingR = new Animation(frames4, 1000, false); // duration in ms
   
    // add the mouse listener
    gc.getInput().addMouseListener(this);
   
    //add two items to the world
    item = new Item[]{new Item(), new Item()};
    item[0].setTypeAmmo();
    item[1].setTypeHP();
    item[0].getBody().setFriction(1000);
    item[1].getBody().setFriction(1000);
    item[0].getBody().setRestitution(0);
    item[1].getBody().setRestitution(0);
    item[0].getBody().setFixedRotation(true);
    item[1].getBody().setFixedRotation(true);
    world.add(item[0].getBody());
    world.add(item[1].getBody());
    world.addBodyListener(item[0].getBody(), this);
    world.addBodyListener(item[1].getBody(), this);
   
    Body currentBeaverBody = currentPlayer.getCurrentBeaver().getBody();
    crosshairAngle = 45;
    crosshair = new StaticBody(new Rectangle(50f,5f),currentBeaverBody.getX(),currentBeaverBody.getY());
    world.add(crosshair);
    crosshair.setRotation(crosshairAngle);
    crosshairImage = new Image("data/crosshair.png").getScaledCopy(0.5f);
    bulletImage = new Image("data/wood.png").getScaledCopy(0.5f);
    healthImage = new Image("data/health.png").getScaledCopy(0.5f);
    ammoImage = new Image("data/ammo.png").getFlippedCopy(false, true).getScaledCopy(0.5f);
    timer(Constants.SECONDS_PER_TURN);
    ///////////////////////////////////////////////
    if(currentPlayer==p2){
      waitToStart();
    }
View Full Code Here

  public int getID() {
    return stateID;
  }
 
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
    bg = new Image("data/menu/menu.png");
   
    start = new Image("data/menu/local.png");
    startWidth = start.getWidth();
    startHeight = start.getHeight();
    startX = 400-(startWidth/2);
   
    options = new Image("data/menu/network.png");
    optionsWidth = options.getWidth();
    optionsHeight = options.getHeight();
    optionsX = 400-(optionsWidth/2);
   
    exit = new Image("data/menu/quit.png");
    exitWidth = exit.getWidth();
    exitHeight = exit.getHeight();
    exitX = 400-(exitWidth/2);
   
    song = new Music("data/song.ogg");
View Full Code Here

  public int getID() {
    return stateID;
  }
 
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
    splashBG = new Image("data/menu/splash.jpg");
    dot = new Image("data/menu/dot.png");
  }
View Full Code Here

  }
 
  private void load(String identifier) {
    try {
      if(identifier.endsWith(".png")) {
        this.images.put(identifier, new Image(identifier));
      } else {
        throw new ResourceError("Unkown ressource type: " + identifier);
      }
      // this.schedule.remove(identifier);
    } catch(SlickException e) {
View Full Code Here

    }
  }
 
  public Image getImage(String id) {
    id = normalizeIdentifier(id);
    Image image = this.images.get(id);
    if(image == null) {
      load(id);
      return this.images.get(id);
    } else {
      return image;
View Full Code Here

    }
  }
 
  public Image getRevertedImage(String id) {
    id = normalizeIdentifier(id);
    Image image = this.images.get(id + "?reverse");
    if(image == null) {
      Image reverted = getImage(id).getFlippedCopy(true, false);
      this.images.put(id + "?reverse", reverted);
      return reverted;
    } else {
      return image;
    }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.Image

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.