Example #1
0
  public MafiaMainClass() {
    setLayout(card); // BorderLayout

    // add("WR",wr);
    add("LOG", login); // window창 위에 penal을 올린다
    setTitle("MAFIA GAME - LOGIN");
    setSize(1280, 985); // window 크기

    /*			// 창을 중앙에 띄운다.
    			Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
    			Dimension ex_size = this.getSize();

    			int xpos=(int)(screen.getWidth()/2 - this.getWidth()/2);
    			int ypos=(int)(screen.getHeight()/2 - this.getHeight()/2);

    			this.setLocation(xpos,ypos);
    */
    // 전체화면
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    setUndecorated(true);
    gd.setFullScreenWindow(this);

    setVisible(true); // window 보이기
    setResizable(false); // 화면크기 고정

    addMouseListener(this); // mouse움직임
  }
Example #2
0
  public GamePanel() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gs.getDefaultConfiguration();

    // Create an image that does not support transparency
    backBufferImage =
        gc.createCompatibleImage(
            TopDownShooter_Main.screenWidth, TopDownShooter_Main.screenHeight, Transparency.OPAQUE);
    backBuffer = backBufferImage.getGraphics();

    player = new Player(new Point(750, 750));

    map = Map.getInstance();
    map.loadWorld("World 1");
    viewScreen = ViewScreen.getInstance();
    collisionManager = CollisionManager.getInstance();

    SwingUtilities.invokeLater(
        new Runnable() { // The GUI needs to be added to the JPanel at a later time, since there is
                         // no way to know the size of this panel yet.
          public void run() {
            viewScreen.setSize(
                new Rectangle(
                    new Point(0, 0),
                    new Dimension(
                        GamePanel.this.getWidth(),
                        GamePanel.this
                            .getHeight()))); // Size the ViewScreen to the actual dimensions of the
                                             // viewable area now that we know them
            viewScreen.CenterOnObject(player.getBoundingBox());
          }
        });

    this.setFocusable(true);
    this.addKeyListener(player);

    new Timer(16, this).start(); // Master game timer
  }
  /**
   * Create an instance of the panel configured to show or hide the controls and only shows VRML97
   * content.
   *
   * @param showDash true to show the navigation bar
   * @param dashTop true to put the nav bar at the top
   * @param showUrl true to show the URL location bar
   * @param urlTop true to put the location bar at the top
   * @param urlReadOnly true to make the location bar read only
   * @param showConsole true if the console should be shown immediately
   * @param skinProperties The properties object to configure appearance with
   * @param showStatusBar true to show a status bar
   * @param showFPS true to show the current FPS
   * @param contentDirectory initial directory to load content from. Must be a full path.
   * @param antialiased true to turn on antialiasing
   * @param antialiasingQuality low, medium, high, antialiasing must be turned on for this to
   *     matter.
   * @param primitiveQuality low, medium, high.
   * @param textureQuality low, medium, high.
   * @param skinProperties Customisation of the browser buttons etc
   */
  public BrowserJPanel(
      boolean showDash,
      boolean dashTop,
      boolean showUrl,
      boolean urlTop,
      boolean urlReadOnly,
      boolean showConsole,
      boolean showOpenButton,
      boolean showReloadButton,
      boolean showStatusBar,
      boolean showFPS,
      String contentDirectory,
      boolean antialiased,
      String antialiasingQuality,
      String primitiveQuality,
      String textureQuality,
      Properties skinProperties) {

    super(new BorderLayout());

    setSize(800, 600);

    numSamples = 1;
    frameCycleTime = -1;
    wireframe = false;
    elumensMode = false;

    // JC: Copied from the OpenGL code, so does nothing right now.
    if (antialiased) {
      if (antialiasingQuality.equals("low")) {
        numSamples = 2;
        //                caps.setNumSamples(numSamples);
      } else if (antialiasingQuality.equals("medium")) {
        // TODO: Really need to find the max allowable.  But JOGL startup issues make this a problem
        System.out.println("Trying for 4 samples of antialiasing.");
        numSamples = 4;
        //                caps.setNumSamples(numSamples);
      } else if (antialiasingQuality.equals("high")) {
        System.out.println("Trying for 8 samples of antialiasing.");
        numSamples = 8;
        //                caps.setNumSamples(numSamples);
      }
    }

    console = new SwingConsoleWindow();
    console.messageReport("Initializing Java3D VRML browser.\n");

    addComponentListener(this);

    // We also need a canvas to display stuff with and a universe to set
    // the content in.
    GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
    template.setDoubleBuffer(GraphicsConfigTemplate3D.REQUIRED);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice dev = env.getDefaultScreenDevice();

    GraphicsConfiguration gfx_cfg = dev.getBestConfiguration(template);

    mainCanvas = new VRMLBrowserCanvas(gfx_cfg, true);
    mainCanvas.initialize();
    mainCanvas.setErrorReporter(console);

    j3dCanvas = mainCanvas;

    CursorManager cm = new CursorManager(mainCanvas, skinProperties, console);

    universe = mainCanvas.getUniverse();
    universe.addSensorStatusListener(cm);
    universe.addNavigationStateListener(cm);

    vpManager = mainCanvas.getViewpointManager();

    setupProperties(textureQuality);

    eaiBrowser = new EAIBrowser(universe, browserImpl, eventQueue, console);

    add(mainCanvas, BorderLayout.CENTER);

    // Create these all the time
    statusLabel = new JLabel();
    fpsLabel = new JLabel();
    SwingLocationToolbar tb = null;

    if (showUrl) {
      tb =
          new SwingLocationToolbar(
              universe,
              mainCanvas.getWorldLoaderManager(),
              urlReadOnly,
              showOpenButton,
              showReloadButton,
              contentDirectory,
              skinProperties,
              console);

      if (urlTop) add(tb, BorderLayout.NORTH);
      else add(tb, BorderLayout.SOUTH);
    }

    // Need to fix this as this panel will trash the existing one if they are
    // both at the top or bottom.

    if (showDash) {
      JPanel p2 = new JPanel(new BorderLayout());

      if (dashTop) add(p2, BorderLayout.NORTH);
      else add(p2, BorderLayout.SOUTH);

      navToolbar = new SwingNavigationToolbar(universe, skinProperties, console);
      // navToolbar.setAllowUserStateChange(true);
      SwingViewpointToolbar vp_tb =
          new SwingViewpointToolbar(universe, vpManager, skinProperties, console);

      SwingConsoleButton console_button = new SwingConsoleButton(console, skinProperties);

      p2.add(navToolbar, BorderLayout.WEST);
      p2.add(vp_tb, BorderLayout.CENTER);
      p2.add(console_button, BorderLayout.EAST);

      if (showFPS || showStatusBar) {
        statusBar = new SwingStatusBar(universe, showStatusBar, showFFS, skinProperties, console);

        if (tb != null) {
          tb.setProgressListener(statusBar.getProgressListener());
        }

        p2.add(statusBar, BorderLayout.SOUTH);
      }
    }

    if (showConsole) console.setVisible(true);
  }