game: add: class: point and segment, add: type docstring
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
import { client } from "../index.js";
|
||||
import { Game } from "../api/game/Game.js";
|
||||
import AbstractView from "./abstracts/AbstractView.js";
|
||||
import { Time } from "../api/game/Time.js";
|
||||
import { MyPlayer } from "../api/game/MyPlayer.js";
|
||||
import { Ball } from "../api/game/Ball.js";
|
||||
|
||||
export default class extends AbstractView
|
||||
{
|
||||
@ -35,6 +33,9 @@ export default class extends AbstractView
|
||||
if (canva === null)
|
||||
return 1;
|
||||
|
||||
/**
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
let ctx = canva.getContext('2d');
|
||||
|
||||
ctx.beginPath();
|
||||
@ -71,7 +72,7 @@ export default class extends AbstractView
|
||||
document.removeEventListener('keyup', this.keyStretchHandler);
|
||||
}
|
||||
|
||||
async start_game()
|
||||
async join_game()
|
||||
{
|
||||
await this.game.join()
|
||||
|
||||
@ -89,16 +90,13 @@ export default class extends AbstractView
|
||||
let my_player = this.game.players[index];
|
||||
this.my_player = new MyPlayer(client,
|
||||
this.game,
|
||||
my_player.rail_start_x,
|
||||
my_player.rail_start_y,
|
||||
my_player.rail_stop_x,
|
||||
my_player.rail_stop_y,
|
||||
my_player.nb_goal,
|
||||
my_player.positon,
|
||||
my_player.rail,
|
||||
my_player.nb_gool,
|
||||
my_player.position,
|
||||
);
|
||||
this.game.players[index] = this.my_player;
|
||||
}
|
||||
|
||||
|
||||
this.register_key()
|
||||
|
||||
this.render_game();
|
||||
@ -108,8 +106,8 @@ export default class extends AbstractView
|
||||
{
|
||||
document.getElementById("game-state").innerText = this.game.state;
|
||||
|
||||
if (this.game.started === true && this.game.finished === false)
|
||||
await this.start_game();
|
||||
if (this.game.finished === false)
|
||||
await this.join_game();
|
||||
}
|
||||
|
||||
async postInit()
|
||||
@ -124,7 +122,7 @@ export default class extends AbstractView
|
||||
|
||||
async leavePage()
|
||||
{
|
||||
if (this.game.started === true && this.game.finished === false)
|
||||
if (this.game.finished === false)
|
||||
{
|
||||
this.game.leave();
|
||||
this.game = undefined;
|
||||
|
Reference in New Issue
Block a user