This commit is contained in:
Kbz-8
2024-02-14 20:22:07 +01:00
parent 0bd7e05c17
commit f7fbfcad15
5 changed files with 192 additions and 18 deletions

View File

@ -1,6 +1,6 @@
import { Game } from "./Game.js";
import { Point } from "./Point.js";
import { renderCube } from "../../3D/cube.js"
class Ball
{
@ -46,7 +46,19 @@ class Ball
*/
draw(ctx)
{
ctx.rect(this.position.x - this.size / 2, this.position.y - this.size / 2, this.size, this.size);
if(ctx instanceof CanvasRenderingContext2D)
{
ctx.rect(this.position.x - this.size / 2, this.position.y - this.size / 2, this.size, this.size);
}
else if(ctx instanceof WebGLRenderingContext)
{
console.log((this.position.x - this.size / 2) / 10, 0, (this.position.y - this.size / 2) / 10)
renderCube(ctx, (this.position.x - this.size / 2) / 10, 0, (this.position.y - this.size / 2) / 10, 0, this.size * 10, this.size * 10, this.size * 10);
}
else
{
alert('Unknown rendering context type');
}
}
/**

View File

@ -1,6 +1,7 @@
import { Game } from "./Game.js";
import { Point } from "./Point.js";
import { Segment } from "./Segment.js";
import { renderCube } from "../../3D/cube.js"
class Player
{
@ -61,8 +62,11 @@ class Player
{
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);
if(ctx instanceof CanvasRenderingContext2D)
{
ctx.moveTo(this.rail.start.x, this.rail.start.y);
ctx.lineTo(this.rail.stop.x, this.rail.stop.y);
}
return;
}