fixing merge
This commit is contained in:
parent
6639f562b8
commit
6d7b52ae06
@ -43,26 +43,6 @@ class Player
|
|||||||
* @type {Segment}
|
* @type {Segment}
|
||||||
*/
|
*/
|
||||||
this.rail = rail === undefined ? new Segment() : rail;
|
this.rail = rail === undefined ? new Segment() : rail;
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.rail_size = Math.abs(this.rail.stop.x - this.rail.start.x) + Math.abs(this.rail.stop.y - this.rail.start.y);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.paddle_size = this.rail_size * this.game.config.paddle_ratio;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.diff_x = this.rail.stop.x - this.rail.start.x;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.diff_y = this.rail.stop.y - this.rail.start.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,33 +59,35 @@ class Player
|
|||||||
*/
|
*/
|
||||||
draw(ctx)
|
draw(ctx)
|
||||||
{
|
{
|
||||||
if(ctx instanceof CanvasRenderingContext2D)
|
if (this.is_connected === false)
|
||||||
{
|
{
|
||||||
if (this.is_connected === false)
|
ctx.moveTo(this.rail.start.x, this.rail.start.y);
|
||||||
{
|
ctx.lineTo(this.rail.stop.x, this.rail.stop.y);
|
||||||
ctx.moveTo(this.rail.start.x, this.rail.start.y);
|
return;
|
||||||
ctx.lineTo(this.rail.stop.x, this.rail.stop.y);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
let paddle_pos = new Point(this.rail.start.x + this.diff_x * this.position,
|
|
||||||
this.rail.start.y + this.diff_y * this.position);
|
|
||||||
|
|
||||||
let start_x = paddle_pos.x - (this.diff_x * (this.paddle_size / 2 / this.rail_size)),
|
|
||||||
start_y = paddle_pos.y - (this.diff_y * (this.paddle_size / 2 / this.rail_size)),
|
|
||||||
stop_x = paddle_pos.x + (this.diff_x * (this.paddle_size / 2 / this.rail_size)),
|
|
||||||
stop_y = paddle_pos.y + (this.diff_y * (this.paddle_size / 2 / this.rail_size));
|
|
||||||
|
|
||||||
ctx.moveTo(start_x, start_y);
|
let diff_x = this.rail.stop.x - this.rail.start.x,
|
||||||
ctx.lineTo(stop_x, stop_y);
|
diff_y = this.rail.stop.y - this.rail.start.y;
|
||||||
}
|
|
||||||
else if(ctx instanceof WebGLRenderingContext)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
let rail_length = this.rail.len(),
|
||||||
else
|
paddle_length = rail_length * this.game.config.paddle_ratio;
|
||||||
{
|
|
||||||
alert('Unknown rendering context type (wtf)');
|
let paddle_center = new Point(this.rail.start.x + diff_x * this.position,
|
||||||
}
|
this.rail.start.y + diff_y * this.position);
|
||||||
|
|
||||||
|
let paddle_start_x = paddle_center.x - (diff_x * (paddle_length / 2 / rail_length)),
|
||||||
|
paddle_start_y = paddle_center.y - (diff_y * (paddle_length / 2 / rail_length)),
|
||||||
|
paddle_stop_x = paddle_center.x + (diff_x * (paddle_length / 2 / rail_length)),
|
||||||
|
paddle_stop_y = paddle_center.y + (diff_y * (paddle_length / 2 / rail_length));
|
||||||
|
|
||||||
|
let paddle_start = new Point(paddle_start_x, paddle_start_y),
|
||||||
|
paddle_stop = new Point (paddle_stop_x, paddle_stop_y);
|
||||||
|
|
||||||
|
let paddle = new Segment(paddle_start, paddle_stop);
|
||||||
|
|
||||||
|
console.log(paddle)
|
||||||
|
|
||||||
|
paddle.draw(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
from_json(data)
|
from_json(data)
|
||||||
@ -135,26 +117,6 @@ class Player
|
|||||||
*/
|
*/
|
||||||
this.rail = this.rail.from_json(data.rail);
|
this.rail = this.rail.from_json(data.rail);
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.rail_size = Math.abs(this.rail.stop.x - this.rail.start.x) + Math.abs(this.rail.stop.y - this.rail.start.y);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.paddle_size = this.rail_size * this.game.config.paddle_ratio;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.diff_x = this.rail.stop.x - this.rail.start.x;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Number}
|
|
||||||
*/
|
|
||||||
this.diff_y = this.rail.stop.y - this.rail.start.y;
|
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user