space-browser / commits / 2a0ab06
fix: clear mvoement marker on arrival
@@ -50,7 +50,8 @@ function frame(): void {
5050 const w = p && at(p);
5151 view.setPointer(c ? c.cellX : null, c?.cellY, w ? spot(w.x, w.y) : undefined);
5252
53- // The marker is the order the server is flying: never a click of our own.
53+ // The marker is the order the server is flying: never a click of our own, and
54+ // never one it has already flown.
5455 const me = own();
5556 if (cam.scene === 'galaxy') {
5657 view.drawGalaxy(cam, state?.systems ?? [], [...ships.values()], state?.you ?? 0);
@@ -63,7 +64,7 @@ function frame(): void {
6364 [...shots.values()],
6465 [...loose.values()],
6566 [...ore.values()],
66- me && !state?.held ? { x: me.tx, y: me.ty } : null,
67+ me && me.order && !state?.held ? { x: me.tx, y: me.ty } : null,
6768 );
6869 }
6970 requestAnimationFrame(frame);
@@ -37,6 +37,7 @@ export type Ship = {
3737 h: number;
3838 tx: number; // where it is flying to, so the marker can show the order
3939 ty: number;
40+ order: boolean; // that order is still pending, so the marker is due
4041 fuel: number; // what is in the tank
4142 fuelmax: number; // capacity, summed from the hull
4243 side: string; // police or rogue for a server hull, empty for a player
@@ -47,6 +47,7 @@ export function apply(dt: number): void {
4747 s.h = turn(s.h, p.h, k);
4848 s.tx = p.tx;
4949 s.ty = p.ty;
50+ s.order = p.order;
5051 s.fuel = p.fuel; // a gauge has to jump, not ease, or it lies about the tank
5152 s.fuelmax = p.fuelmax;
5253 s.foe = p.foe;
@@ -13,7 +13,7 @@ func (p *player) steer(dt float64) {
1313 dx, dy := p.TX-p.X, p.TY-p.Y
1414 dist := math.Hypot(dx, dy)
1515 var wantX, wantY float64
16- if dist >= 0.5 {
16+ if dist >= settle {
1717 s := math.Min(maxSpeed, dist*arrive)
1818 wantX, wantY = dx/dist*s, dy/dist*s
1919 }
@@ -66,6 +66,18 @@ func (h *hub) step(dt float64) {
6666 }
6767 }
6868 p.steer(dt)
69+ // An order is spent once the ship reaches it, and a spent order is nothing to
70+ // mark: a point when the ship settles on it, an orbit when it is docked on the
71+ // ring. A flown point stops being a target at all; an orbit has to keep its
72+ // turning ring point, or the ship would be left standing still.
73+ r := settle
74+ if p.orbit != 0 {
75+ r = dockR
76+ }
77+ p.Order = math.Hypot(p.TX-p.X, p.TY-p.Y) >= r
78+ if !p.Order && p.orbit == 0 {
79+ p.TX, p.TY = p.X, p.Y
80+ }
6981 h.burn(p, dt)
7082 h.haul(p)
7183 h.guns(p, dt)
@@ -22,6 +22,7 @@ const (
2222 maxSpeed = 90.0
2323 accel = 260.0
2424 arrive = 2.2 // slowdown radius factor
25+ settle = 0.5 // a ship this close to its target has arrived and stops thrusting
2526 reach = 4000.0 // an order further out than this is ignored
2627
2728 oreGap = 15.0 // closest two ore may sit: also the spacing of the rings
@@ -173,6 +174,7 @@ type player struct {
173174 H float64 `json:"h"`
174175 TX float64 `json:"tx"`
175176 TY float64 `json:"ty"`
177+ Order bool `json:"order"` // the order is still pending, so it is still to be marked
176178 Pieces []piece `json:"pieces"`
177179 Fuel float64 `json:"fuel"` // what is in the tank, spent by flying
178180 FuelMax float64 `json:"fuelmax"` // capacity, summed from the hull every tick