Package it.marteEngine.test.platformer

Source Code of it.marteEngine.test.platformer.PlatformerTest

package it.marteEngine.test.platformer;

import it.marteEngine.ME;
import it.marteEngine.ResourceManager;

import java.io.IOException;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.util.Log;

/**
* Platformer Test
*
* @author Gornova
*/
public class PlatformerTest extends StateBasedGame {

  public static final int GAME_STATE = 0;
  private static boolean ressourcesInited;

  public PlatformerTest() {
    super("PlatformerTest MarteEngine");
  }

  @Override
  public void initStatesList(GameContainer container) throws SlickException {
    initRessources();
    PlatformerGameWorld gameState = new PlatformerGameWorld(GAME_STATE);

    addState(gameState);
  }

  public static void initRessources() throws SlickException {
    if (ressourcesInited)
      return;
    try {
      ResourceManager.loadResources("data/platformer/resources.xml");
    } catch (IOException e) {
      Log.error("failed to load ressource file 'data/platformer/resources.xml': "
          + e.getMessage());
      throw new SlickException("Resource loading failed!");
    }

    ressourcesInited = true;
  }

  public static void main(String[] argv) {
    try {
      ME.keyToggleDebug = Input.KEY_1;
      AppGameContainer container = new AppGameContainer(
          new PlatformerTest());
      container.setDisplayMode(640, 480, false);
      container.setTargetFrameRate(60);
      container.setShowFPS(false);
      container.start();
    } catch (SlickException e) {
      e.printStackTrace();
    }
  }

}
TOP

Related Classes of it.marteEngine.test.platformer.PlatformerTest

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.