Smooth camera and unit motion: display positions, camera target smoothing, pan speed setting
This commit is contained in:
1 parent
583c3fcdaf
commit
eb11cca8cb
10 files changed
+107
-23
No files matched your search
+8
-3
@@ -394,6 +394,7 @@ impl App {
|
||||
self.game = l.game;
|
||||
if let Some(c) = l.camera {
|
||||
self.cam = c;
|
||||
self.cam.snap();
|
||||
}
|
||||
if let Some(s) = l.settings {
|
||||
self.settings = s;
|
||||
@@ -778,7 +779,7 @@ async fn main() {
|
||||
if playing {
|
||||
let cam = &mut app.cam;
|
||||
let (right, fwd) = cam.ground_axes();
|
||||
let pan = cam.zoom * 0.9 * dt;
|
||||
let pan = cam.zoom * keys.pan_speed.max(0.25) * dt;
|
||||
let move_cam = |dx: f32, dz: f32, cam: &mut Cam| {
|
||||
let d = right * dx + fwd * dz;
|
||||
cam.tx += d.x;
|
||||
@@ -1134,6 +1135,9 @@ async fn main() {
|
||||
}
|
||||
app.cam.tx = app.cam.tx.clamp(0.0, mw() as f32);
|
||||
app.cam.tz = app.cam.tz.clamp(0.0, mh() as f32);
|
||||
app.cam.rx = app.cam.rx.clamp(0.0, mw() as f32);
|
||||
app.cam.rz = app.cam.rz.clamp(0.0, mh() as f32);
|
||||
app.cam.update_render(dt);
|
||||
|
||||
if settings_changed {
|
||||
apply_settings(&app.settings, &mut r3d);
|
||||
@@ -1167,10 +1171,11 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
app.game.smooth_display(dt);
|
||||
let hear = app.cam.zoom * 1.2;
|
||||
let (right, _) = app.cam.ground_axes();
|
||||
for ev in app.game.events.drain(..) {
|
||||
sounds.play(ev, vec2(app.cam.tx, app.cam.tz), right, hear, now);
|
||||
sounds.play(ev, vec2(app.cam.rx, app.cam.rz), right, hear, now);
|
||||
}
|
||||
// a won mission goes into the campaign progress (with the carry-over)
|
||||
if let (Some(i), false) = (app.game.mission.as_ref().map(|m| m.index), app.recorded) {
|
||||
@@ -1195,7 +1200,7 @@ async fn main() {
|
||||
| Some(Page::Account)
|
||||
| Some(Page::Bestiary { from_title: true, .. })
|
||||
);
|
||||
music.update(&app.game, on_title, (app.cam.tx, app.cam.tz));
|
||||
music.update(&app.game, on_title, (app.cam.rx, app.cam.rz));
|
||||
for m in app.game.msgs.drain(..) {
|
||||
if app.settings.voice && voice::speaks(m.key) {
|
||||
voice.say(&i18n::trf(m.key, &m.args), now, 12);
|
||||
|
||||
Reference in new issue
Block a user