Assorted fixes for OUYA.

This commit is contained in:
2014-06-26 18:25:28 -04:30
parent a9285a684f
commit 53ae001e59
10 changed files with 159 additions and 105 deletions

View File

@@ -32,7 +32,6 @@ import com.artemis.EntitySystem;
import com.artemis.World; import com.artemis.World;
import com.artemis.managers.GroupManager; import com.artemis.managers.GroupManager;
import com.artemis.utils.ImmutableBag; import com.artemis.utils.ImmutableBag;
import com.badlogic.gdx.controllers.mappings.Ouya;
import com.badlogic.gdx.graphics.g3d.ModelBatch; import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.Disposable;
@@ -148,7 +147,7 @@ public abstract class ScenarioGlobals{
playerSystem.setCore(core); playerSystem.setCore(core);
gameWorld.setSystem(new MarkerPositioningSystem()); gameWorld.setSystem(new MarkerPositioningSystem());
gameWorld.setSystem(new RobotArmPositioningSystem(), Ouya.runningOnOuya); gameWorld.setSystem(new RobotArmPositioningSystem());
gameWorld.setSystem(new GeometrySystem()); gameWorld.setSystem(new GeometrySystem());
gameWorld.setSystem(new AnimationSystem()); gameWorld.setSystem(new AnimationSystem());
gameWorld.setSystem(new CollisionDetectionSystem()); gameWorld.setSystem(new CollisionDetectionSystem());

View File

@@ -22,6 +22,7 @@ import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
import ve.ucv.ciens.ccg.nxtar.utils.Utils; import ve.ucv.ciens.ccg.nxtar.utils.Utils;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.controllers.mappings.Ouya;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
@@ -72,7 +73,10 @@ public class BombGameAutomaticActionSummaryOverlay extends SummaryOverlayBase{
fontParameters = new FreeTypeFontParameter(); fontParameters = new FreeTypeFontParameter();
fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.characters = ProjectConstants.FONT_CHARS;
fontParameters.size = (int)((float)ProjectConstants.MENU_BUTTON_FONT_SIZE * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH)); if(!Ouya.runningOnOuya)
fontParameters.size = (int)((float)ProjectConstants.MENU_BUTTON_FONT_SIZE * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH));
else
fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
fontParameters.flip = false; fontParameters.flip = false;
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
@@ -122,6 +126,9 @@ public class BombGameAutomaticActionSummaryOverlay extends SummaryOverlayBase{
font.draw(batch, String.format("Combination bombs: %d", bombGameSummary.getNumCombinationBombs()), combinationX, combinationY); font.draw(batch, String.format("Combination bombs: %d", bombGameSummary.getNumCombinationBombs()), combinationX, combinationY);
font.draw(batch, String.format("Wire bombs: %d", bombGameSummary.getNumWireBombs()), wireX, wireY); font.draw(batch, String.format("Wire bombs: %d", bombGameSummary.getNumWireBombs()), wireX, wireY);
titleFont.draw(batch, "Summary", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleHeight - 10); if(!Ouya.runningOnOuya)
titleFont.draw(batch, "Summary", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleHeight - 10);
else
titleFont.draw(batch, "Summary", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - 10);
} }
} }

View File

@@ -20,6 +20,7 @@ import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
import ve.ucv.ciens.ccg.nxtar.utils.Utils; import ve.ucv.ciens.ccg.nxtar.utils.Utils;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.controllers.mappings.Ouya;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
@@ -70,7 +71,10 @@ public class BombGameInstructionsOverlay extends HintsOverlayBase {
fontParameters = new FreeTypeFontParameter(); fontParameters = new FreeTypeFontParameter();
fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.characters = ProjectConstants.FONT_CHARS;
fontParameters.size = (int)((float)ProjectConstants.MENU_BUTTON_FONT_SIZE * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH)); if(!Ouya.runningOnOuya)
fontParameters.size = (int)((float)ProjectConstants.MENU_BUTTON_FONT_SIZE * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH));
else
fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
fontParameters.flip = false; fontParameters.flip = false;
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
@@ -115,6 +119,9 @@ public class BombGameInstructionsOverlay extends HintsOverlayBase {
font.draw(batch, "Blue, red, gray and green", combinationX, combinationY); font.draw(batch, "Blue, red, gray and green", combinationX, combinationY);
font.draw(batch, "Cut the blue wire.", wireX, wireY); font.draw(batch, "Cut the blue wire.", wireX, wireY);
titleFont.draw(batch, "Instructions", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleHeight - 10); if(!Ouya.runningOnOuya)
titleFont.draw(batch, "Instructions", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleHeight - 10);
else
titleFont.draw(batch, "Instructions", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - 10);
} }
} }

View File

@@ -22,6 +22,7 @@ import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
import ve.ucv.ciens.ccg.nxtar.utils.Utils; import ve.ucv.ciens.ccg.nxtar.utils.Utils;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.controllers.mappings.Ouya;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds; import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
@@ -44,7 +45,10 @@ public class BombGameScenarioEndingOverlay extends SummaryOverlayBase {
fontParameters = new FreeTypeFontParameter(); fontParameters = new FreeTypeFontParameter();
fontParameters.characters = ProjectConstants.FONT_CHARS; fontParameters.characters = ProjectConstants.FONT_CHARS;
fontParameters.size = (int)(65.0f * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH)); if(!Ouya.runningOnOuya)
fontParameters.size = (int)(65.0f * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH));
else
fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
fontParameters.flip = false; fontParameters.flip = false;
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
@@ -96,6 +100,10 @@ public class BombGameScenarioEndingOverlay extends SummaryOverlayBase {
else else
title = "Game Over"; title = "Game Over";
titleBounds = titleFont.getBounds(title); titleBounds = titleFont.getBounds(title);
titleFont.draw(batch, title, -(titleBounds.width / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleBounds.height - 10);
if(!Ouya.runningOnOuya)
titleFont.draw(batch, title, -(titleBounds.width / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleBounds.height - 10);
else
titleFont.draw(batch, title, -(titleBounds.width / 2), (Utils.getScreenHeightWithOverscan() / 2) - 10);
} }
} }

View File

@@ -136,6 +136,7 @@ public class AutomaticActionSummaryState extends BaseState{
ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png"); ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png");
ouyaOButton = new Sprite(ouyaOButtonTexture); ouyaOButton = new Sprite(ouyaOButtonTexture);
ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f); ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f);
ouyaOButton.setPosition(continueButton.getX() - ouyaOButton.getWidth() - 20, continueButton.getY() + (ouyaOButton.getHeight() / 2));
oButtonPressed = false; oButtonPressed = false;
}else{ }else{
ouyaOButtonTexture = null; ouyaOButtonTexture = null;

View File

@@ -57,6 +57,7 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.GdxRuntimeException;
public class InGameState extends BaseState{ public class InGameState extends BaseState{
private static final String TAG = "IN_GAME_STATE"; private static final String TAG = "IN_GAME_STATE";
@@ -309,104 +310,108 @@ public class InGameState extends BaseState{
// If a valid frame was fetched. // If a valid frame was fetched.
if(data != null && data.outFrame != null){ if(data != null && data.outFrame != null){
// Set the camera to the correct projection. try{
focalPointX = core.cvProc.getFocalPointX(); // Set the camera to the correct projection.
focalPointY = core.cvProc.getFocalPointY(); focalPointX = core.cvProc.getFocalPointX();
cameraCenterX = core.cvProc.getCameraCenterX(); focalPointY = core.cvProc.getFocalPointY();
cameraCenterY = core.cvProc.getCameraCenterY(); cameraCenterX = core.cvProc.getCameraCenterX();
perspectiveCamera.setCustomARProjectionMatrix(focalPointX, focalPointY, cameraCenterX, cameraCenterY, NEAR, FAR, w, h); cameraCenterY = core.cvProc.getCameraCenterY();
perspectiveCamera.update(perspectiveCamera.projection); perspectiveCamera.setCustomARProjectionMatrix(focalPointX, focalPointY, cameraCenterX, cameraCenterY, NEAR, FAR, w, h);
perspectiveCamera.update(perspectiveCamera.projection);
// Update the game state. // Update the game state.
if(controlMode == robot_control_mode_t.ARM_CONTROL) if(controlMode == robot_control_mode_t.ARM_CONTROL || Ouya.runningOnOuya)
gameWorld.getSystem(CollisionDetectionSystem.class).enableCollisions(); gameWorld.getSystem(CollisionDetectionSystem.class).enableCollisions();
else else
gameWorld.getSystem(CollisionDetectionSystem.class).disableCollisions(); gameWorld.getSystem(CollisionDetectionSystem.class).disableCollisions();
gameWorld.setDelta(Gdx.graphics.getDeltaTime() * 1000); gameWorld.setDelta(Gdx.graphics.getDeltaTime() * 1000);
gameWorld.getSystem(MarkerPositioningSystem.class).setMarkerData(data); gameWorld.getSystem(MarkerPositioningSystem.class).setMarkerData(data);
gameWorld.process(); gameWorld.process();
// Decode the video frame. // Decode the video frame.
videoFrame = new Pixmap(data.outFrame, 0, w * h); videoFrame = new Pixmap(data.outFrame, 0, w * h);
videoFrameTexture = new Texture(videoFrame); videoFrameTexture = new Texture(videoFrame);
videoFrameTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); videoFrameTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
videoFrame.dispose(); videoFrame.dispose();
// Convert the decoded frame into a renderable texture. // Convert the decoded frame into a renderable texture.
region = new TextureRegion(videoFrameTexture, 0, 0, w, h); region = new TextureRegion(videoFrameTexture, 0, 0, w, h);
if(renderableVideoFrame == null) if(renderableVideoFrame == null)
renderableVideoFrame = new Sprite(region); renderableVideoFrame = new Sprite(region);
else else
renderableVideoFrame.setRegion(region); renderableVideoFrame.setRegion(region);
renderableVideoFrame.setOrigin(renderableVideoFrame.getWidth() / 2, renderableVideoFrame.getHeight() / 2); renderableVideoFrame.setOrigin(renderableVideoFrame.getWidth() / 2, renderableVideoFrame.getHeight() / 2);
renderableVideoFrame.setPosition(0, 0); renderableVideoFrame.setPosition(0, 0);
// Set the 3D frame buffer for rendering. // Set the 3D frame buffer for rendering.
frameBuffer.begin();{ frameBuffer.begin();{
// Set OpenGL state. // Set OpenGL state.
Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
Gdx.gl.glDisable(GL20.GL_TEXTURE_2D); Gdx.gl.glDisable(GL20.GL_TEXTURE_2D);
// Call rendering systems. // Call rendering systems.
markerRenderingSystem.begin(perspectiveCamera); markerRenderingSystem.begin(perspectiveCamera);
markerRenderingSystem.process(); markerRenderingSystem.process();
markerRenderingSystem.end(); markerRenderingSystem.end();
if(controlMode.getValue() == robot_control_mode_t.ARM_CONTROL.getValue() || Ouya.runningOnOuya){ if(controlMode.getValue() == robot_control_mode_t.ARM_CONTROL.getValue() || Ouya.runningOnOuya){
objectRenderingSystem.begin(perspectiveCamera); objectRenderingSystem.begin(perspectiveCamera);
objectRenderingSystem.process(); objectRenderingSystem.process();
objectRenderingSystem.end(); objectRenderingSystem.end();
}
}frameBuffer.end();
// Set the frame buffer object texture to a renderable sprite.
region = new TextureRegion(frameBuffer.getColorBufferTexture(), 0, 0, frameBuffer.getWidth(), frameBuffer.getHeight());
region.flip(false, true);
if(frameBufferSprite == null)
frameBufferSprite = new Sprite(region);
else
frameBufferSprite.setRegion(region);
frameBufferSprite.setOrigin(frameBufferSprite.getWidth() / 2, frameBufferSprite.getHeight() / 2);
frameBufferSprite.setPosition(0, 0);
// Set the position and orientation of the renderable video frame and the frame buffer.
if(!Ouya.runningOnOuya){
renderableVideoFrame.setSize(1.0f, renderableVideoFrame.getHeight() / renderableVideoFrame.getWidth() );
renderableVideoFrame.rotate90(true);
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, 0.5f - renderableVideoFrame.getHeight());
frameBufferSprite.setSize(1.0f, frameBufferSprite.getHeight() / frameBufferSprite.getWidth() );
frameBufferSprite.rotate90(true);
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, 0.5f - frameBufferSprite.getHeight());
}else{
float xSize = Gdx.graphics.getHeight() * (w / h);
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
renderableVideoFrame.rotate90(true);
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
frameBufferSprite.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
frameBufferSprite.rotate90(true);
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, -frameBufferSprite.getHeight() / 2);
} }
}frameBuffer.end();
// Set the frame buffer object texture to a renderable sprite. // Set the correct camera for the device.
region = new TextureRegion(frameBuffer.getColorBufferTexture(), 0, 0, frameBuffer.getWidth(), frameBuffer.getHeight()); if(!Ouya.runningOnOuya){
region.flip(false, true); core.batch.setProjectionMatrix(unitaryOrthographicCamera.combined);
if(frameBufferSprite == null) }else{
frameBufferSprite = new Sprite(region); core.batch.setProjectionMatrix(pixelPerfectOrthographicCamera.combined);
else }
frameBufferSprite.setRegion(region);
frameBufferSprite.setOrigin(frameBufferSprite.getWidth() / 2, frameBufferSprite.getHeight() / 2);
frameBufferSprite.setPosition(0, 0);
// Set the position and orientation of the renderable video frame and the frame buffer. // Render the video frame and the frame buffer.
if(!Ouya.runningOnOuya){ core.batch.begin();{
renderableVideoFrame.setSize(1.0f, renderableVideoFrame.getHeight() / renderableVideoFrame.getWidth() ); renderableVideoFrame.draw(core.batch);
renderableVideoFrame.rotate90(true); frameBufferSprite.draw(core.batch);
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, 0.5f - renderableVideoFrame.getHeight()); }core.batch.end();
frameBufferSprite.setSize(1.0f, frameBufferSprite.getHeight() / frameBufferSprite.getWidth() ); // Clear the video frame from memory.
frameBufferSprite.rotate90(true); videoFrameTexture.dispose();
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, 0.5f - frameBufferSprite.getHeight()); }catch(GdxRuntimeException e){
Gdx.app.error(TAG, CLASS_NAME + ".render(): Runtime exception caught: ", e);
}else{
float xSize = Gdx.graphics.getHeight() * (w / h);
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
renderableVideoFrame.rotate90(true);
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
frameBufferSprite.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
frameBufferSprite.rotate90(true);
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, -frameBufferSprite.getHeight() / 2);
} }
// Set the correct camera for the device.
if(!Ouya.runningOnOuya){
core.batch.setProjectionMatrix(unitaryOrthographicCamera.combined);
}else{
core.batch.setProjectionMatrix(pixelPerfectOrthographicCamera.combined);
}
// Render the video frame and the frame buffer.
core.batch.begin();{
renderableVideoFrame.draw(core.batch);
frameBufferSprite.draw(core.batch);
}core.batch.end();
// Clear the video frame from memory.
videoFrameTexture.dispose();
} }
// Render the interface buttons. // Render the interface buttons.

View File

@@ -133,6 +133,7 @@ public class InstructionsState extends BaseState {
ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png"); ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png");
ouyaOButton = new Sprite(ouyaOButtonTexture); ouyaOButton = new Sprite(ouyaOButtonTexture);
ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f); ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f);
ouyaOButton.setPosition(continueButton.getX() - ouyaOButton.getWidth() - 20, continueButton.getY() + (ouyaOButton.getHeight() / 2));
oButtonPressed = false; oButtonPressed = false;
}else{ }else{
ouyaOButtonTexture = null; ouyaOButtonTexture = null;

View File

@@ -150,10 +150,10 @@ public class OuyaMainMenuState extends MainMenuStateBase{
} }
}else if(buttonCode == Ouya.BUTTON_DPAD_UP){ }else if(buttonCode == Ouya.BUTTON_DPAD_UP){
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad up button pressed."); Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad up button pressed.");
oButtonSelection = oButtonSelection - 1 < 0 ? NUM_MENU_BUTTONS - 1 : oButtonSelection - 1; oButtonSelection = (oButtonSelection + 1) % NUM_MENU_BUTTONS;
}else if(buttonCode == Ouya.BUTTON_DPAD_DOWN){ }else if(buttonCode == Ouya.BUTTON_DPAD_DOWN){
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad down button pressed."); Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad down button pressed.");
oButtonSelection = (oButtonSelection + 1) % NUM_MENU_BUTTONS; oButtonSelection = oButtonSelection - 1 < 0 ? NUM_MENU_BUTTONS - 1 : oButtonSelection - 1;
} }
return true; return true;
@@ -189,4 +189,21 @@ public class OuyaMainMenuState extends MainMenuStateBase{
return false; return false;
} }
} }
@Override
public boolean axisMoved(Controller controller, int axisCode, float value){
if(Math.abs(value) > 0.99f){
if(axisCode == Ouya.AXIS_LEFT_Y && value < 0.0f){
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad up button pressed.");
oButtonSelection = (oButtonSelection + 1) % NUM_MENU_BUTTONS;
}else if(axisCode == Ouya.AXIS_LEFT_Y && value >= 0.0f){
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): Dpad down button pressed.");
oButtonSelection = oButtonSelection - 1 < 0 ? NUM_MENU_BUTTONS - 1 : oButtonSelection - 1;
}
return true;
}
return false;
}
} }

View File

@@ -136,6 +136,7 @@ public class ScenarioEndSummaryState extends BaseState {
ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png"); ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png");
ouyaOButton = new Sprite(ouyaOButtonTexture); ouyaOButton = new Sprite(ouyaOButtonTexture);
ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f); ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f);
ouyaOButton.setPosition(continueButton.getX() - ouyaOButton.getWidth() - 20, continueButton.getY() + (ouyaOButton.getHeight() / 2));
oButtonPressed = false; oButtonPressed = false;
}else{ }else{
ouyaOButtonTexture = null; ouyaOButtonTexture = null;

View File

@@ -82,9 +82,7 @@ public class RobotArmPositioningSystem extends EntityProcessingSystem {
Gdx.app.log(TAG, CLASS_NAME + ".process(): Started moving from " + Utils.vector2String(auto.startPoint) + " to " + Utils.vector2String(auto.endPoint)); Gdx.app.log(TAG, CLASS_NAME + ".process(): Started moving from " + Utils.vector2String(auto.startPoint) + " to " + Utils.vector2String(auto.endPoint));
}else autoMove(geometry, auto, collision); }else autoMove(geometry, auto, collision);
input = null; input = null;
}else if(input instanceof GamepadUserInput){ }else if(input instanceof GamepadUserInput){
tempGP = (GamepadUserInput) input; tempGP = (GamepadUserInput) input;
@@ -92,18 +90,22 @@ public class RobotArmPositioningSystem extends EntityProcessingSystem {
if(!tempGP.oButton){ if(!tempGP.oButton){
geometry.position.x += -tempGP.axisLeftY * STEP_SIZE; geometry.position.x += -tempGP.axisLeftY * STEP_SIZE;
geometry.position.y += tempGP.axisLeftX * STEP_SIZE; geometry.position.y += tempGP.axisLeftX * STEP_SIZE;
if(Math.abs(tempGP.axisLeftX) < Ouya.STICK_DEADZONE && Math.abs(tempGP.axisLeftY) < Ouya.STICK_DEADZONE && Math.abs(tempGP.axisRightX) < Ouya.STICK_DEADZONE && Math.abs(tempGP.axisRightY) < Ouya.STICK_DEADZONE) if(Math.abs(tempGP.axisLeftX) < Ouya.STICK_DEADZONE && Math.abs(tempGP.axisLeftY) < Ouya.STICK_DEADZONE)
input = null; input = null;
else
input = (UserInput)tempGP;
}else{ }else{
endPoint = new Vector3(geometry.position.x, geometry.position.y, MAX_Z); endPoint = new Vector3(geometry.position.x, geometry.position.y, MAX_Z);
auto.startPoint.set(geometry.position); auto.startPoint.set(geometry.position);
auto.endPoint.set(endPoint); auto.endPoint.set(endPoint);
auto.moving = true; auto.moving = true;
auto.forward = true; auto.forward = true;
input = null; input = null;
} }
}else autoMove(geometry, auto, collision); }else{
autoMove(geometry, auto, collision);
input = null;
}
}else if(input instanceof KeyboardUserInput){ }else if(input instanceof KeyboardUserInput){
tempKey = (KeyboardUserInput) input; tempKey = (KeyboardUserInput) input;
@@ -114,20 +116,26 @@ public class RobotArmPositioningSystem extends EntityProcessingSystem {
geometry.position.x -= tempKey.keyDown ? STEP_SIZE : 0.0f; geometry.position.x -= tempKey.keyDown ? STEP_SIZE : 0.0f;
geometry.position.y -= tempKey.keyLeft ? STEP_SIZE : 0.0f; geometry.position.y -= tempKey.keyLeft ? STEP_SIZE : 0.0f;
geometry.position.y += tempKey.keyRight ? STEP_SIZE : 0.0f; geometry.position.y += tempKey.keyRight ? STEP_SIZE : 0.0f;
if(!tempKey.keyUp && !tempKey.keyUp && !tempKey.keyUp && !tempKey.keyUp)
input = null;
else
input = (UserInput)tempKey;
}else{ }else{
endPoint = new Vector3(geometry.position.x, geometry.position.y, MAX_Z); endPoint = new Vector3(geometry.position.x, geometry.position.y, MAX_Z);
auto.startPoint.set(geometry.position); auto.startPoint.set(geometry.position);
auto.endPoint.set(endPoint); auto.endPoint.set(endPoint);
auto.moving = true; auto.moving = true;
auto.forward = true; auto.forward = true;
input = null;
} }
}else autoMove(geometry, auto, collision); }else{
autoMove(geometry, auto, collision);
input = null; input = null;
}
}else }else
throw new ClassCastException("Input is not a valid UserInput instance."); throw new ClassCastException("Input is not a valid UserInput instance.");
} }
} }
private void autoMove(GeometryComponent geometry, AutomaticMovementComponent auto, CollisionDetectionComponent collision){ private void autoMove(GeometryComponent geometry, AutomaticMovementComponent auto, CollisionDetectionComponent collision){