game: add: game map
This commit is contained in:
43
frontend/static/js/api/game/GameConfig.js
Normal file
43
frontend/static/js/api/game/GameConfig.js
Normal file
@ -0,0 +1,43 @@
|
||||
class GameConfig
|
||||
{
|
||||
/**
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor(client)
|
||||
{
|
||||
/**
|
||||
* @type {Client}
|
||||
*/
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async init()
|
||||
{
|
||||
let response = await this.client._get("/api/games/");
|
||||
|
||||
if (response.status !== 200)
|
||||
return response.status;
|
||||
|
||||
let response_data = await response.json();
|
||||
|
||||
|
||||
this.size_x = response_data.MAP_SIZE_X;
|
||||
this.size_y = response_data.MAP_SIZE_Y;
|
||||
this.center_x = this.size_x / 2;
|
||||
this.center_y = this.size_y / 2;
|
||||
|
||||
this.paddle_ratio = response_data.PADDLE_RATIO;
|
||||
this.wall_ratio = response_data.WALL_RATIO;
|
||||
|
||||
this.ball_speed_inc = response_data.BALL_SPEED_INC;
|
||||
this.ball_speed_start = response_data.BALL_SPEED_START;
|
||||
|
||||
this.ball_size = response_data.BALL_SIZE;
|
||||
this.ball_spawn_x = this.center_x;
|
||||
this.ball_spawn_y = this.center_y;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export { GameConfig }
|
Reference in New Issue
Block a user