@Override
  public void initResources() {

    final int MARGIN = 30;
    int x = container.getWidth();
    int y = container.getHeight();
    Image tmp = ResourceManager.getImage("butRetour");

    int larg = tmp.getWidth();
    int haut = tmp.getHeight();
    int yBut = y - haut - MARGIN;

    shapeListeServers = new Rectangle(MARGIN, 50, x / 2 - MARGIN - 10, yBut - 50);

    listeServers =
        new ListeDeroulante(
            container,
            ResourceManager.getImage("transparent"),
            (int) shapeListeServers.getX() + 5,
            (int) shapeListeServers.getY() + 5);
    listeServers.setScrolled(true);
    listeServers.setMaxElementsToDraw((int) shapeListeServers.getHeight() / 20);

    butRetour =
        new MouseOverArea(
            container, ResourceManager.getImage("butRetour"), MARGIN, yBut, larg, haut);
    butRetour.setMouseOverImage(ResourceManager.getImage("butRetourOver"));

    butCreerServer =
        new MouseOverArea(container, tmp, tmp.getWidth() + MARGIN * 2, yBut, larg, haut);
    butCreerServer.setMouseOverImage(ResourceManager.getImage("MenuJouerOver"));

    timerRefreshServers = new Timer(7000);
  }
Beispiel #2
0
  /** Special render method for the TiledMap foreground layer. */
  private void renderFore() {

    if (playerIsBehindForeground(curPlayerX, curPlayerY) || movedIntoOpen) {

      // Update the non-rendered tiles if the player
      // is occupying a new tile this frame
      if (updateForeground || movedIntoOpen) {
        updateForeground = false;

        for (int i = 0; i < foreAlpha.length; i++) {
          map.setTileId(foreAlpha[i][0], foreAlpha[i][1], foregroundLayerIndex, foreAlpha[i][2]);
        }
        foreAlphaIndex = 0;
      }

      if (changedPosition && !movedIntoOpen) {
        for (int y = curPlayerY - foregroundAlphaRadius;
            y <= curPlayerY + foregroundAlphaRadius;
            y++) {
          for (int x = curPlayerX - foregroundAlphaRadius;
              x <= curPlayerX + foregroundAlphaRadius;
              x++) {
            int dX = curPlayerX - x;
            int dY = curPlayerY - y;
            float dd = (float) Math.sqrt((dX * dX) + (dY * dY));
            if (dd <= foregroundAlphaRadius + 0.5
                && x >= 0
                && y >= 0
                && x < map.getWidth()
                && y < map.getHeight()) {
              addToForegroundAlpha(
                  x,
                  y,
                  map.getTileId(x, y, foregroundLayerIndex),
                  map.getTileImage(x, y, foregroundLayerIndex));
              map.setTileId(x, y, foregroundLayerIndex, 0);
            }
          }
        }
      }
    }
    renderLayer("FOREGROUND");

    if (playerIsBehindForeground(curPlayerX, curPlayerY)) {
      for (int i = 0; i < foreAlphaImage.length; i++) {
        try {
          int x = foreAlpha[i][0];
          int y = foreAlpha[i][1];
          float dX = (vPlayerX / tileWidth) - x;
          float dY = (vPlayerY / tileHeight) - y;
          float dd = (float) Math.sqrt((dX * dX) + (dY * dY));
          float alpha = (dd / foregroundAlphaRadius) + 0.25f;
          Image image = foreAlphaImage[i];
          image.setAlpha(alpha);
          image.draw(x * tileWidth, y * tileHeight);
        } catch (Exception e) {
        }
      }
    }
  }
Beispiel #3
0
  @Override
  public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta)
      throws SlickException {
    super.update(gameContainer, stateBasedGame, delta);
    rotation += (targetrotation - rotation) / rotationEase;
    tandwiel1.setRotation(rotation);
    tandwiel2.setRotation((float) ((float) -(rotation * 1.818181818181818) + 16.36363636363636));
    spinner.setRotation(rotation);

    if (frameGrabber != null && updateCamera) {
      updateCamera = false;
      buffer = frameGrabber.grabFrame();
      awtFrame = new BufferToImage((VideoFormat) buffer.getFormat()).createImage(buffer);
      BufferedImage bufferedImage =
          new BufferedImage(
              awtFrame.getWidth(null), awtFrame.getHeight(null), BufferedImage.TYPE_INT_RGB);
      bufferedImage.createGraphics().drawImage(awtFrame, 0, 0, this);
      baseImage = bufferedImage;
      try {
        texture = BufferedImageUtil.getTexture("", baseImage);
        webcamFeed.setTexture(texture);
      } catch (IOException e) {
        logger.error(e);
      }
    }
    calculatePulse();
  }
Beispiel #4
0
 public void render(GameContainer arg0, StateBasedGame arg1, Graphics g) throws SlickException {
   g.drawString("Choose your Vehicle", 240, 30);
   try {
     base = new Image("sideView/base.png");
     turret = new Image("sideView/turret.png");
     gun = new Image("sideView/gun.png");
     plane = new Image("sideView/plan.png");
     boat = new Image("sideView/boat.png");
   } catch (SlickException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   if (base != null) {
     base = base.getScaledCopy(3);
     turret = turret.getScaledCopy(3);
     gun = gun.getScaledCopy(3);
     plane = plane.getScaledCopy(3);
     boat = boat.getScaledCopy(3);
     g.drawImage(base, 50, 50);
     g.drawImage(turret, 150, 50);
     g.drawImage(gun, 250, 50);
     g.drawImage(plane, 350, 50);
     g.drawImage(boat, 450, 50);
   }
 }
  @Override
  public void update(GameContainer container, StateBasedGame game, int delta)
      throws SlickException {
    Input input = container.getInput();
    int mouseX = input.getMouseX();
    int mouseY = input.getMouseY();
    boolean startGame = false;
    boolean exitGame = false;

    if ((mouseX >= menuX && mouseX <= menuX + startGameOption.getWidth())
        && (mouseY >= menuY && mouseY <= menuY + startGameOption.getHeight())) {
      startGame = true;
    } else if ((mouseX >= menuX && mouseX <= menuX + exitOption.getWidth())
        && (mouseY >= menuY + 100 && mouseY <= menuY + 100 + exitOption.getHeight())) {
      exitGame = true;
    }

    if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
      if (startGame) {
        game.enterState(RunGame.GAMEPLAYSTATE);
      } else if (exitGame) {
        container.exit();
      }
    }
  }
Beispiel #6
0
  public Lightning(float x, float y, String i, World world) {
    super(x, y, i, world);

    int numFrames = 4;
    Image sheet;
    try {
      sheet = new Image("assets/Art/Transformations/Animations/lightning.png");
      projectileWidth = sheet.getWidth() / numFrames;
      projectileHeight = sheet.getHeight();
      SpriteSheet ss = new SpriteSheet(sheet, projectileWidth, projectileHeight);
      projectileRightAnimation = new Animation(ss, 100);
      projectileRightAnimation.stopAt(projectileRightAnimation.getFrameCount() - 1);
      ss = new SpriteSheet(ss.getFlippedCopy(true, false), projectileWidth, projectileHeight);
      projectileLeftAnimation = new Animation(ss, 100);
      projectileLeftAnimation.stopAt(projectileLeftAnimation.getFrameCount() - 1);
    } catch (SlickException e) {
      e.printStackTrace();
    }

    damage = 3;
    projectileRange = 600;
    projectileXVelocity = 3;
    dropChance = false;
    startUpTime = .01;
    reloadTime = 800;
    projectileOffsets = new Rectangle(10, 10, 20, 20);
  }
 @Override
 public void render(GameContainer container, StateBasedGame game, Graphics g)
     throws SlickException {
   background.draw(0, 0);
   startGameOption.draw(menuX, menuY);
   exitOption.draw(menuX, menuY + 100);
 }
Beispiel #8
0
  @Override
  public void render(Graphics g) {
    int sx = 0;
    int sy = 0;

    if (moving() && onGround()) {
      sx = frame % nb_sprites;
      sy = 0;
    } else if (onGround()) {
      sx = 0;
      sy = 0;
    }

    // get the appropriate sprite
    Image image = walk.getSprite(sx, sy);
    image = image.getFlippedCopy(true, false);

    // if we're facing the other direction, flip the sprite over
    if (facingRight()) {
      image = image.getFlippedCopy(true, false);
    }

    image.draw(getX() - width / 2, getY() - height / 2, width, height + 4);
    permanentSound();
  }
Beispiel #9
0
  public Image getImage() throws SlickException {
    noOffset.getGraphics().clear(); // Strange things happen without this...

    for (int i = 0; i < 21; i++) // Loop to generate the background image, which is 20 tiles long
    {

      if (blockArray[i] == false) // Draw these tiles if there isn't a block at this position
      {
        noOffset.getGraphics().drawImage(sheet.getSprite(0, 0), i * 32, 0);
        noOffset.getGraphics().drawImage(sheet.getSprite(0, 1), i * 32, 32);
      } else // Draw these tiles if there IS a block at this position
      {
        noOffset.getGraphics().drawImage(sheet.getSprite(0, 3), i * 32, 0);
        noOffset.getGraphics().drawImage(sheet.getSprite(0, 4), i * 32, 32);
      }

      if (gapArray[i]
          == false) // Draw this tile if there isn't a gap. If there is a gap, no tile is drawn
                    // (convenient eh?)
      {
        noOffset.getGraphics().drawImage(sheet.getSprite(0, 2), i * 32, 64);
      }
    }

    return noOffset.getSubImage(
        timeElapsed / 5,
        0,
        32 * 19,
        32 * 3); // Return the part of the image that is drawn on screen,
    // which is shifted depending on time elapsed.
    // In 160 ms, the tile will be shifted 32 pixels.
  }
  @Override
  public void render(GameContainer gc, StateBasedGame sb, Graphics g) throws SlickException {
    // Background etc.
    g.setAntiAlias(true);
    g.drawImage(
        background,
        gc.getWidth() / 2 - background.getWidth() / 2,
        gc.getHeight() / 2 - background.getHeight() / 2);
    uniTitle.drawString(
        gc.getWidth() / 2 - uniTitle.getWidth("Highscores") / 2,
        (float) 0,
        "Highscores",
        Color.orange);

    count = 0;

    // Zeichnet die Überschrift
    MenuItem item = levelNames.get(0);
    uniNormal.drawString(item.getPos().x, item.getPos().y, item.getName(), item.getColor());
    item = playerNames.get(0);
    uniNormal.drawString(item.getPos().x, item.getPos().y, item.getName(), item.getColor());
    item = times.get(0);
    uniNormal.drawString(item.getPos().x, item.getPos().y, item.getName(), item.getColor());

    // Von start bis zu end
    for (int i = start; i <= end; i++) {
      // Falls wir am ende der Liste angekommen sind, abbrechen und itemsOnSide setzen
      if (i == levelNames.size()) {
        itemsOnSide = i - start;
        break;
      }
      // Maximale itemsOnSide = 10
      else {
        itemsOnSide = 10;
      }

      // Zeichnen der Highscores
      item = levelNames.get(i);
      uniNormal.drawString(item.getPos().x, item.getPos().y, item.getName(), item.getColor());
      item = playerNames.get(i);
      uniNormal.drawString(item.getPos().x, item.getPos().y, item.getName(), item.getColor());
      item = times.get(i);
      uniNormal.drawString(item.getPos().x, item.getPos().y, item.getName(), item.getColor());
    }

    g.setColor(Color.green);
    g.draw(selection);

    // aktuelle Seite zeichnen
    String displayside = "Seite " + (side + 1) + " von " + sideCount;
    uniNormal.drawString(
        gc.getWidth() / 2 - uniNormal.getWidth(displayside) / 2,
        gc.getHeight() - uniNormal.getHeight(displayside),
        displayside,
        Color.orange);

    // ESC String
    uniNormal.drawString(
        0, gc.getHeight() - uniNormal.getHeight("ESC = Zurück"), "ESC = Zurück", Color.orange);
  }
Beispiel #11
0
  public Level(int id, GameFactory factory) throws SlickException {
    super(id, EntityType.LEVEL);

    this.currentPlayerId = -1;

    this.factory = factory;
    AssetMgr assets = factory.getAssetMgr();

    // Load Images
    Image tmp = assets.storeImage(Assets.LevelBackgroundImageId, "backgrounds/background.png");
    assets.storeImage(Assets.LevelBackgroundImageId, tmp.getScaledCopy(1350, 800));
    tmp = assets.storeImage(Assets.LevelMiddlegroundImageId, "backgrounds/middleground.png");
    assets.storeImage(Assets.LevelMiddlegroundImageId, tmp.getScaledCopy(1850, 800));
    this.groundMap = assets.storeTiledMap(Assets.LevelTileMapId, "tiles/blocks.tmx");

    // gfx
    this.backgroundImage =
        factory.createImageEntity(Assets.LevelBackgroundImageId, Assets.LevelBackgroundImageId);
    this.backgroundImage.setVisible(true);
    add(this.backgroundImage);

    this.middlegroundImage =
        factory.createImageEntity(Assets.LevelMiddlegroundImageId, Assets.LevelMiddlegroundImageId);
    this.middlegroundImage.setVisible(true);
    add(this.middlegroundImage);

    this.ground = factory.createTiledMapEntity(Assets.LevelTileMapId, Assets.LevelTileMapId);
    this.ground.setVisible(true);
    this.ground.setActive(true);
    add(this.ground);

    // physics
    setData(new float[] {0, 0, 0, 0, 1, 1, 0});

    // network
    setUpdateStrategy(EntityUpdateStrategy.Local);

    // order
    setOrder(EntityOrder.Level);

    // Shader Setup
    if (textureBuffer == null && Constants.Debug.shadersActive) {
      textureBuffer = new Image(JumpNRun.SCREENWIDTH, JumpNRun.SCREENHEIGHT);
      fbGraphics = textureBuffer.getGraphics();
      blur1D = new BlurShader();
      glowshader =
          new Shader("content/jumpnrun/shader/simple.vert", "content/jumpnrun/shader/glow.frag");
      glowshader2 =
          new Shader("content/jumpnrun/shader/simple.vert", "content/jumpnrun/shader/glow.frag");

      // For testing
      params = new ShaderParams();
      params.showEditor("Shader-Einstellungen!!!");
    }

    // setup
    setActive(true);
    setVisible(true);
  }
Beispiel #12
0
  public TexturedQuad(Image img, Orientation orientation, int angle) {
    this.img = img;
    this.flip = orientation == Orientation.LEFT;
    this.angle = angle;

    centerX = img.getWidth() / 2;
    centerY = img.getHeight() / 2;
  }
  @Override
  public void init(GameContainer container, StateBasedGame game) throws SlickException {
    background = new Image("tloc/gui/res/background.png");

    Image menuOptions = new Image("tloc/gui/res/menuoptions.png");
    startGameOption = menuOptions.getSubImage(0, 0, 240, 70);
    exitOption = menuOptions.getSubImage(135, 127, 240, 60);
  }
Beispiel #14
0
 public Rock(Image image, float x, float y, int id) {
   this.image = image;
   this.x = x;
   this.y = y;
   this.height = image.getHeight();
   this.width = image.getWidth();
   this.id = id;
 }
Beispiel #15
0
 public Enemy(Image image, Vector2f location) {
   this.image = image;
   loc = location;
   collisionRect = new Rectangle(0, 0, image.getWidth(), image.getHeight());
   collisionRect.setCenterX(loc.x);
   collisionRect.setCenterY(loc.y);
   isDead = false;
 }
  /**
   * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer,
   *     org.newdawn.slick.Graphics)
   */
  public void render(GameContainer container, Graphics g) {
    g.setBackground(Color.lightGray);
    //		image.draw(0,0, inside ? Color.red : Color.white);
    //		timage.draw(10,310);

    image.draw();
    timage.draw(image.getWidth(), 0);
  }
Beispiel #17
0
 public Button(Image button, int x, int y, int images) {
   int imageHeight = button.getHeight() / images;
   Image btn = button.getSubImage(0, 0, button.getWidth(), imageHeight);
   Image hover = button.getSubImage(0, imageHeight, button.getWidth(), imageHeight);
   Image click = button.getSubImage(0, imageHeight * 2, button.getWidth(), imageHeight);
   Image disabled = button.getSubImage(0, imageHeight * 3, button.getWidth(), imageHeight);
   constructorHack(
       null, btn, hover, click, disabled, new Rectangle(x, y, button.getWidth(), imageHeight));
 }
 @Override
 public void render(GameContainer container, Graphics g) throws SlickException {
   // throw new UnsupportedOperationException("Not supported yet.");
   // g.drawString("Hello World", 100, 100);
   land.draw(0, 0);
   plane1.draw(
       (float) jugador1.getPosicion().getX(), (float) jugador1.getPosicion().getY(), 0.75f);
   plane2.draw(
       (float) jugador2.getPosicion().getX(), (float) jugador2.getPosicion().getY(), 0.75f);
 }
Beispiel #19
0
 public Player(
     World world,
     float x,
     float y,
     float mass,
     String name,
     SoundWrapper soundWrapper,
     Image image) {
   super(world, x, y, image.getWidth(), image.getHeight(), mass, name, soundWrapper);
   setImage(image);
 }
Beispiel #20
0
 public static Image makeTestImage(int width, int height, Color color, String text)
     throws SlickException {
   Image im = new Image(width, height);
   im.getGraphics().setColor(color);
   im.getGraphics().fillRect(0, 0, width, height);
   im.getGraphics().setColor(Color.white);
   im.getGraphics().setFont(Constants.PRIMARY_FONT);
   im.getGraphics().drawString(text, 0, 0);
   im.getGraphics().flush();
   return im;
 }
Beispiel #21
0
  @Override
  public void init(GameContainer container, StateBasedGame game) throws SlickException {
    this.container = container;
    this.game = game;
    this.input = container.getInput();

    // initialize buttons
    Image button = GameImage.MENU_BUTTON_MID.getImage();
    button = button.getScaledCopy(container.getWidth() / 2, button.getHeight());
    Image buttonL = GameImage.MENU_BUTTON_LEFT.getImage();
    Image buttonR = GameImage.MENU_BUTTON_RIGHT.getImage();
    for (MenuState ms : MenuState.values()) ms.init(container, game, button, buttonL, buttonR);
  }
 @Override
 public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
   knight.draw(594, 360);
   mage.draw(784, 360);
   thief.draw(976, 360);
   g.setColor(Color.white);
   g.drawString("Name:", 650, 500);
   tf.render(gc, g);
   tf.setFocus(true);
   for (int i = 0; i < buttons.size(); i++) {
     buttons.get(i).draw(g);
   }
 }
Beispiel #23
0
 public Button(
     Image button, Image buttonHover, Image buttonClick, Image buttonDisabled, int x, int y) {
   if (button == null) {
     throw new IllegalArgumentException("Button image cannot be null.");
   }
   constructorHack(
       null,
       button,
       buttonHover,
       buttonClick,
       buttonDisabled,
       new Rectangle(x, y, button.getWidth(), button.getHeight()));
 }
Beispiel #24
0
 public void render(GameContainer container, Graphics g) throws SlickException {
   if (isFlippedHorizontally) {
     currentImage = imageLeft;
     spinAngularVelocity = -15;
   } else {
     currentImage = imageRight;
     spinAngularVelocity = 15;
   }
   spinAngle += spinAngularVelocity;
   currentImage.setRotation(spinAngle);
   currentImage.draw(xCoord, yCoord);
   // g.draw(getHitbox());
 }
  @Override
  protected void processEntities(ImmutableBag<Entity> entities) {
    ensurePlayerEntity();

    if (player != null) {
      hudBg.draw(
          0, container.getHeight() - hudBg.getHeight(), container.getWidth(), hudBg.getHeight());

      renderHealth();
      renderAmmo();
    }

    renderMinimap();
  }
 /**
  * Indicates whether the game is over or not. If the game is over it draws a message showing which
  * player has won.
  *
  * @return Whether the game is over or not.
  * @throws SlickException
  */
 private boolean gameOver(StateBasedGame sbg, GameContainer gc) throws SlickException {
   if (!gameOver) {
     return false;
   } else {
     if (player1.getLives() <= 0) {
       sbg.enterState(Main.GAMEOVERSTATE);
     } else { // Draws a message saying player1 has won.
       Image gameOverMessage = new Image("data/player1_win.png");
       gameOverMessage.draw(
           windowSizeX / 2 - gameOverMessage.getWidth() / 2,
           windowSizeY / 2 - gameOverMessage.getHeight() / 2);
     }
   }
   return true;
 }
Beispiel #27
0
 public void Render(int i, Graphics g) throws SlickException {
   if (i == 0) {
     pic.draw(150, 200);
     g.drawString("Name " + name, 100, 100);
     g.drawString("Hp " + hp, 100, 120);
     g.drawString("Damage " + damage, 100, 140);
     g.drawString("Delay " + delay, 100, 160);
   } else {
     pic.draw(550, 200);
     g.drawString("Name " + name, 400, 100);
     g.drawString("Hp " + hp, 400, 120);
     g.drawString("Damage " + damage, 400, 140);
     g.drawString("Delay " + delay, 400, 160);
   }
 }
Beispiel #28
0
 public void render(Graphics g) {
   // render all except entities
   for (int l = 0; l < map.getLayerCount(); l++) {
     String value = map.getLayerProperty(l, "type", null);
     if (value == null || !value.equalsIgnoreCase("entity")) {
       for (int w = 0; w < map.getWidth(); w++) {
         for (int h = 0; h < map.getHeight(); h++) {
           Image img = map.getTileImage(w, h, l).getScaledCopy(4);
           if (img != null) {
             g.drawImage(img, w * img.getWidth(), h * img.getHeight());
           }
         }
       }
     }
   }
 }
  @Override
  public void render(GameContainer gc, Graphics g) throws SlickException {
    backgroundImage.draw();

    Airplane airplaneHandle;
    Iterator<Airplane> it;
    it = airQueue.iterator();
    while (it.hasNext()) {
      airplaneHandle = it.next();

      airplaneHandle.render(g, airplaneImage);
    }
    it = groundQueue.iterator();
    while (it.hasNext()) {
      airplaneHandle = it.next();

      airplaneHandle.render(g, airplaneImage);
    }
    airplaneHandle = runway.getCurrentAirplane();
    if (airplaneHandle != null) airplaneHandle.render(g, airplaneImage);

    g.setColor(Color.white);
    g.drawString("Airport Simulator", gc.getWidth() - 170, 10);
    g.drawString("Update: " + currentUpdate, gc.getWidth() - 130, gc.getHeight() - 30);
  }
Beispiel #30
0
  @Override
  public void update(GameContainer container, int delta)
      throws SlickException, InterruptedException {
    if (isFlippedHorizontally) {
      angularVelocity = 2;
      spinAngularVelocity = 15;
      xCoord =
          xCenterOfRotation
              + (float) (radius * Math.cos(angle * Math.PI / 180))
              - imageRight.getWidth();
      yCoord = yCenterOfRotation - (float) (radius * Math.sin(angle * Math.PI / 180));
    } else {
      angularVelocity = -2;
      spinAngularVelocity = -15;
      xCoord = xCenterOfRotation + (float) (radius * Math.cos(angle * Math.PI / 180));
      yCoord = yCenterOfRotation - (float) (radius * Math.sin(angle * Math.PI / 180));
    }

    angle += angularVelocity;
    // Remove when angle = PI,0
    if (angle <= 0 || angle > 180) {
      world.remove(this);
    }
    setHitboxLocation(xCoord, yCoord);
  }