Esempio n. 1
0
  private static void setScreenMode(
      String title, Resources resources, int width, int height, boolean resizable) {
    Video.setWindowTitle(title);

    // According to the SDL1.2 docs, windows MUST be given a 32x32 image. How very quaint (windows
    // is s***e).
    // For good looking OSes, we should try to use a bigger icon if there is one.
    // Note that these must be bmp (yuck!), and not png, because it uses SDL_LoadBMP. Annoying!
    String filename32 = resources.resolveFilename("icon32.bmp");
    String filename = resources.resolveFilename("icon.bmp");

    if (System.getProperty("os.name").startsWith("Windows")) {
      filename = filename32;
    }

    try {
      if (new File(filename).exists()) {
        Video.setWindowIcon(filename);
      } else if (new File(filename32).exists()) {
        Video.setWindowIcon(filename32);
      }
    } catch (Exception e) {
      // Do nothing
    }

    try {
      int flags = Video.SWSURFACE | Video.DOUBLEBUF;
      if (resizable) {
        flags = flags | Video.RESIZABLE;
      }
      Video.setMode(width, height, 32, flags);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 2
0
 /**
  * Renders (draws) the whole screen, and then flips the double buffer, so that the newly rendered
  * screen is visible.
  *
  * @priority 3
  */
 public static void render() {
   try {
     currentGame.render(Video.getDisplaySurface());
   } catch (Exception e) {
     handleException(e);
   }
   Video.flip();
 }
Esempio n. 3
0
  /**
   * This is called automatically when the game's ".itchy" file is being loaded (because it gets the
   * game's width and height from this file). As this is called automatically, you don't need to
   * worry about it.
   *
   * @param resources Uses the resource's GameInfo to set the screen size.
   * @throws Exception
   * @priority 5
   */
  public static void init(Resources resources) throws Exception {
    if (initialised) {
      return;
    }

    System.out.println("Itchy.init");

    Video.init();
    Audio.init();
    Audio.open();
    Events.enableKeyTranslation(true);

    keyboardState = new boolean[KEYBOARD_STATE_SIZE];
    mouseState = new boolean[MOUSE_STATE_SIZE];
    soundManager = new StandardSoundManager();
    setScreenMode(resources);
    initialised = true;
  }
Esempio n. 4
0
 /**
  * Gets the surface the game is being drawn to. This will not have an alpha channel.
  *
  * @return The display's surface.
  */
 public static Surface getDisplaySurface() {
   return Video.getDisplaySurface();
 }