Package marioRhythm

Source Code of marioRhythm.MarioRhythm

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package marioRhythm;

import factories.Dimensions;
import factories.Points;
import factories.Sizes;
import graphics.common.GraphicsDB;
import graphics.common.GraphicsObject;
import graphics.java.JavaSprite;
import java.awt.event.KeyEvent;
import java.util.LinkedList;
import java.util.List;
import javax.swing.SwingUtilities;
import utils.GlobalData;
import utils.InputManager;
import utils.Keyboard;
import utils.Mouse;
import utils.ThreadManager;
import utils.JavaWindow;

/**
*
* @author Freezerburn
*/
public class MarioRhythm{

    private JavaWindow theWindow;
    private InputManager input;
    private Mouse theMouse;
    private GraphicsDB gdb;
    private Points pf;
    private Sizes sf;

    private List< GraphicsObject > allGraphics;

    public static void main( String[] args ) {
        new MarioRhythm();
    }

    public MarioRhythm() {
        theGame();
    }

    public void theGame() {
        gameInit();

        long prevTime = System.nanoTime() / 1000000,
                curTime = System.nanoTime() / 1000000;
        long allTime = 0;
        long delta;
        while( true ) {
            input.update();
            if( input.isKeyDown( KeyEvent.VK_Q ) ) {
                break;
            }
            delta = curTime - prevTime;
            prevTime = curTime;
            curTime = System.nanoTime() / 1000000;
            allTime += delta;

            theWindow.clear();

            for( GraphicsObject go : allGraphics ) {
                go.draw( JavaWindow.getGraphics2D(), delta );
            }

            theWindow.update();
            //System.out.println( "Time running: " + allTime );
            if( ( (RhythmBall)allGraphics.get( 0 ) ).finished() )
                System.exit( 0 );

            try {
                Thread.sleep( 10 );
            }
            catch ( InterruptedException e ) {
                e.printStackTrace();
            }
        }

        theWindow.shutdown();
        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();

        GraphicsDB.cacheJavaImage( "images/marioRhythm/mariohitball.png",
                StringConsts.MARIO_NAME + StringConsts.RHYTHM_BALL_NAME );
        GraphicsDB.cacheJavaImage( "images/marioRhythm/luigihitball.png",
                StringConsts.LUIGI_NAME + StringConsts.RHYTHM_BALL_NAME);
        GraphicsDB.cacheJavaImage( "images/marioRhythm/target.png",
                StringConsts.TARGET_NAME );

        RhythmBall ball = RhythmBallFactory.get( RhythmBallTypes.MARIO );
        RhythmBallNew ballNew = new RhythmBallNew( StringConsts.MARIO_NAME + StringConsts.RHYTHM_BALL_NAME,
                                   5000,
                                   Points.get( 0, 200 ), Points.get( 100, 50 ),
                                   Points.get( 350, 150 ), Points.get( 300, 300 ) );
        ball.setStartLoc( 0, 200 );
        ball.addIntermediaryLoc( 100, 50 );
        ball.addIntermediaryLoc( 350, 150 );
        ball.setEndLoc( 300, 300 );
        //ball.start();
        ballNew.start();
        allGraphics.add( ball );
        allGraphics.add( ballNew );
    }
}
TOP

Related Classes of marioRhythm.MarioRhythm

TOP
Copyright © 2018 www.massapi.com. 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.