Code review 2023-01-10
This commit is contained in:
parent
d748312d66
commit
637a867c7e
9 changed files with 13 additions and 5 deletions
|
|
@ -6,7 +6,7 @@ import {leaderboardRoute} from "./leaderboardRoute.js";
|
|||
import {userRoute} from "./userRoute.js";
|
||||
import {gameRoute} from "./gameRoute.js";
|
||||
|
||||
|
||||
// TODO: Rename variables --> Responsotory + Comments
|
||||
const app = express()
|
||||
const port = 3000
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ userRoute.post(
|
|||
)
|
||||
|
||||
userRoute.get('/:userId/scores',
|
||||
// TODO: With id exists --> cusotm validator
|
||||
param('userId').isInt({min: 1}),
|
||||
async (req, res) => {
|
||||
//region validate parameters
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// TODO: Refactor
|
||||
const pipeImagePath: string = "resources/raspberry-low-res.png";
|
||||
const obstacleWidth: number = 88;
|
||||
let obstacleOffset: number;
|
||||
|
|
@ -33,6 +34,7 @@ function setupGame() {
|
|||
raspberry.image = raspberryImagePath;
|
||||
|
||||
// Create all obstacles
|
||||
// TODO: Loop
|
||||
obstacles = [];
|
||||
obstacles.push(new Obstacle(
|
||||
new Position(width, 0),
|
||||
|
|
@ -57,6 +59,7 @@ function setupGame() {
|
|||
obstacles.forEach((obstacle) => obstacle.randomizeHeight());
|
||||
}
|
||||
|
||||
// TODO: Split into funciton
|
||||
function draw() {
|
||||
background(backgroundImage)
|
||||
if (!paused) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class Obstacle extends Entity implements Collidable {
|
||||
private pipeTop: Pipe;
|
||||
private pipeBottom: Pipe;
|
||||
private readonly distanceBetweenPipes: number;
|
||||
private static distanceBetweenPipes: number;
|
||||
private readonly padding: number = 150;
|
||||
private readonly speed: number = 3;
|
||||
|
||||
|
|
@ -22,7 +22,8 @@ class Obstacle extends Entity implements Collidable {
|
|||
this.pipeTop.image = pipeImagePath;
|
||||
this.pipeBottom.image = pipeImagePath;
|
||||
|
||||
this.distanceBetweenPipes = height / 2.5;
|
||||
Obstacle.distanceBetweenPipes = height / 2.5;
|
||||
//TODO: Put into setupGame()
|
||||
Obstacle.startX = width;
|
||||
}
|
||||
|
||||
|
|
@ -41,9 +42,10 @@ class Obstacle extends Entity implements Collidable {
|
|||
* Randomizes the height of the pipes
|
||||
*/
|
||||
public randomizeHeight(): void {
|
||||
this.pipeTop.height = this.randomRange(this.padding, height - this.padding - this.distanceBetweenPipes);
|
||||
this.pipeTop.height = this.randomRange(this.padding, height - this.padding - Obstacle.distanceBetweenPipes);
|
||||
//TODO: Soi des do sei?
|
||||
this.pipeTop.position.y = 0;
|
||||
this.pipeBottom.position.y = this.pipeTop.height + this.distanceBetweenPipes;
|
||||
this.pipeBottom.position.y = this.pipeTop.height + Obstacle.distanceBetweenPipes;
|
||||
this.pipeBottom.height = height - this.pipeTop.height - this.padding;
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ class Obstacle extends Entity implements Collidable {
|
|||
}
|
||||
|
||||
public update(): void {
|
||||
// TODO: Put into pipe.update
|
||||
this.pipeTop.position.x -= this.speed;
|
||||
this.pipeBottom.position.x -= this.speed;
|
||||
this.position.x = this.pipeTop.position.x;
|
||||
|
|
@ -28,6 +28,7 @@ class Raspberry extends Entity {
|
|||
* Constructs the Raspberry with fixed sizes
|
||||
*/
|
||||
constructor() {
|
||||
// TODO: Move literals to consta
|
||||
super(new Position(width / 6, height / 2), 180, 70, 0);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue