public SplashRenderer(Application app) {

    font = new BitmapFont(Gdx.files.internal("data/default.fnt"), false);
    try {
      spriteBatch = new SpriteBatch();
      skin =
          new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
      stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
      InputStream in = Gdx.files.internal("data/ship02.obj").read();
      shipMesh = ObjLoader.loadObj(in, true);
      in.close();
      in = Gdx.files.internal("data/jet.obj").read();
      jetMesh = ObjLoader.loadObj(in, true);
      in.close();
      in = Gdx.files.internal("data/sun.obj").read();
      sunMesh = ObjLoader.loadObj(in, true);
      in.close();

      in = Gdx.files.internal("data/planet.obj").read();
      planetMesh = ObjLoader.loadObj(in, true);
      in.close();

      in = Gdx.files.internal("data/planet02.obj").read();
      planetMesh02 = ObjLoader.loadObj(in, true);
      in.close();

      in = Gdx.files.internal("data/shot.obj").read();
      ObjLoader.loadObj(in, false);
      in.close();
      // note use of tru to flip texture V co-ords for max OBJ files
      in = Gdx.files.internal("data/sky.obj").read();
      skyMesh = ObjLoader.loadObj(in, true);
      in.close();
      progressBarTexture = new Texture(Gdx.files.internal("data/progbar.png"), Format.RGB565, true);
      progressBarTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

      camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #2
0
  /**
   * This method is called right after initialize() method in Android Project. Loads meshes(.obj)
   * and textures(.png) from /data folder. Creates perspective camera. Starts physics.
   *
   * @throws IOException This Exception is thrown when specific file is not found.
   */
  public LevelScreen1(Tyrian game, Float index, float x, float y, float z) throws IOException {
    this.game = game;
    int width = (isGameScreen() ? GAME_VIEWPORT_WIDTH : MENU_VIEWPORT_WIDTH);
    int height = (isGameScreen() ? GAME_VIEWPORT_HEIGHT : MENU_VIEWPORT_HEIGHT);
    this.stage = new Stage(width, height, true);
    this.indexior = index;
    this.pozx = x;
    this.pozy = y;
    this.pozz = z;

    // Loading meshes + textures
    try {

      InputStream spherefile = Gdx.files.internal("sphere.obj").read();
      sphere = ObjLoader.loadObj(spherefile, false);
      spherefile.close();

      InputStream planefile = Gdx.files.internal("plane.obj").read();
      plane = ObjLoader.loadObj(planefile, false);
      planefile.close();

      InputStream wallfile = Gdx.files.internal("cube.obj").read();
      wall = ObjLoader.loadObj(wallfile, false);
      wallfile.close();

      InputStream targetfile = Gdx.files.internal("target.obj").read();
      target = ObjLoader.loadObj(targetfile, false);
      targetfile.close();

      FileHandle steelfile = Gdx.files.internal("Steel.png");
      steel = new Texture(steelfile);

      FileHandle woodfile = Gdx.files.internal("wall_wood.png");
      wood = new Texture(woodfile);

      FileHandle stonefile = Gdx.files.internal("floor_stones.png");
      stone = new Texture(stonefile);

      FileHandle greenfile = Gdx.files.internal("zielonaa.png");
      green = new Texture(greenfile);

      FileHandle pinkfile = Gdx.files.internal("roze.png");
      pink = new Texture(pinkfile);

      FileHandle majafile = Gdx.files.internal("maja.png");
      maja = new Texture(majafile);

      FileHandle blackfile = Gdx.files.internal("czarna.png");
      black = new Texture(blackfile);

      FileHandle aimfile = Gdx.files.internal("aim.png");
      aim = new Texture(aimfile);

    } catch (IOException e) {
      e.printStackTrace();
    }

    // Camera initialization
    float aspectRatio = (float) Gdx.graphics.getWidth() / (float) Gdx.graphics.getHeight();
    camera = new PerspectiveCamera(67, 2f * aspectRatio, 2f);

    position = new Vector3();

    initPhysics();
  }