fixing WebGL warnings
This commit is contained in:
@ -50,21 +50,7 @@ export class PongBall extends AExchangeable
|
||||
*/
|
||||
draw(ctx)
|
||||
{
|
||||
if(ctx instanceof CanvasRenderingContext2D)
|
||||
{
|
||||
ctx.rect(this.position.location.x - this.size / 2, this.position.location.y - this.size / 2, this.size, this.size);
|
||||
}
|
||||
else if(ctx instanceof WebGLRenderingContext)
|
||||
{
|
||||
const size = this.size * 3;
|
||||
const posx = (this.position.location.x - this.size / 2) - this.game.config.MAP_SIZE_X / 2;
|
||||
const posy = (this.position.location.y - this.size / 2) - this.game.config.MAP_SIZE_Y / 2;
|
||||
renderCube(ctx, posx, 0, posy, 0, size, size, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
alert('Unknown rendering context type');
|
||||
}
|
||||
ctx.rect(this.position.location.x - this.size / 2, this.position.location.y - this.size / 2, this.size, this.size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,4 +66,4 @@ export class PongBall extends AExchangeable
|
||||
|
||||
this.draw(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,23 +49,8 @@ class Segment extends AExchangeable
|
||||
|
||||
draw(ctx)
|
||||
{
|
||||
if(ctx instanceof CanvasRenderingContext2D)
|
||||
{
|
||||
ctx.moveTo(this.start.x, this.start.y);
|
||||
ctx.lineTo(this.stop.x, this.stop.y);
|
||||
}
|
||||
else if(ctx instanceof WebGLRenderingContext)
|
||||
{
|
||||
const size = this.game.config.BALL_SIZE * 2;
|
||||
const sizex = this.len() / 2;
|
||||
const posx = (this.start.x - this.game.config.MAP_CENTER_X);
|
||||
const posy = (this.start.y - this.game.config.MAP_CENTER_Y);
|
||||
renderCube(ctx, posx, 0, posy, -this.angle(), sizex, size, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
alert('Unknown rendering context type');
|
||||
}
|
||||
ctx.moveTo(this.start.x, this.start.y);
|
||||
ctx.lineTo(this.stop.x, this.stop.y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,22 +23,7 @@ export class Wall extends Segment
|
||||
|
||||
draw(ctx)
|
||||
{
|
||||
if(ctx instanceof CanvasRenderingContext2D)
|
||||
{
|
||||
ctx.moveTo(this.start.x, this.start.y);
|
||||
ctx.lineTo(this.stop.x, this.stop.y);
|
||||
}
|
||||
else if(ctx instanceof WebGLRenderingContext)
|
||||
{
|
||||
const size = this.game.config.BALL_SIZE * 2;
|
||||
const sizeX = this.len() / 2;
|
||||
const posX = (this.start.x - this.game.config.MAP_CENTER_X);
|
||||
const posY = (this.start.y - this.game.config.MAP_CENTER_Y);
|
||||
renderCube(ctx, posX, 0, posY, -this.angle(), sizeX, size, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
alert('Unknown rendering context type');
|
||||
}
|
||||
ctx.moveTo(this.start.x, this.start.y);
|
||||
ctx.lineTo(this.stop.x, this.stop.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user