Android Open Source - AllBinary-Platform-Game Test Game Demo M I Dlet






From Project

Back to project page AllBinary-Platform-Game.

License

The source code is released under:

AllBinary Open License Version 1.0 Copyright (c) 2011 AllBinary. By agreeing to this license you and any business entity you represent are legally bound to this legal agreement. You may transmit, m...

If you think the Android project AllBinary-Platform-Game listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

import org.allbinary.logic.basic.string.CommonStrings;
import org.allbinary.logic.communication.log.LogFactory;
import org.allbinary.logic.communication.log.LogUtil;
import org.allbinary.data.resource.ResourceUtil;
import org.allbinary.game.configuration.GameConfigurationCentral;
import org.allbinary.game.configuration.feature.Features;
import org.allbinary.game.configuration.feature.GameFeatureFactory;
import org.allbinary.game.configuration.feature.GraphicsFeatureFactory;
import org.allbinary.game.configuration.feature.InputFeatureFactory;
import org.allbinary.game.configuration.feature.SensorFeatureFactory;
import org.allbinary.input.motion.AllMotionRecognizer;
import org.allbinary.input.motion.gesture.observer.BasicMotionGesturesHandler;
import org.allbinary.input.motion.gesture.observer.GameMotionGestureListener;
import org.allbinary.input.motion.gesture.observer.MotionGestureReceiveInterfaceFactory;
import org.allbinary.logic.math.SmallIntegerSingletonFactory;
import org.allbinary.media.audio.EarlySoundsFactoryFactory;
import org.allbinary.media.audio.Sounds;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import org.allbinary.game.init.DefaultGameInitializationListener;
import org.allbinary.media.audio.TestGameDemoSoundsFactory;
/*from   ww  w  .  j av a2s .c  o m*/
public class TestGameDemoMIDlet
        extends org.allbinary.game.testgamedemo.TestGameDemoMIDlet
{
    private final int DEVICE_ID = 0;
    private AllMotionRecognizer motionRecognizer = new AllMotionRecognizer();

    public TestGameDemoMIDlet()
    {
        BasicMotionGesturesHandler motionGesturesHandler =
            motionRecognizer.getMotionGestureRecognizer().getMotionGesturesHandler();

        motionGesturesHandler.addListener(
            new GameMotionGestureListener(
            MotionGestureReceiveInterfaceFactory.getInstance()));    

        new DefaultGameInitializationListener();
    }

    protected void init()
    {
        try
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, CommonStrings.getInstance().INIT));

            ResourceUtil.setClassLoader(this.getClass().getClassLoader());

            Features features = Features.getInstance();

            GameFeatureFactory gameFeatureFactory =
                GameFeatureFactory.getInstance();

            InputFeatureFactory inputFeatureFactory =
                InputFeatureFactory.getInstance();

            GraphicsFeatureFactory graphicsFeatureFactory =
                GraphicsFeatureFactory.getInstance();

            SensorFeatureFactory sensorFeatureFactory =
                    SensorFeatureFactory.getInstance();

            features.removeDefault(sensorFeatureFactory.ORIENTATION_SENSORS);
            features.addDefault(sensorFeatureFactory.NO_ORIENTATION);

            features.addDefault(graphicsFeatureFactory.IMAGE_GRAPHICS);
            //features.addDefault(gameFeatureFactory.VECTOR_GRAPHICS);

            features.addDefault(graphicsFeatureFactory.SPRITE_FULL_GRAPHICS);
            //features.addDefault(gameFeatureFactory.SPRITE_QUARTER_ROTATION_GRAPHICS);

            features.addDefault(gameFeatureFactory.HEALTH_BARS);
            features.addDefault(gameFeatureFactory.DAMAGE_FLOATERS);

            features.addDefault(gameFeatureFactory.DROPPED_ITEMS);

            features.addDefault(gameFeatureFactory.SOUND);

            features.addDefault(inputFeatureFactory.MULTI_KEY_PRESS);
            //gameFeatureFactory.removeDefault(inputFeatureFactory.MULTI_KEY_PRESS);
            //features.addDefault(inputFeatureFactory.SINGLE_KEY_PRESS);
            features.addDefault(inputFeatureFactory.REMOVE_DUPLICATE_KEY_PRESSES);

            GameConfigurationCentral gameConfigurationCentral =
                    GameConfigurationCentral.getInstance();

            SmallIntegerSingletonFactory smallIntegerSingletonFactory = 
                    SmallIntegerSingletonFactory.getInstance();

            gameConfigurationCentral.VIBRATION.setDefaultValue(smallIntegerSingletonFactory.getInstance(0));
            gameConfigurationCentral.VIBRATION.setDefault();

            gameConfigurationCentral.SPEED_CHALLENGE_LEVEL.setDefaultValue(smallIntegerSingletonFactory.getInstance(4));
            gameConfigurationCentral.SPEED_CHALLENGE_LEVEL.setDefault();

            gameConfigurationCentral.SPEED.setDefaultValue(smallIntegerSingletonFactory.getInstance(9));
            gameConfigurationCentral.SPEED.setDefault();

            gameConfigurationCentral.PLAYER_INPUT_WAIT.setDefaultValue(smallIntegerSingletonFactory.getInstance(0));
            gameConfigurationCentral.PLAYER_INPUT_WAIT.setDefault();

            gameConfigurationCentral.SCALE.setDefaultValue(smallIntegerSingletonFactory.getInstance(3));
            gameConfigurationCentral.SCALE.setDefault();

        } catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, CommonStrings.getInstance().CONSTRUCTOR, e));
        }
    }
    
    public void stopAll()
    {
        try
        {
            new Sounds(EarlySoundsFactoryFactory.getInstance()).stopAll();
            new Sounds(new TestGameDemoSoundsFactory()).stopAll();
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "stopAll", e));
        }
    }
    
    public void mouseClicked(MouseEvent mouseEvent)
    {
        /*
        try
        {
        //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseClicked"));
        motionGestureRecognizer.processPressedMotionEvent(
        PointFactory.getInstance(mouseEvent.getX(), mouseEvent.getY()),
        mouseEvent.getButton());
        }
        catch (Exception e)
        {
        LogUtil.put(LogFactory.getInstance("Exception", this, "mouseClicked", e));
        }
         */
    }

    public void mousePressed(MouseEvent mouseEvent)
    {
        try
        {
            //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mousePressed"));
            this.motionRecognizer.processStartMotionEvent(
                mouseEvent.getX(), mouseEvent.getY(),
                DEVICE_ID,
                mouseEvent.getButton());
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "mousePressed", e));
        }
    }

    public void mouseReleased(MouseEvent mouseEvent)
    {
        try
        {
            //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseReleased"));
            this.motionRecognizer.processEndMotionEvent(
                mouseEvent.getX(), mouseEvent.getY(),
                    DEVICE_ID,
                mouseEvent.getButton());
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "mouseReleased", e));
        }
    }

    public void mouseEntered(MouseEvent mouseEvent)
    {
        //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseEntered"));
    }

    public void mouseExited(MouseEvent mouseEvent)
    {
        //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseExited"));
    }

    public void mouseMoved(MouseEvent mouseEvent)
    {
        //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseMoved"));
    }

    public void mouseDragged(MouseEvent mouseEvent)
    {
        try
        {
            //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseDragged"));
            this.motionRecognizer.processDraggedMotionEvent(
                mouseEvent.getX(), mouseEvent.getY(),
                    DEVICE_ID,
                mouseEvent.getButton());
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "mouseDragged", e));
        }
    }

    public void mouseWheelMoved(MouseWheelEvent mouseEvent)
    {
        //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseWheelMoved"));
    }

    /*
    private MouseAdapter mouseListener = new MouseAdapter()
    {

    public void mouseClicked(MouseEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseClicked"));
    }

    public void mousePressed(MouseEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mousePressed"));
    }
    };
    private MouseMotionListener mouseMotionListener = new MouseMotionListener()
    {

    public void mouseReleased(MouseEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseReleased"));
    }

    public void mouseEntered(MouseEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseEntered"));
    }

    public void mouseExited(MouseEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseExited"));
    }

    public void mouseMoved(MouseEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseMoved"));
    }

    public void mouseDragged(MouseEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseDragged"));
    }
    };
    private MouseWheelListener mouseWheelListener = new MouseWheelListener()
    {

    public void mouseWheelMoved(MouseWheelEvent mouseEvent)
    {
    LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "mouseWheelMoved"));
    }
    };
     */
    
}




Java Source Code List

.TestGameDemoMIDlet.java
.TestGameDemoMIDlet.java
.TestGameDemoMIDlet.java
.TestGameDemoMIDlet.java
.TestGameDemoMIDlet.java
org.allbinary.AndroidResources.java
org.allbinary.AndroidResources.java
org.allbinary.AndroidResources.java
org.allbinary.animation.image.TestGameDemoEarlyResourcesImageBasedAnimationInterfaceFactoryInterfaceFactory.java
org.allbinary.animation.image.TestGameDemoEarlyResourcesOpenGLESImageBasedAnimationInterfaceFactoryInterfaceFactory.java
org.allbinary.animation.image.TestGameDemoGameResourcesImageBasedAnimationInterfaceFactoryInterfaceFactory.java
org.allbinary.animation.image.TestGameDemoImageBasedAnimationInterfaceFactoryInterfaceFactory.java
org.allbinary.animation.image.TestGameDemoOpenGLESImageBasedAnimationInterfaceFactoryInterfaceFactory.java
org.allbinary.game.testgamedemo.TestDemoGameAndroidActivity.java
org.allbinary.game.testgamedemo.TestDemoGameMIDletFactory.java
org.allbinary.game.testgamedemo.TestGameDemoAndroidActivity.java
org.allbinary.game.testgamedemo.TestGameDemoAndroidOpenGLESView.java
org.allbinary.game.testgamedemo.TestGameDemoAndroidView.java
org.allbinary.game.testgamedemo.TestGameDemoMIDletFactory.java
org.allbinary.game.testgamedemo.TestGameDemoMIDlet.java
org.allbinary.game.testgamedemo.canvas.TestDemoPaintable.java
org.allbinary.game.testgamedemo.canvas.TestGameDemoGameCanvas.java
org.allbinary.game.testgamedemo.canvas.TestGameDemoHelpPaintable.java
org.allbinary.game.testgamedemo.canvas.TestGameDemoInputMappingHelpPaintable.java
org.allbinary.game.testgamedemo.canvas.TestGameDemoSoftwareInfo.java
org.allbinary.game.testgamedemo.canvas.TestGameDemoStartCanvas.java
org.allbinary.game.testgamedemo.canvas.TitleAnimationFactory.java
org.allbinary.game.testgamedemo.canvas.TitleVectorData.java
org.allbinary.game.testgamedemo.configuration.TestGameDemoGameFeatures.java
org.allbinary.game.testgamedemo.configuration.TestGameDemoGameFeatures.java
org.allbinary.game.testgamedemo.configuration.TestGameDemoGameFeatures.java
org.allbinary.game.testgamedemo.configuration.TestGameDemoGameFeatures.java
org.allbinary.game.testgamedemo.init.J2METestGameDemoStaticInitializer.java
org.allbinary.game.testgamedemo.init.J2METestGameDemoStaticInitializer.java
org.allbinary.game.testgamedemo.init.J2METestGameDemoStaticInitializer.java
org.allbinary.game.testgamedemo.init.TestGameDemoAndroidAnimationInterfaceFactoryEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoAndroidAnimationInterfaceFactoryResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoAndroidStaticInitializer.java
org.allbinary.game.testgamedemo.init.TestGameDemoJ2MEAnimationInterfaceFactoryEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoJ2MEAnimationInterfaceFactoryEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoJ2MEAnimationInterfaceFactoryEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoJ2MEAnimationInterfaceFactoryResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoJ2MEAnimationInterfaceFactoryResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoJ2MEAnimationInterfaceFactoryResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoResourceInitialization.java
org.allbinary.game.testgamedemo.init.TestGameDemoStaticInitializerFactory.java
org.allbinary.game.testgamedemo.init.TestGameDemoStaticInitializerFactory.java
org.allbinary.game.testgamedemo.init.TestGameDemoStaticInitializerFactory.java
org.allbinary.game.testgamedemo.init.TestGameDemoStaticInitializerFactory.java
org.allbinary.game.testgamedemo.init.TestGameDemoStaticInitializer.java
org.allbinary.game.testgamedemo.input.TestGameDemoGameInputMappingFactory.java
org.allbinary.game.testgamedemo.layer.TestGameDemoLayerManager.java
org.allbinary.game.testgamedemo.level.TestGameDemoLevelBuilder.java
org.allbinary.game.testgamedemo.resource.TestGameDemoAndroidEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.resource.TestGameDemoAndroidResourceInitialization.java
org.allbinary.game.testgamedemo.resource.TestGameDemoJ2MEEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.resource.TestGameDemoJ2MEEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.resource.TestGameDemoJ2MEEarlyResourceInitialization.java
org.allbinary.game.testgamedemo.resource.TestGameDemoJ2MEResourceInitialization.java
org.allbinary.game.testgamedemo.resource.TestGameDemoJ2MEResourceInitialization.java
org.allbinary.game.testgamedemo.resource.TestGameDemoJ2MEResourceInitialization.java
org.allbinary.input.motion.button.TestGameDemoMultiTouchButtonsBuilder.java
org.allbinary.input.motion.button.TestGameDemoNeededMultiTouchButtonsBuilder.java
org.allbinary.input.motion.button.TestGameDemoNeededTouchButtonsBuilder.java
org.allbinary.input.motion.button.TestGameDemoNeededTouchButtonsBuilder.java
org.allbinary.input.motion.button.TestGameDemoNeededWithSensorTouchButtonsBuilder.java
org.allbinary.input.motion.button.TestGameDemoTouchButtonsBuilder.java
org.allbinary.input.motion.button.TestGameDemoTouchButtonsBuilder.java
org.allbinary.input.motion.button.TestGameDemoWithSensorTouchButtonsBuilder.java
org.allbinary.input.motion.button.TouchButtonAllStopResource.java
org.allbinary.logic.system.security.licensing.AbeClientInformationInterfaceFactory.java
org.allbinary.logic.system.security.licensing.AbeClientInformationInterfaceFactory.java
org.allbinary.logic.system.security.licensing.TestGameDemoAndroidMobileClientInformation.java
org.allbinary.logic.system.security.licensing.TestGameDemoPCClientInformation.java
org.allbinary.media.audio.TestGameDemoSoundsFactoryFactory.java
org.allbinary.media.audio.TestGameDemoSoundsFactoryFactory.java
org.allbinary.media.audio.TestGameDemoSoundsFactoryFactory.java
org.allbinary.media.audio.TestGameDemoSoundsFactoryFactory.java
org.allbinary.media.audio.TestGameDemoSoundsFactory.java
org.allbinary.media.audio.TestSound.java
playn.core.TestGameDemoMidletFactory.java
playn.core.TestGameDemoProcessor.java
playn.core.TestGameDemo.java
playn.html.TestGameDemoGameHtml.java
playn.java.TestGameDemoJ2SE.java
playn.shared.Protocol.java