Android Open Source - AllBinary-Platform-Game Test Game Demo






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

package playn.core;
// w  w w.  java 2s .c  om
import org.allbinary.logic.basic.string.CommonStrings;
import org.allbinary.logic.communication.log.LogFactory;
import org.allbinary.logic.communication.log.LogUtil;
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.HTMLFeatureFactory;
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 org.allbinary.game.init.DefaultGameInitializationListener;
import org.allbinary.media.audio.TestGameDemoSoundsFactoryFactory;

public class TestGameDemo
    extends org.allbinary.game.testgamedemo.TestGameDemoMIDlet
implements Keyboard.Listener, 
//Mouse.Listener, 
Pointer.Listener
{
    private final int DEVICE_ID = 0;
    private AllMotionRecognizer motionRecognizer = new AllMotionRecognizer();

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

        motionGesturesHandler.addListener(
            new GameMotionGestureListener(
            MotionGestureReceiveInterfaceFactory.getInstance()));
        
        PlayN.keyboard().setListener(this);
        //PlayN.mouse().setListener(this);
        PlayN.pointer().setListener(this);
        
        new DefaultGameInitializationListener();        
    }

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

            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();

            features.removeDefault(sensorFeatureFactory.ORIENTATION_SENSORS);
            features.addDefault(sensorFeatureFactory.NO_ORIENTATION);
            features.addDefault(HTMLFeatureFactory.getInstance().HTML);
        }
        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(TestGameDemoSoundsFactoryFactory.getInstance()).stopAll();
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "stopAll", e));
        }
    }
    
    public void onKeyDown(Keyboard.Event event)
    {
        LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "onKeyDown"));
        
        this.getCurrentDisplayable().keyPressed(event.keyCode());
    }

    public void onKeyUp(Keyboard.Event event)
    {
        LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "onKeyUp"));
        
        this.getCurrentDisplayable().keyReleased(event.keyCode());
    }

    public void onPointerStart(Pointer.Event mouseEvent)
    {
        try
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "onPointerStart"));
            this.motionRecognizer.processStartMotionEvent(
                (int) mouseEvent.x(), (int) mouseEvent.y(), this.DEVICE_ID, 
                0);
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "onPointerStart", e));
        }
    }

    public void onPointerEnd(Pointer.Event mouseEvent)
    {
        try
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "onPointerEnd"));
            this.motionRecognizer.processEndMotionEvent(
                (int) mouseEvent.x(), (int) mouseEvent.y(), this.DEVICE_ID, 
                0);
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "onPointerEnd", e));
        }
    }

    public void onPointerDrag(Pointer.Event mouseEvent)
    {
        try
        {
            //LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "onPointerDrag"));
            this.motionRecognizer.processDraggedMotionEvent(
                (int) mouseEvent.x(), (int) mouseEvent.y(), this.DEVICE_ID, 
                0);
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "onPointerDrag", e));
        }
    }

    /*
    public void onMouseDown(Mouse.ButtonEvent mouseEvent)
    {
        try
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "onMouseDown"));
            this.motionRecognizer.processStartMotionEvent(
                (int) mouseEvent.x(), (int) mouseEvent.y(),
                mouseEvent.button());
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "onMouseDown", e));
        }
    }

    public void onMouseUp(Mouse.ButtonEvent mouseEvent)
    {
        try
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().START, this, "onMouseUp"));
            this.motionRecognizer.processEndMotionEvent(
                (int) mouseEvent.x(), (int) mouseEvent.y(),
                mouseEvent.button());
        }
        catch (Exception e)
        {
            LogUtil.put(LogFactory.getInstance(CommonStrings.getInstance().EXCEPTION, this, "onMouseUp", e));
        }
    }

    public void onMouseMove(Mouse.MotionEvent event)
    {
        
    }

    public void onMouseWheelScroll(Mouse.WheelEvent event)
    {
        
    }
    * 
    */
}




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