feat: Добавлена функцияя для пересборки отображений кирпичей и удаления оставшихся отображений кирпичей из контейнера при смене уровня
This commit is contained in:
+6
-4
@@ -17,7 +17,7 @@ import { LEVELS } from './const/levels';
|
||||
import { Game } from './game';
|
||||
import { calculateCollision } from './lib/calculateCollision/calculateCollision';
|
||||
import { calculateDirection } from './lib/calculateDirection/calculateDirection';
|
||||
import { createGameView, syncronizeViewsWithGame } from './view';
|
||||
import { createGameView, rebuildBrickViews, syncronizeViewsWithGame } from './view';
|
||||
|
||||
(async () => {
|
||||
// Create a new application
|
||||
@@ -42,17 +42,19 @@ import { createGameView, syncronizeViewsWithGame } from './view';
|
||||
|
||||
const game = new Game(LEVELS);
|
||||
const views = createGameView(game, container);
|
||||
const currentLevel = game.currentLevel;
|
||||
|
||||
container.on('pointermove', (event) => {
|
||||
const localPosition = container.toLocal(event.global);
|
||||
game.paddle.moveTo(localPosition.x, 0, CONTAINER_WIDTH);
|
||||
});
|
||||
|
||||
console.log(game.paddle.x, game.paddle.y);
|
||||
|
||||
app.ticker.add((time) => {
|
||||
game.update(time.deltaTime);
|
||||
|
||||
if (game.currentLevel !== currentLevel) {
|
||||
rebuildBrickViews(views, game, container);
|
||||
}
|
||||
syncronizeViewsWithGame(views, game);
|
||||
console.log(game.paddle.x, game.paddle.y);
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user