3030import org .destinationsol .game .input .Shooter ;
3131import org .destinationsol .ui .SolInputManager ;
3232import org .destinationsol .ui .SolUiControl ;
33+ import org .slf4j .Logger ;
34+ import org .slf4j .LoggerFactory ;
3335
3436import java .util .List ;
3537
@@ -39,15 +41,16 @@ public class ShipMixedControl implements ShipUiControl {
3941 public final SolUiControl shoot2Ctrl ;
4042 public final SolUiControl abilityCtrl ;
4143 private final SolUiControl myDownCtrl ;
42- private final Vector2 myMouseScreenPos ;
44+ private final Vector2 mouseScreenPos ;
4345 private final TextureAtlas .AtlasRegion myCursor ;
44- private boolean myRight ;
45- private boolean myLeft ;
46+ private boolean turnRight ;
47+ private boolean turnLeft ;
48+ private Logger logger = LoggerFactory .getLogger (ShipMixedControl .class );
4649
4750 ShipMixedControl (SolApplication solApplication , List <SolUiControl > controls ) {
4851 GameOptions gameOptions = solApplication .getOptions ();
4952 myCursor = Assets .getAtlasRegion ("engine:uiCursorTarget" );
50- myMouseScreenPos = new Vector2 ();
53+ mouseScreenPos = new Vector2 ();
5154 upCtrl = new SolUiControl (null , false , gameOptions .getKeyUpMouse ());
5255 controls .add (upCtrl );
5356 myDownCtrl = new SolUiControl (null , false , gameOptions .getKeyDownMouse ());
@@ -71,18 +74,18 @@ public void update(SolApplication solApplication, boolean enabled) {
7174 SolInputManager im = solApplication .getInputManager ();
7275 Hero hero = game .getHero ();
7376 if (hero .isNonTranscendent ()) {
74- myMouseScreenPos .set (Gdx .input .getX (), Gdx .input .getY ());
77+ mouseScreenPos .set (Gdx .input .getX (), Gdx .input .getY ());
7578 // project mouse coordinates [0;width] and [0;height] to screen coordinates [0,1], [0,1] by scaling down
76- myMouseScreenPos .scl (1.0f / Gdx .graphics .getWidth (), 1.0f / Gdx .graphics .getHeight ());
79+ mouseScreenPos .scl (1.0f / Gdx .graphics .getWidth (), 1.0f / Gdx .graphics .getHeight ());
7780 Vector2 shipOnScreen = game .getCam ().worldToScreen (hero .getShip ()); // unproject hero to screen coordinates
78- assertHeroAndMouseCoords (myMouseScreenPos , shipOnScreen );
79- float desiredAngle = SolMath .angle (shipOnScreen , myMouseScreenPos );
80- Boolean ntt = Mover .needsToTurn (hero .getAngle (), desiredAngle , hero .getRotationSpeed (), hero .getRotationAcceleration (), Shooter .MIN_SHOOT_AAD );
81- if (ntt != null ) {
82- if (ntt ) {
83- myRight = true ;
81+ assertHeroAndMouseCoords (mouseScreenPos , shipOnScreen );
82+ float desiredAngle = SolMath .angle (shipOnScreen , mouseScreenPos );
83+ Boolean needsToTurn = Mover .needsToTurn (hero .getAngle (), desiredAngle , hero .getRotationSpeed (), hero .getRotationAcceleration (), Shooter .MIN_SHOOT_AAD );
84+ if (needsToTurn != null ) {
85+ if (needsToTurn ) {
86+ turnRight = true ;
8487 } else {
85- myLeft = true ;
88+ turnLeft = true ;
8689 }
8790 }
8891 if (!im .isMouseOnUi ()) {
@@ -115,25 +118,23 @@ private boolean problemWithProjections(SolCam camera) {
115118 * @param heroCoords hero coordinates projected to [0;1] screen space
116119 */
117120 private void assertHeroAndMouseCoords (Vector2 mouseCoords , Vector2 heroCoords ) {
118- if (Double .isNaN (mouseCoords .x ) || Double .isNaN (mouseCoords .y )) {
119- System .err .println ("Screen size: " + Gdx .graphics .getWidth () + " " + Gdx .graphics .getHeight ());
121+ if (Double .isNaN (mouseCoords .x ) || Double .isNaN (mouseCoords .y )) {
120122 throw new RuntimeException ("Mouse coordinates are not valid: " + mouseCoords .x + " " + mouseCoords .y );
121123 }
122124
123- if (Double .isNaN (heroCoords .x ) || Double .isNaN (heroCoords .y )) {
124- System .err .println ("Screen size: " + Gdx .graphics .getWidth () + " " + Gdx .graphics .getHeight ());
125+ if (Double .isNaN (heroCoords .x ) || Double .isNaN (heroCoords .y )) {
125126 throw new RuntimeException ("Hero coordinates are not valid: " + heroCoords .x + " " + heroCoords .y );
126127 }
127128 }
128129
129130 @ Override
130131 public boolean isLeft () {
131- return myLeft ;
132+ return turnLeft ;
132133 }
133134
134135 @ Override
135136 public boolean isRight () {
136- return myRight ;
137+ return turnRight ;
137138 }
138139
139140 @ Override
@@ -168,7 +169,7 @@ public TextureAtlas.AtlasRegion getInGameTex() {
168169
169170 @ Override
170171 public void blur () {
171- myLeft = false ;
172- myRight = false ;
172+ turnLeft = false ;
173+ turnRight = false ;
173174 }
174175}
0 commit comments