Package ru.vagrant_ai.questionmarkgame.obj

Source Code of ru.vagrant_ai.questionmarkgame.obj.GUI

package ru.vagrant_ai.questionmarkgame.obj;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

import ru.vagrant_ai.questionmarkgame.main.GameplayState;
import ru.vagrant_ai.questionmarkgame.util.Text;
import ru.vagrant_ai.questionmarkgame.util.Util;

public class GUI {

  private Image money_icon;
  private Image bullet, bullet_empty;
  private final byte text_size = 38;
  public byte util_offset = 0;
  public byte money_offset = 0;
  private byte util_iter = 3;
 
  public GUI()
  {
    bullet = Util.loadImage("particle/bullet");
    bullet_empty = Util.loadImage("particle/bullet_empty");
    money_icon = Util.loadImage("particle/money0");
  }
 
  public void render_1st_layer(Graphics g) //all frames goes here
  {

  }
 
  public void render_2nd_layer(Graphics g)
  {
    if (GameplayState.player.gun.util_chamber == 0)
      g.setColor(new Color(255, 0, 0, 160));
    else
      g.setColor(Color.black);
    g.fillRoundRect(-5, 15, 100, 20+util_offset, 5);
    g.setColor(Color.black);
    g.fillRoundRect(-5, 40+util_offset, 100, 20, 5);
    g.fillRoundRect(-5, 65+util_offset, 100+money_offset, 20+money_offset, 5);
    g.setColor(new Color(170, 170, 170));
    g.setLineWidth(1);
    g.drawRoundRect(-5, 15, 100, 20+util_offset, 5);
    g.drawRoundRect(-5, 40+util_offset, 100, 20, 5);
    g.drawRoundRect(-5, 65+util_offset, 100+money_offset, 20+money_offset, 5);
    render_bullets(g);
    render_wave(g);
    render_money_collected(g);
  }
 
    private void render_bullets(Graphics g)
    {
      for (int i = 0; i < GameplayState.player.gun.opt_chamber; i++)
      {
        int j = i;
        if (j >= 24)
          j -= 24;
        else if (j >= 12)
          j -= 12;
        if (GameplayState.player.gun.getChamber() <= i)
          bullet_empty.draw(5+j*7, 18+(i>=24?32:(i>=12?16:0)));
        else
          bullet.draw(5+j*7, 18+(i>=24?32:(i>=12?16:0)));
      }
    }
         
    private void render_wave(Graphics g)
    {
      Text.drawString(text_size, 5, 42+util_offset, "Wave "+GameplayState.monster_controller.currentWave(), Color.red);
    }
   
    private void render_money_collected(Graphics g)
    {
      money_icon.getScaledCopy(1.0f+(float)money_offset/50).draw(4, 67+util_offset);
      Text.drawString(text_size+money_offset*2, 20, 67+util_offset, ""+GameplayState.player.getMoney(), Color.red);

    }

    public void update()
    {
      if (money_offset > 0)
      {
        util_iter--;
        if (util_iter < 1)
        {
          util_iter = 3;
          money_offset--;
        }
      }
    }
   

 
 
}
TOP

Related Classes of ru.vagrant_ai.questionmarkgame.obj.GUI

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.