예제 #1
0
파일: Level.java 프로젝트: bullerta/rgb4
  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);
  }
예제 #2
0
 public GameFactory getFactory(String name) {
   GameFactory factory = null;
   for (GameFactory gf : availableGames)
     if (gf.getName().equalsIgnoreCase(name)) {
       factory = gf;
       break;
     }
   return factory;
 }
예제 #3
0
파일: Level.java 프로젝트: bullerta/rgb4
  public Player getPlayer(int id) {
    if (id == -1) {
      return null;
    }

    Entity player = factory.getEntity(id);
    if (player instanceof Player) {
      return (Player) player;
    }
    throw new RuntimeException("id doesn't match requested entity type");
  }
예제 #4
0
 public static void gamesConsumer(GameFactory factory) {
   game = factory.getGame();
   while (game.move()) ;
 }
예제 #5
0
 @Before
 public void setUp() throws Exception {
   game = GameFactory.createGame();
 }
예제 #6
0
파일: Level.java 프로젝트: bullerta/rgb4
  @Override
  protected void postRender(Graphics graphicContext) {
    super.postRender(graphicContext);

    graphicContext.setColor(Constants.Debug.overlayColor);
    graphicContext.drawString(
        "NetworkID: "
            + NetworkComponent.getInstance().getNetworkId()
            + "\n"
            + factory.size()
            + " entities",
        20,
        50);

    Entity e = this;
    graphicContext.drawString(
        "Level\n"
            + "ID: "
            + e.getId()
            + "\n"
            + " X: "
            + e.getData()[X]
            + "  Y: "
            + e.getData()[Y]
            + "\n"
            + "OX: "
            + e.getData()[CENTER_X]
            + " OY: "
            + e.getData()[CENTER_Y]
            + "\n"
            + "FX: "
            + "SX: "
            + e.getData()[SCALE_X]
            + " SY: "
            + e.getData()[SCALE_Y]
            + "\n"
            + "ROT: "
            + e.getData()[ROTATION],
        20,
        100);

    e = getCurrentPlayer();
    if (e != null) {
      graphicContext.drawString(
          "Player\n"
              + "ID: "
              + e.getId()
              + "\n"
              + " X: "
              + e.getData()[X]
              + "  Y: "
              + e.getData()[Y]
              + "\n"
              + "OX: "
              + e.getData()[CENTER_X]
              + " OY: "
              + e.getData()[CENTER_Y]
              + "SX: "
              + e.getData()[SCALE_X]
              + " SY: "
              + e.getData()[SCALE_Y]
              + "\n"
              + "ROT: "
              + e.getData()[ROTATION]
              + "\n"
              + "STATE: "
              + ((Player) e).currentState,
          20,
          250);
    }
  }
예제 #7
0
 public static void playGame(GameFactory factory) {
   Game s = factory.getGame();
   while (s.move()) ;
 }