fixing merge

This commit is contained in:
Kbz-8 2024-02-14 18:52:43 +01:00 committed by AdrienLSH
parent f1f6cc939a
commit 04afee89d2

View File

@ -1,6 +1,6 @@
import { Game } from "./Game.js"; import { Game } from "./Game.js";
import { Point } from "./Point.js"; import { Point } from "./Point.js";
import { renderCube } from "../../3D/cube.js"
class Ball class Ball
{ {
@ -42,22 +42,11 @@ class Ball
/** /**
* *
* @param {CanvasRenderingContext2D} ctx ou pas ptdr * @param {CanvasRenderingContext2D} ctx
*/ */
draw(ctx) draw(ctx)
{ {
if(ctx instanceof CanvasRenderingContext2D) ctx.rect(this.position.x - this.size / 2, this.position.y - this.size / 2, this.size, this.size);
{
ctx.rect(this.position_x, this.position_y, this.game.config.ball_size, this.game.config.ball_size);
}
else if(ctx instanceof WebGLRenderingContext)
{
renderCube(ctx, this.position_x / 1000, 0, this.position_y / 1000, 0, this.game.config.ball_size, this.game.config.ball_size, this.game.config.ball_size);
}
else
{
alert('Unknown rendering context type (wtf)');
}
} }
/** /**
@ -66,7 +55,7 @@ class Ball
*/ */
render(ctx) render(ctx)
{ {
let distance = this.speed * (this.game.time.deltaTime() / 1000); let distance = this.speed * (this.game.time.deltaTime() / 1000)
this.position.x = this.position.x + distance * Math.cos(this.angle); this.position.x = this.position.x + distance * Math.cos(this.angle);
this.position.y = this.position.y - distance * Math.sin(this.angle); this.position.y = this.position.y - distance * Math.sin(this.angle);
@ -81,7 +70,7 @@ class Ball
this.angle = data.angle; this.angle = data.angle;
this.speed = data.speed; this.speed = data.speed;
return this; return this
} }
} }