From eecd3b55dc1e8fea112080424281b7ba2ce9d891 Mon Sep 17 00:00:00 2001 From: Maksymilian Wojnar Date: Mon, 7 Oct 2024 21:14:12 +0200 Subject: [PATCH 1/4] Zadanie domowe 5.1 --- index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.html b/index.html index a8a3f2b..70d153e 100644 --- a/index.html +++ b/index.html @@ -63,8 +63,10 @@ window.addEventListener('keydown', event => { if (event.key === 'ArrowLeft') { // Jeśli naciśnięto strzałkę w lewo player.vx = -playerSpeed; // Ustaw prędkość gracza na ujemną + player.scale.x = -3; } else if (event.key === 'ArrowRight') { // Jeśli naciśnięto strzałkę w prawo player.vx = playerSpeed; // Ustaw prędkość gracza na dodatnią + player.scale.x = 3; } }); window.addEventListener('keyup', event => { From 8e9939abf645cd7e357f7c28930dcdbc1fdb9f51 Mon Sep 17 00:00:00 2001 From: Maksymilian Wojnar Date: Mon, 7 Oct 2024 21:14:31 +0200 Subject: [PATCH 2/4] Zadanie domowe 5.2 --- index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.html b/index.html index 70d153e..13bdcaa 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,8 @@ let objectScore = 10; let objectSpawnRate = 3000; let objectMinSpawnRate = 400; + let objectSkewSpeed = 1; + let objectMaxSkewSpeed = 6; let app = new PIXI.Application(); // Tworzenie aplikacji PixiJS await app.init({ @@ -92,6 +94,7 @@ let object = PIXI.Sprite.from('obiekt.png'); object.x = Math.random() * (app.canvas.width - object.width - 1); // Losowa pozycja obiektu object.y = -object.height; // Pozycja startowa obiektu poza ekranem + object.vx = Math.random() * objectSkewSpeed - objectSkewSpeed / 2; object.vy = objectSpeed + Math.random(); // Losowa prędkość obiektu object.scale.set(1.2, 1.2); app.stage.addChild(object); @@ -107,6 +110,7 @@ objectSpeed += 0.2; objectScore += 1; objectSpawnRate = Math.max(objectMinSpawnRate, objectSpawnRate - 100); + objectSkewSpeed = Math.min(objectMaxSkewSpeed, objectSkewSpeed + 0.1); updateDifficultyTimeout = setTimeout(updateDifficulty, 5000); } @@ -128,7 +132,13 @@ // Funkcja do aktualizacji pozycji spadających obiektów app.ticker.add(() => { for (let object of objects) { + // Zapobiega wychodzeniu obiektów poza granice + if (object.getBounds().maxX >= app.canvas.width || object.getBounds().minX <= 0) { + object.vx *= -1; // Zmiana kierunku obiektu po odbiciu od ściany + } + object.y += object.vy; + object.x += object.vx; // Detekcja kolizji if (hitTestRectangle(player, object)) { From 09809dce64b014174de03bbd74610f6bd92a47a3 Mon Sep 17 00:00:00 2001 From: Maksymilian Wojnar Date: Mon, 7 Oct 2024 21:14:49 +0200 Subject: [PATCH 3/4] Zadanie domowe 5.3 --- index.html | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 13bdcaa..c63a32e 100644 --- a/index.html +++ b/index.html @@ -21,6 +21,7 @@ \ No newline at end of file From b6dceed448d6d73a9a92d1097231b6725aaf1eb0 Mon Sep 17 00:00:00 2001 From: Maksymilian Wojnar Date: Mon, 7 Oct 2024 21:14:59 +0200 Subject: [PATCH 4/4] Zadanie domowe 5.4 --- index.html | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index c63a32e..bdd7b6d 100644 --- a/index.html +++ b/index.html @@ -20,8 +20,11 @@