game: advent to online
This commit is contained in:
@ -21,22 +21,16 @@ export default class extends AbstractView
|
||||
|
||||
let paddle_size = rail_size * this.game.config.paddle_ratio;
|
||||
|
||||
console.log(paddle_size)
|
||||
|
||||
let diff_x = rail_stop_x - rail_start_x,
|
||||
diff_y = rail_stop_y - rail_start_y;
|
||||
|
||||
console.log("diff", diff_x, diff_y)
|
||||
|
||||
let pos_x = rail_start_x + diff_x * pos,
|
||||
pos_y = rail_start_y + diff_y * pos;
|
||||
|
||||
console.log("pos", pos_x, pos_y)
|
||||
|
||||
let start_x = pos_x - paddle_size * (diff_x * (paddle_size / rail_size)),
|
||||
start_y = pos_y - paddle_size * (diff_y * (paddle_size / rail_size)),
|
||||
stop_x = pos_x + paddle_size * (diff_x * (paddle_size / rail_size)),
|
||||
stop_y = pos_y + paddle_size * (diff_y * (paddle_size / rail_size));
|
||||
let start_x = pos_x - (diff_x * (paddle_size / rail_size)),
|
||||
start_y = pos_y - (diff_y * (paddle_size / rail_size)),
|
||||
stop_x = pos_x + (diff_x * (paddle_size / rail_size)),
|
||||
stop_y = pos_y + (diff_y * (paddle_size / rail_size));
|
||||
|
||||
console.log(start_x, start_y, stop_x, stop_y);
|
||||
ctx.moveTo(start_x, start_y);
|
||||
@ -45,6 +39,11 @@ export default class extends AbstractView
|
||||
ctx.moveTo(rail_stop_x, rail_stop_y);
|
||||
}
|
||||
|
||||
_down()
|
||||
{
|
||||
pl
|
||||
}
|
||||
|
||||
draw_ball(ctx, x, y)
|
||||
{
|
||||
ctx.rect(x, y, this.game.config.ball_size, this.game.config.ball_size);
|
||||
@ -59,14 +58,13 @@ export default class extends AbstractView
|
||||
|
||||
for (let i = 0; i <= nb_sides; i++)
|
||||
{
|
||||
let angle = (i * 2 * Math.PI / nb_sides) + (Math.PI / 4);
|
||||
let angle = (i * 2 * Math.PI / nb_sides) + (Math.PI * 3 / 4);
|
||||
|
||||
stop_x = this.game.config.center_x + 400 * Math.cos(angle);
|
||||
stop_y = this.game.config.center_y + 400 * Math.sin(angle);
|
||||
|
||||
if (i == 0)
|
||||
ctx.moveTo(stop_x, start_y);
|
||||
|
||||
if (i % 2 == 0)
|
||||
this.draw_wall(ctx, stop_x, stop_y);
|
||||
else
|
||||
@ -83,11 +81,11 @@ export default class extends AbstractView
|
||||
|
||||
ctx.beginPath()
|
||||
|
||||
this.draw_sides(ctx, (this.game.players_id.length +10) * 2);
|
||||
this.draw_sides(ctx, (this.game.players_id.length +0) * 2);
|
||||
this.draw_ball(ctx, this.game.ball_pos_x, this.game.ball_pos_y);
|
||||
|
||||
ctx.strokeStyle = "#000000";
|
||||
ctx.lineWidth = 4;
|
||||
ctx.lineWidth = 10;
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
@ -96,6 +94,7 @@ export default class extends AbstractView
|
||||
while (true)
|
||||
{
|
||||
this.draw_game();
|
||||
// TODO remove the line below
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -110,6 +109,7 @@ export default class extends AbstractView
|
||||
|
||||
document.getElementById("app").appendChild(canva);
|
||||
|
||||
this.game.join()
|
||||
this.render_game();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user