Package ru.vagrant_ai.questionmarkgame.obj.item

Source Code of ru.vagrant_ai.questionmarkgame.obj.item.BonusItem

package ru.vagrant_ai.questionmarkgame.obj.item;

import java.util.Random;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;

import ru.vagrant_ai.questionmarkgame.main.Game;
import ru.vagrant_ai.questionmarkgame.main.GameplayState;
import ru.vagrant_ai.questionmarkgame.util.list.IS;
import ru.vagrant_ai.questionmarkgame.util.list.ITEM;

public class BonusItem {

  int arg0;
  float f_arg0;
 
  ITEM id;
  String name[] = {"",""};
  Rectangle hitbox;
  float x;
  float y;
  public IS state = IS.FALLING;
  boolean queue_rule = false; //if item mustn't be announced, then set to true
 
  int util_activating = 0;
 
  public BonusItem()
  {
    x = new Random().nextInt(Game.getAppX()-60)+30;
    y = -120;
    hitbox = new Rectangle(x,y,30,30);
  }
   
  public void update()
  {
    switch(state)
    {
    case FALLING:
      int gr_lv = GameplayState.ground_level+12;
      if (y != gr_lv) y++;
      if (y == gr_lv) state = IS.WAITING;
    case WAITING:
      checkIntersection();
      break;
    default: break;
    }
  }
 
  public void render(Graphics g) throws SlickException {
    if (state == IS.WAITING || state == IS.FALLING)
    {
      g.setColor(new Color(162, 83, 81));
      g.fillRect(x, y, 30, 30);
      g.setColor(new Color(90,46,46)); //box border
      g.setLineWidth(5);
      g.drawRect(x, y, 30, 30);
      hitbox.setBounds(x, y, 30, 30);
    }
  }
 
  private void checkIntersection() {
    if (hitbox.intersects(GameplayState.player.hitbox))
    {
      perform();
      state = IS.NULL;
      if (queue_rule == false) GameplayState.dispenser.addToQueue(id, name);
    }
     
  }
 
  public boolean check() {
    return false;
  }
 
  protected void perform()
  {
  }
 
  public float getX() {
    return x;
  }
 
  public float getY() {
    return y;
  }
 
  public void setXY(float x, float y) {
    this.x = x;
    this.y = y;
    return;
 

}
TOP

Related Classes of ru.vagrant_ai.questionmarkgame.obj.item.BonusItem

TOP
Copyright © 2018 www.massapi.com. 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.