Package beaver.game

Source Code of beaver.game.SplashScreenState

package beaver.game;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class SplashScreenState extends BasicGameState {

  // Initialize stateID to an "impossible" value
  int stateID = -1;
 
  // Initialize our menu images
  Image splashBG = null;
  Image dot = null;
 
  // Number of dots to draw
  int numDots = 0;
 
  // Number of updates
  int numUpdates = 0;
 
  SplashScreenState(int stateID)
  {
    this.stateID = stateID;
  }
 
  @Override
  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");
  }
   
  public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
    splashBG.draw(0,0);
    if (numDots >= 1) dot.draw(535, 295);
    if (numDots >= 2) dot.draw(565, 295);
    if (numDots >= 3) dot.draw(595, 295);
  }
 
  public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
    try {
      Thread.sleep(1000);
    }
    catch (InterruptedException ie) {}
    if(numDots>=3) numDots = 0;
    else numDots++;
   
    numUpdates++;
    if (numUpdates>=7) sbg.enterState(BeaversGame.MAINMENUSTATE);
  }
}
TOP

Related Classes of beaver.game.SplashScreenState

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.