Commit ea1cb2b2 authored by Aneta Steimarova's avatar Aneta Steimarova

#847 Made some new constants

parent c60c4cbc
......@@ -29,6 +29,8 @@ import cz.nic.tablexia.game.games.safe.model.SafeSequence;
public abstract class AbstractMechanics extends Group {
private static final int ANGLE_SPREAD = 17;
private static final int FULL_DEGREES = 360;
private static final int QUARTER_OF_CIRCLE = 90;
public static final String LIGHT_NAME = "light";
public static final String LIGHT_LIGHTED_UP = "light lighted up";
public static boolean holding = false;
......@@ -44,7 +46,7 @@ public abstract class AbstractMechanics extends Group {
boolean foundValid = false;
for (SafeLightImage lightImage : listOfLights) {
float testedAngle = lightImage.getAngle();
if(testedAngle<0) testedAngle+=360;
if(testedAngle<0) testedAngle+=FULL_DEGREES;
if (testedAngle - ANGLE_SPREAD <= angle && testedAngle + ANGLE_SPREAD > angle) {
foundValid = true;
if (!lightImage.equals(safeGame.getSelectedLight())) {
......@@ -63,7 +65,7 @@ public abstract class AbstractMechanics extends Group {
protected void rotateSafeCircleTo(Vector2 dest, Image rotationObject) {
Vector2 safeOrigin = rotationObject.localToStageCoordinates(new Vector2(rotationObject.getOriginX(), rotationObject.getOriginY()));
float angle = dest.sub(safeOrigin).angle() - 90;
float angle = dest.sub(safeOrigin).angle() - QUARTER_OF_CIRCLE;
rotationObject.setRotation(angle);
}
......
......@@ -46,8 +46,11 @@ public class Cable extends Group {
private static final int INC_SHAPING = 100;
private static final int CNT_PARTS_MIN_SHAPING = 5;
private static final int MIN_CABLE_LENGTH = 30;
private static final int SAMPLES = 10;
private static final int FULL_DEGREES = 360;
private static final int QUARTER_OF_CIRCLE = 90;
public static final int CABLE_WIDTH = 20;
public static final int CABLE_WIDTH = 20;
private static final float UV_TEXTURE_BLEEDING_FIX = 0.003f;
......@@ -189,7 +192,7 @@ public class Cable extends Group {
cableSpriteBatch.reset();
spline.set(splineVectors, false);
float approxLength = spline.approxLength(10);
float approxLength = spline.approxLength(SAMPLES);
int minParts = getCableLength() > MIN_CABLE_LENGTH ? MINUMUM_CABLE_PARTS : 2;
int cableSegments = (int) (approxLength / PREFFERED_CABLE_PART_LENGTH);
......@@ -208,7 +211,7 @@ public class Cable extends Group {
spline.valueAt(tempPoint, progress);
spline.derivativeAt(tempDir, progress);
distances.add(prevPoint.dst(tempPoint));
float angle = (tempDir.angle() + 90) % 360;
float angle = (tempDir.angle() + QUARTER_OF_CIRCLE) % FULL_DEGREES;
float cos = MathUtils.cosDeg(angle) * CABLE_WIDTH/2;
float sin = MathUtils.sinDeg(angle) * CABLE_WIDTH/2;
......
......@@ -55,6 +55,7 @@ public class SequenceGenerator extends Group {
private static final Color PLAY_COLOR = new Color(0x29abe1ff); //baby blue
private static final Color NORMAL_COLOR = Color.BLACK;
private static final float SILENCE_DELAY = 2f;
private static final float SEQUENCE_DELAY = 1f;
private Image earImage, backgroundImage;
private TablexiaLabel text;
......@@ -100,7 +101,7 @@ public class SequenceGenerator extends Group {
* @param afterAction do this after sound sequence has been played
*/
public void playSequenceVisualization(SafeSequence safeSequence, SafeGame safeGame, List<Actor> listOfChars, RunnableAction afterAction){
SequenceGenerator.this.addAction(Actions.sequence(Actions.delay(1f), soundSequence(safeSequence, safeGame, listOfChars)));
SequenceGenerator.this.addAction(Actions.sequence(Actions.delay(SEQUENCE_DELAY), soundSequence(safeSequence, safeGame, listOfChars)));
SequenceGenerator.this.addAction(Actions.after(afterAction));
}
......
......@@ -44,15 +44,17 @@ import cz.nic.tablexia.screen.AbstractTablexiaScreen;
*/
public class CableGroup extends Group {
private final int SOCKET_WIDTH = 125;
private final int SOCKET_HEIGHT = 75;
private static final int SOCKET_WIDTH = 125;
private static final int SOCKET_HEIGHT = 75;
private final int CONNECTOR_WIDTH = 80;
private final int CONNECTOR_HEIGHT = 40;
private final int MAX_CABLE_PARTS = 18;
private static final int CONNECTOR_WIDTH = 80;
private static final int CONNECTOR_HEIGHT = 40;
private static final int MAX_CABLE_PARTS = 18;
private final int SAFE_LIGHT_SIZE = 40;
private final int SAFE_LIGHT_X_POS = 50;
private static final int SAFE_LIGHT_SIZE = 40;
private static final int SAFE_LIGHT_X_POS = 50;
private static final float LIGHT_DELAY = 1;
private SafeGame safeGame;
private SafeMechanicsMedium mechanicsMedium;
......@@ -106,7 +108,7 @@ public class CableGroup extends Group {
public void run() {
lightImage.light(listOfLights, safeGame.getSelectedLight());
}
}), Actions.delay(1), Actions.run(new Runnable() {
}), Actions.delay(LIGHT_DELAY), Actions.run(new Runnable() {
@Override
public void run() {
if (safeGame.getSelectedLight() != null)
......
......@@ -33,6 +33,7 @@ import cz.nic.tablexia.game.AbstractTablexiaGame;
*/
public class SafeLightImage extends Image {
private static final float DEFAULT_ANGLE = -1;
private TextureRegion screenTextureGrey;
private TextureRegion screenTextureRed;
......@@ -67,7 +68,7 @@ public class SafeLightImage extends Image {
this.screenTextureGreen = game.getScreenTextureRegion(greenTextureRegion);
this.screenTextureBlue = game.getScreenTextureRegion(blueTextureRegion);
this.sound = music;
this.angle = -1;
this.angle = DEFAULT_ANGLE;
}
public Music getSound() {
......
......@@ -59,6 +59,8 @@ public class VisualizationDialog {
private static final float IMAGE_SPACE = 10;
private static final Color CHARACTER_COLOR = Color.BLACK;
private static final int ALPHA = 0;
SafeGame safeGame;
public VisualizationDialog(SafeGame safeGame, Image dimmer) {
......@@ -105,7 +107,7 @@ public class VisualizationDialog {
vizualizationGroup.setVisible(false);
safeGame.getStage().addActor(vizualizationGroup);
vizualizationGroup.addAction(Actions.sequence(Actions.alpha(0), Actions.visible(true), Actions.fadeIn(SafeGame.FADE_ANIMATION_DURATION), Actions.run(new Runnable() {
vizualizationGroup.addAction(Actions.sequence(Actions.alpha(ALPHA), Actions.visible(true), Actions.fadeIn(SafeGame.FADE_ANIMATION_DURATION), Actions.run(new Runnable() {
@Override
public void run() {
safeGame.getSequenceGenerator().playSequenceVisualization(safeGame.getSafeSequence(), safeGame, listOfChars, Actions.run(new Runnable() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment