Skip to content

Commit 3d474ba

Browse files
authored
Merge pull request #126 from Avalancs/pauseMapFix
fix map doesn't look right when the game is paused (issue #119)
2 parents a0ac41d + cc7122b commit 3d474ba

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

main/src/org/destinationsol/game/SolCam.java

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ public Matrix4 getMtx() {
6262
}
6363

6464
public void update(SolGame game) {
65-
66-
float desiredVd = Const.CAM_VIEW_DIST_GROUND;
6765
float life = 0;
6866

6967
SolShip hero = game.getHero();
@@ -75,7 +73,6 @@ public void update(SolGame game) {
7573
applyInput(game);
7674
}
7775
} else {
78-
desiredVd = Const.CAM_VIEW_DIST_SPACE;
7976
myPos.set(trans.getPosition());
8077
}
8178
} else {
@@ -93,17 +90,6 @@ public void update(SolGame game) {
9390
myPos.y = SolMath.approach(myPos.y, heroPos.y, moveSpd);
9491
}
9592
life = hero.getLife();
96-
97-
float spd = hero.getSpd().len();
98-
99-
desiredVd = Const.CAM_VIEW_DIST_SPACE;
100-
Planet np = game.getPlanetMan().getNearestPlanet(myPos);
101-
if (np.getFullHeight() < np.getPos().dst(myPos) && MAX_ZOOM_SPD < spd) {
102-
desiredVd = Const.CAM_VIEW_DIST_JOURNEY;
103-
} else if (np.isNearGround(myPos) && spd < MED_ZOOM_SPD) {
104-
desiredVd = Const.CAM_VIEW_DIST_GROUND;
105-
}
106-
desiredVd += hero.getHull().config.getApproxRadius();
10793
}
10894

10995
if (life < myPrevHeroLife) {
@@ -124,12 +110,38 @@ public void update(SolGame game) {
124110
myAngle = SolMath.approachAngle(myAngle, desiredAngle, rotSpd);
125111
applyAngle();
126112

127-
float desiredZoom = calcZoom(desiredVd);
113+
updateMap(game);
114+
}
115+
116+
public void updateMap(SolGame game) {
117+
float ts = game.getTimeStep();
118+
float desiredViewDistance = getDesiredViewDistance(game);
119+
float desiredZoom = calcZoom(desiredViewDistance);
128120
myZoom = SolMath.approach(myZoom, desiredZoom, ZOOM_CHG_SPD * ts);
129121
applyZoom(game.getMapDrawer());
130122
myCam.update();
131123
}
132124

125+
private float getDesiredViewDistance(SolGame game) {
126+
SolShip hero = game.getHero();
127+
if(hero == null && game.getTranscendentHero() != null) { // hero is in transcendent state
128+
return Const.CAM_VIEW_DIST_SPACE;
129+
} else if(hero == null && game.getTranscendentHero() == null) {
130+
return Const.CAM_VIEW_DIST_GROUND;
131+
} else {
132+
float speed = hero.getSpd().len();
133+
float desiredViewDistance = Const.CAM_VIEW_DIST_SPACE;
134+
Planet nearestPlanet = game.getPlanetMan().getNearestPlanet(myPos);
135+
if (nearestPlanet.getFullHeight() < nearestPlanet.getPos().dst(myPos) && MAX_ZOOM_SPD < speed) {
136+
desiredViewDistance = Const.CAM_VIEW_DIST_JOURNEY;
137+
} else if (nearestPlanet.isNearGround(myPos) && speed < MED_ZOOM_SPD) {
138+
desiredViewDistance = Const.CAM_VIEW_DIST_GROUND;
139+
}
140+
desiredViewDistance += hero.getHull().config.getApproxRadius();
141+
return desiredViewDistance;
142+
}
143+
}
144+
133145
private float calcZoom(float vd) {
134146
float h = vd * SolMath.sqrt(2);
135147
return h / VIEWPORT_HEIGHT;

main/src/org/destinationsol/game/SolGame.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ public GameScreens getScreens() {
255255
public void update() {
256256
myDraDebugger.update(this);
257257

258-
if (myPaused) return;
258+
if (myPaused) {
259+
myCam.updateMap(this); // update zoom only for map
260+
myMapDrawer.update(this); // animate map icons
261+
return;
262+
}
259263

260264
myTimeFactor = DebugOptions.GAME_SPEED_MULTIPLIER;
261265
if (myHero != null) {

0 commit comments

Comments
 (0)