fixing merge conflicts

This commit is contained in:
Kbz-8
2024-02-21 16:43:44 +01:00
12 changed files with 457 additions and 17 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');
}
}
/**
@ -74,4 +86,4 @@ class Ball
}
}
export { Ball };
export { Ball };

View File

@ -114,7 +114,10 @@ class Game
*/
render(ctx)
{
ctx.clearRect(0, 0, this.config.size_x, this.config.size_y);
if(ctx instanceof CanvasRenderingContext2D)
{
ctx.clearRect(0, 0, this.config.size_x, this.config.size_y);
}
this.draw_sides(ctx);
this.ball.render(ctx);

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
{
@ -67,8 +68,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;
}
@ -107,4 +111,4 @@ class Player
}
}
export { Player };
export { Player };

View File

@ -1,4 +1,9 @@
<<<<<<< HEAD
import { Point } from "./Point.js";
=======
import { Point } from "./Point.js"
import { renderCube } from "../../3D/cube.js"
>>>>>>> de2488589cf0a579b849e706b40901c355ff35f8
class Segment
{
@ -41,8 +46,19 @@ class Segment
*/
draw(ctx)
{
ctx.moveTo(this.start.x, this.start.y);
ctx.lineTo(this.stop.x, this.stop.y);
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)
{
renderCube(ctx, this.start.x, -3, this.start.y, 0, 0.5, 0.5, 0.5);
}
else
{
alert('Unknown rendering context type');
}
}
from_json(data)
@ -54,4 +70,4 @@ class Segment
}
}
export { Segment };
export { Segment }

View File

@ -14,8 +14,8 @@ class Wall
}
draw(ctx)
{
this.rail.draw(ctx);
{
this.rail.draw(ctx);
}
from_json(data)
@ -26,4 +26,4 @@ class Wall
}
}
export { Wall };
export { Wall };