Package utils

Examples of utils.JavaWindow


        ThreadManager.shutdown();
    }

    private static void init() {
        GlobalData.GRAPHICS_DIMENSIONS = Dimensions.TWO_DIMENSION;
        theWindow = new JavaWindow( "Tree test", WINDOW_WIDTH, WINDOW_HEIGHT );
        theWindow.addKeyListener( ( input = InputManager.getInstance() ) );
        //mouseInput = new Mouse();
        theWindow.addMouseListener( ( mouseInput = new Mouse() ) );
        theWindow.addMouseMotionListener( mouseInput );
        //theWindow.addMouseListener( new MockMouse() );
View Full Code Here


   * grounds for new features of the engine, such as image loading/drawing.
   *
   * @param args
   */
  public static void main( String[] args ) {
    JavaWindow window = new JavaWindow( "Research project mock", 640, 480 );
    window.setClearColor( new Color( 210, 210, 210 ) );
    Keyboard kb = new Keyboard();
    Mouse mouse = new Mouse();
    window.addKeyListener( kb );
   
    new GraphicsDB();
    GraphicsDB.cacheJavaImage( "images/Fence_endright.png", "fenceright" );
    try {
      Thread.sleep( 200 );
    } catch ( InterruptedException e1 ) {
      e1.printStackTrace();
    }
   
    Random rand = new Random( System.nanoTime() );
    final int listSize = 400;
    GraphicsObject[] objList = new GraphicsObject[ listSize ];
    List< GraphicsObject > objList2 = new LinkedList< GraphicsObject >();
    for( int i = 0; i < listSize; i++ ) {
      Point2D tempPoint = new Point2D( rand.nextInt( window.getWidth() - 30 ) + 30, rand.nextInt( window.getHeight() - 30 ) + 30 );
      Size2D tempSize = new Size2D( rand.nextInt( 30 ) + 21, rand.nextInt( 30 ) + 21 );
      GraphicsObject obj = new JavaSprite( "fenceright",
          tempPoint, tempSize );
      objList[ i ] = obj;
      objList2.add( obj );
    }
    GraphicsObject obj = new JavaSprite( "fenceright",
        new Point2D( 15, 31 ), new Size2D( 80, 80 ) );
   
    GraphicsObject elp1 = new Oval( new Point2D( 50, 50 ), new Size2D( 30, 16 ) );
    ((Oval)elp1).setColor( new Color( 255, 0, 0 ) );
    GraphicsObject elp2 = new Oval( new Point2D( 300, 300 ), new Size2D( 30, 16 ),
                      new Color( 255, 0, 0 ) );
    GraphicsObject cur = new BezierCurve( new Point2D( 65, 58 ), new Point2D( 315, 108 ),
                  new Point2D( 315, 208 ), new Point2D( 315, 308 ),
                  new Color( 255, 255, 0 ), 100 );
   
    Network network = new Network();
    Network.Node n1 = network.new Node( new Oval( new Point2D( 100, 100 ), new Size2D( 30, 15 ) ) );
    Network.Node n2 = network.new Node( new Oval( new Point2D( 200, 450 ), new Size2D( 30, 15 ) ) );
    Network.Node n3 = network.new Node( new Oval( new Point2D( 30, 200 ), new Size2D( 30, 15 ) ) );
    Network.Node n4 = network.new Node( new Oval( new Point2D( 500, 40 ), new Size2D( 30, 15 ) ) );
    network.addNode( n1 );
    network.addNode( n2 );
    network.addNode( n3 );
    network.addNode( n4 );
    network.addEdge( n1, n2 );
    network.addEdge( n1, n4 );
    //network.addEdge( n2, n3 );
    //network.addEdge( n4, n3 );
   
    Timer timer = new Timer();
    int frames = 0, prevFrames = 0;
    int timePassed = 0;
    timer.start();
    while( true ) {
      kb.poll();
      if( kb.keyDown( KeyEvent.VK_Q ) ) {
        break;
      }
      if( kb.keyDown( KeyEvent.VK_A ) ) {
        Point2D tempPoint = new Point2D( rand.nextInt( window.getWidth() ), rand.nextInt( window.getHeight() ) );
        Size2D tempSize = new Size2D( rand.nextInt( 30 ) + 21, rand.nextInt( 30 ) + 21 );
        GraphicsObject obj2 = new JavaSprite( "fenceright",
            tempPoint, tempSize );
        objList2.add( obj2 );
      }
      window.clear();
     
      for( GraphicsObject go : objList2 ) {
        go.draw( JavaWindow.getGraphics2D(), 0 );
      }
      //obj.draw( Window.getGraphics2D() );
      //cur.draw( window.getDrawGraphics() );
      //elp1.draw( window.getDrawGraphics() );
      //elp2.draw( window.getDrawGraphics() );
      //network.draw( Window.getGraphics2D() );
     
      JavaWindow.getGraphics2D().setColor( Color.black );
      JavaWindow.getGraphics2D().drawString( String.valueOf( objList2.size() ), 0, 10 );
      JavaWindow.getGraphics2D().drawString( String.valueOf( prevFrames ), 0, 20 );
      window.update();
     
      frames++;
      timePassed += (int)timer.get();
      //System.out.println( timePassed );
      if( timePassed >= 1000 ) {
        prevFrames = frames;
        frames = 0;
        timePassed = 0;
      }
      try {
        Thread.sleep( 10 );
      } catch ( InterruptedException e ) {
        e.printStackTrace();
      }
    }
   
    window.shutdown();
    ThreadManager.shutdown();
  }
View Full Code Here

        ThreadManager.shutdown();
    }

    private void gameInit() {
        GlobalData.GRAPHICS_DIMENSIONS = Dimensions.TWO_DIMENSION;
        theWindow = new JavaWindow( "Mario Rhythm Test", 400, 400 );
        theWindow.addKeyListener( ( input = InputManager.getInstance() ) );
        allGraphics = new LinkedList< GraphicsObject >();
        pf = new Points();
        sf = new Sizes();
        gdb = new GraphicsDB();
View Full Code Here

TOP

Related Classes of utils.JavaWindow

Copyright © 2018 www.massapicom. 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.