~starkingdoms/starkingdoms

62e3e0789c6c07b6550978d2deea4d3ff5ed1b8d — ghostlyzsh 2 years ago 88b7701 + f48ae47
Merge branch 'master' of https://gitlab.com/starkingdoms.tk/starkingdoms.tk
3 files changed, 15 insertions(+), 2 deletions(-)

M client/play.html
M client/src/gateway.ts
M client/src/index.ts
M client/play.html => client/play.html +1 -0
@@ 14,6 14,7 @@
      <p id="pos">Position: NaN, NaN</p>
      <p id="vel">Velocity: NaN</p>
      <p id="pos-moon">Relative to Moon: NaN, NaN</p>
      <p id="vel-dir">Track Angle: NaN</p>
      <button style="display: none;" id="beamout">Beam out!</button>
    </div>
  </body>

M client/src/gateway.ts => client/src/gateway.ts +5 -0
@@ 153,7 153,12 @@ export async function gateway_connect(gateway_url: string, username: string): Pr
                            let x_vel = (global.me.x - pkt.players[i].x) / (1 / 20);
                            let y_vel = (global.me.y - pkt.players[i].y) / (1 / 20);
                            let total_vel = Math.sqrt(x_vel * x_vel + y_vel * y_vel);
                            global.x_vel = x_vel;
                            global.y_vel = y_vel;
                            global.velocity = total_vel;

                            // calc theta
                            global.direction_radians = Math.atan(global.y_vel / global.x_vel);
                        }

                        global.me = pkt.players[i];

M client/src/index.ts => client/src/index.ts +9 -2
@@ 27,7 27,10 @@ export interface GlobalData {
    context: CanvasRenderingContext2D,
    keys: Keys,
    velocity: number,
    can_beam_out: boolean
    x_vel: number,
    y_vel: number
    can_beam_out: boolean,
    direction_radians: number
}

export interface Keys {


@@ 54,7 57,10 @@ export const global: GlobalData = {
        right: false
    },
    velocity: 0,
    can_beam_out: false
    x_vel: 0,
    y_vel: 0,
    can_beam_out: false,
    direction_radians: 0
}

async function client_main(server: string, username: string, texture_quality: string) {


@@ 234,6 240,7 @@ async function client_main(server: string, username: string, texture_quality: st
            document.getElementById("pos")!.innerText = `Position: ${Math.trunc(global.me.x)}, ${Math.trunc(global.me.y)}`;
        }
        document.getElementById("vel")!.innerText = `Velocity: ${Math.trunc(global.velocity)}`;
        document.getElementById("vel-dir")!.innerText = `Track Angle: ${global.direction_radians}`

        for (let i = 0; i < global.planets.length; i++) {
            let planet = global.planets[i];