From a840990bdcabf45fb0d377478ba0ab27222434ae Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Mon, 23 Dec 2024 18:32:29 +0100 Subject: initial commit --- .gitignore | 1 + .ignore | 1 + assets/ase/boshy.ase | Bin 0 -> 841 bytes assets/music/Ace Combat Megalith.ogg | Bin 0 -> 3047708 bytes assets/music/loludied.ogg | Bin 0 -> 629247 bytes assets/music/terranigma-theunderworld.ogg | Bin 0 -> 493580 bytes assets/sounds/AHHHHHHHHHHHHHHHHHHHHHHHHHHHH.ogg | Bin 0 -> 20751 bytes assets/sounds/Awww.ogg | Bin 0 -> 11267 bytes assets/sounds/BLAAHLouder.ogg | Bin 0 -> 28662 bytes assets/sounds/ItsBOSHYtime.ogg | Bin 0 -> 34405 bytes assets/sounds/Noho (2).ogg | Bin 0 -> 9284 bytes assets/sounds/SF33RD_0014.wav | Bin 0 -> 54338 bytes assets/sounds/SF33RD_0054.wav | Bin 0 -> 75058 bytes assets/sounds/Small_Explosion.ogg | Bin 0 -> 5591 bytes assets/sounds/SoFuckingClose.ogg | Bin 0 -> 15495 bytes assets/sounds/Solgryn_OMNOMNOM.ogg | Bin 0 -> 12389 bytes assets/sounds/Solgryn_roar.ogg | Bin 0 -> 44412 bytes assets/sounds/Solgryn_shoot (2).ogg | Bin 0 -> 5174 bytes assets/sounds/alien bomb explosion 2.ogg | Bin 0 -> 20239 bytes assets/sounds/alien explosion.ogg | Bin 0 -> 24327 bytes assets/sounds/alienbomb explosion.ogg | Bin 0 -> 24565 bytes assets/sounds/hyperbeam.ogg | Bin 0 -> 18400 bytes .../nooooooooooooooooooooooooooooooooo (2).ogg | Bin 0 -> 38339 bytes assets/sounds/shoot.ogg | Bin 0 -> 12424 bytes assets/sounds/slag.ogg | Bin 0 -> 6866 bytes assets/sounds/solgryn_laser.ogg | Bin 0 -> 31572 bytes assets/sounds/solgryn_shielf_hurt.ogg | Bin 0 -> 4532 bytes assets/sounds/splash.ogg | Bin 0 -> 7017 bytes assets/sounds/teleport (2).ogg | Bin 0 -> 7853 bytes assets/sounds/teleport (3).ogg | Bin 0 -> 14903 bytes assets/sprites/bigexplosion1.png | Bin 0 -> 24405 bytes assets/sprites/bigexplosion10.png | Bin 0 -> 64286 bytes assets/sprites/bigexplosion11.png | Bin 0 -> 65197 bytes assets/sprites/bigexplosion12.png | Bin 0 -> 66401 bytes assets/sprites/bigexplosion13.png | Bin 0 -> 67009 bytes assets/sprites/bigexplosion14.png | Bin 0 -> 63085 bytes assets/sprites/bigexplosion15.png | Bin 0 -> 55984 bytes assets/sprites/bigexplosion16.png | Bin 0 -> 50544 bytes assets/sprites/bigexplosion17.png | Bin 0 -> 27150 bytes assets/sprites/bigexplosion18.png | Bin 0 -> 8547 bytes assets/sprites/bigexplosion19.png | Bin 0 -> 1706 bytes assets/sprites/bigexplosion2.png | Bin 0 -> 33743 bytes assets/sprites/bigexplosion3.png | Bin 0 -> 43339 bytes assets/sprites/bigexplosion4.png | Bin 0 -> 50024 bytes assets/sprites/bigexplosion5.png | Bin 0 -> 54689 bytes assets/sprites/bigexplosion6.png | Bin 0 -> 57512 bytes assets/sprites/bigexplosion7.png | Bin 0 -> 59234 bytes assets/sprites/bigexplosion8.png | Bin 0 -> 60422 bytes assets/sprites/bigexplosion9.png | Bin 0 -> 61462 bytes assets/sprites/black_background.png | Bin 0 -> 87884 bytes assets/sprites/black_sun_background.png | Bin 0 -> 206606 bytes assets/sprites/boshy1.png | Bin 0 -> 630 bytes assets/sprites/boshy2.png | Bin 0 -> 658 bytes assets/sprites/boshy_bullet.png | Bin 0 -> 93 bytes assets/sprites/explosion1.png | Bin 0 -> 1679 bytes assets/sprites/explosion2.png | Bin 0 -> 1401 bytes assets/sprites/explosion3.png | Bin 0 -> 744 bytes assets/sprites/nomnomnom1.png | Bin 0 -> 74882 bytes assets/sprites/nomnomnom2.png | Bin 0 -> 91296 bytes assets/sprites/nomnomnom3.png | Bin 0 -> 95511 bytes assets/sprites/oatmeal1.png | Bin 0 -> 1202 bytes assets/sprites/oatmeal2.png | Bin 0 -> 2190 bytes assets/sprites/oatmeal3.png | Bin 0 -> 1861 bytes assets/sprites/openanimation1.png | Bin 0 -> 12482 bytes assets/sprites/openanimation10.png | Bin 0 -> 12141 bytes assets/sprites/openanimation11.png | Bin 0 -> 12146 bytes assets/sprites/openanimation12.png | Bin 0 -> 12057 bytes assets/sprites/openanimation2.png | Bin 0 -> 12482 bytes assets/sprites/openanimation3.png | Bin 0 -> 12411 bytes assets/sprites/openanimation4.png | Bin 0 -> 12411 bytes assets/sprites/openanimation5.png | Bin 0 -> 12420 bytes assets/sprites/openanimation6.png | Bin 0 -> 12319 bytes assets/sprites/openanimation7.png | Bin 0 -> 12322 bytes assets/sprites/openanimation8.png | Bin 0 -> 12220 bytes assets/sprites/openanimation9.png | Bin 0 -> 12226 bytes assets/sprites/portal1.png | Bin 0 -> 31210 bytes assets/sprites/portal10.png | Bin 0 -> 31279 bytes assets/sprites/portal11.png | Bin 0 -> 30283 bytes assets/sprites/portal12.png | Bin 0 -> 30871 bytes assets/sprites/portal13.png | Bin 0 -> 30976 bytes assets/sprites/portal14.png | Bin 0 -> 31080 bytes assets/sprites/portal15.png | Bin 0 -> 30900 bytes assets/sprites/portal2.png | Bin 0 -> 30895 bytes assets/sprites/portal3.png | Bin 0 -> 30623 bytes assets/sprites/portal4.png | Bin 0 -> 31040 bytes assets/sprites/portal5.png | Bin 0 -> 31202 bytes assets/sprites/portal6.png | Bin 0 -> 30913 bytes assets/sprites/portal7.png | Bin 0 -> 31082 bytes assets/sprites/portal8.png | Bin 0 -> 31050 bytes assets/sprites/portal9.png | Bin 0 -> 31021 bytes assets/sprites/shitbullet.png | Bin 0 -> 675 bytes assets/sprites/skylaser1.png | Bin 0 -> 2870 bytes assets/sprites/skylaser2.png | Bin 0 -> 5462 bytes assets/sprites/skylaser3.png | Bin 0 -> 4969 bytes assets/sprites/skylaser4.png | Bin 0 -> 3297 bytes assets/sprites/skylaser5.png | Bin 0 -> 4862 bytes assets/sprites/skylaser6.png | Bin 0 -> 4507 bytes assets/sprites/solgryn.png | Bin 0 -> 154372 bytes assets/sprites/solgryn_fight.png | Bin 0 -> 125709 bytes assets/sprites/solgryn_open1.png | Bin 0 -> 122623 bytes assets/sprites/solgryn_open2.png | Bin 0 -> 119663 bytes assets/sprites/solgryn_open3.png | Bin 0 -> 116000 bytes assets/sprites/solgryn_sun.png | Bin 0 -> 237636 bytes countlines.sh | 10 +++ index.html | 14 ++++ index.js | 32 ++++++++ scss/index.scss | 35 +++++++++ src/assets.js | 22 ++++++ src/engine.js | 34 ++++++++ src/engine/clock.js | 26 ++++++ src/engine/keyboard.js | 23 ++++++ src/engine/screen.js | 87 +++++++++++++++++++++ src/engine/vector.js | 47 +++++++++++ src/entities/boshy.js | 65 +++++++++++++++ src/entities/boshybullet.js | 30 +++++++ src/entities/entity.js | 23 ++++++ src/main.js | 38 +++++++++ src/scenes.js | 30 +++++++ src/scenes/game.js | 13 +++ src/scenes/prequel.js | 13 +++ style.css | 30 +++++++ 121 files changed, 574 insertions(+) create mode 100644 .gitignore create mode 100644 .ignore create mode 100644 assets/ase/boshy.ase create mode 100644 assets/music/Ace Combat Megalith.ogg create mode 100644 assets/music/loludied.ogg create mode 100644 assets/music/terranigma-theunderworld.ogg create mode 100644 assets/sounds/AHHHHHHHHHHHHHHHHHHHHHHHHHHHH.ogg create mode 100644 assets/sounds/Awww.ogg create mode 100644 assets/sounds/BLAAHLouder.ogg create mode 100644 assets/sounds/ItsBOSHYtime.ogg create mode 100644 assets/sounds/Noho (2).ogg create mode 100644 assets/sounds/SF33RD_0014.wav create mode 100644 assets/sounds/SF33RD_0054.wav create mode 100644 assets/sounds/Small_Explosion.ogg create mode 100644 assets/sounds/SoFuckingClose.ogg create mode 100644 assets/sounds/Solgryn_OMNOMNOM.ogg create mode 100644 assets/sounds/Solgryn_roar.ogg create mode 100644 assets/sounds/Solgryn_shoot (2).ogg create mode 100644 assets/sounds/alien bomb explosion 2.ogg create mode 100644 assets/sounds/alien explosion.ogg create mode 100644 assets/sounds/alienbomb explosion.ogg create mode 100644 assets/sounds/hyperbeam.ogg create mode 100644 assets/sounds/nooooooooooooooooooooooooooooooooo (2).ogg create mode 100644 assets/sounds/shoot.ogg create mode 100644 assets/sounds/slag.ogg create mode 100644 assets/sounds/solgryn_laser.ogg create mode 100644 assets/sounds/solgryn_shielf_hurt.ogg create mode 100644 assets/sounds/splash.ogg create mode 100644 assets/sounds/teleport (2).ogg create mode 100644 assets/sounds/teleport (3).ogg create mode 100644 assets/sprites/bigexplosion1.png create mode 100644 assets/sprites/bigexplosion10.png create mode 100644 assets/sprites/bigexplosion11.png create mode 100644 assets/sprites/bigexplosion12.png create mode 100644 assets/sprites/bigexplosion13.png create mode 100644 assets/sprites/bigexplosion14.png create mode 100644 assets/sprites/bigexplosion15.png create mode 100644 assets/sprites/bigexplosion16.png create mode 100644 assets/sprites/bigexplosion17.png create mode 100644 assets/sprites/bigexplosion18.png create mode 100644 assets/sprites/bigexplosion19.png create mode 100644 assets/sprites/bigexplosion2.png create mode 100644 assets/sprites/bigexplosion3.png create mode 100644 assets/sprites/bigexplosion4.png create mode 100644 assets/sprites/bigexplosion5.png create mode 100644 assets/sprites/bigexplosion6.png create mode 100644 assets/sprites/bigexplosion7.png create mode 100644 assets/sprites/bigexplosion8.png create mode 100644 assets/sprites/bigexplosion9.png create mode 100644 assets/sprites/black_background.png create mode 100644 assets/sprites/black_sun_background.png create mode 100644 assets/sprites/boshy1.png create mode 100644 assets/sprites/boshy2.png create mode 100644 assets/sprites/boshy_bullet.png create mode 100644 assets/sprites/explosion1.png create mode 100644 assets/sprites/explosion2.png create mode 100644 assets/sprites/explosion3.png create mode 100644 assets/sprites/nomnomnom1.png create mode 100644 assets/sprites/nomnomnom2.png create mode 100644 assets/sprites/nomnomnom3.png create mode 100644 assets/sprites/oatmeal1.png create mode 100644 assets/sprites/oatmeal2.png create mode 100644 assets/sprites/oatmeal3.png create mode 100644 assets/sprites/openanimation1.png create mode 100644 assets/sprites/openanimation10.png create mode 100644 assets/sprites/openanimation11.png create mode 100644 assets/sprites/openanimation12.png create mode 100644 assets/sprites/openanimation2.png create mode 100644 assets/sprites/openanimation3.png create mode 100644 assets/sprites/openanimation4.png create mode 100644 assets/sprites/openanimation5.png create mode 100644 assets/sprites/openanimation6.png create mode 100644 assets/sprites/openanimation7.png create mode 100644 assets/sprites/openanimation8.png create mode 100644 assets/sprites/openanimation9.png create mode 100644 assets/sprites/portal1.png create mode 100644 assets/sprites/portal10.png create mode 100644 assets/sprites/portal11.png create mode 100644 assets/sprites/portal12.png create mode 100644 assets/sprites/portal13.png create mode 100644 assets/sprites/portal14.png create mode 100644 assets/sprites/portal15.png create mode 100644 assets/sprites/portal2.png create mode 100644 assets/sprites/portal3.png create mode 100644 assets/sprites/portal4.png create mode 100644 assets/sprites/portal5.png create mode 100644 assets/sprites/portal6.png create mode 100644 assets/sprites/portal7.png create mode 100644 assets/sprites/portal8.png create mode 100644 assets/sprites/portal9.png create mode 100644 assets/sprites/shitbullet.png create mode 100644 assets/sprites/skylaser1.png create mode 100644 assets/sprites/skylaser2.png create mode 100644 assets/sprites/skylaser3.png create mode 100644 assets/sprites/skylaser4.png create mode 100644 assets/sprites/skylaser5.png create mode 100644 assets/sprites/skylaser6.png create mode 100644 assets/sprites/solgryn.png create mode 100644 assets/sprites/solgryn_fight.png create mode 100644 assets/sprites/solgryn_open1.png create mode 100644 assets/sprites/solgryn_open2.png create mode 100644 assets/sprites/solgryn_open3.png create mode 100644 assets/sprites/solgryn_sun.png create mode 100755 countlines.sh create mode 100644 index.html create mode 100644 index.js create mode 100644 scss/index.scss create mode 100644 src/assets.js create mode 100644 src/engine.js create mode 100644 src/engine/clock.js create mode 100644 src/engine/keyboard.js create mode 100644 src/engine/screen.js create mode 100644 src/engine/vector.js create mode 100644 src/entities/boshy.js create mode 100644 src/entities/boshybullet.js create mode 100644 src/entities/entity.js create mode 100644 src/main.js create mode 100644 src/scenes.js create mode 100644 src/scenes/game.js create mode 100644 src/scenes/prequel.js create mode 100644 style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09c2dff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +BOSHY\ FILES/* diff --git a/.ignore b/.ignore new file mode 100644 index 0000000..09c2dff --- /dev/null +++ b/.ignore @@ -0,0 +1 @@ +BOSHY\ FILES/* diff --git a/assets/ase/boshy.ase b/assets/ase/boshy.ase new file mode 100644 index 0000000..c751512 Binary files /dev/null and b/assets/ase/boshy.ase differ diff --git a/assets/music/Ace Combat Megalith.ogg b/assets/music/Ace Combat Megalith.ogg new file mode 100644 index 0000000..e7302a5 Binary files /dev/null and b/assets/music/Ace Combat Megalith.ogg differ diff --git a/assets/music/loludied.ogg b/assets/music/loludied.ogg new file mode 100644 index 0000000..e6b82ec Binary files /dev/null and b/assets/music/loludied.ogg differ diff --git a/assets/music/terranigma-theunderworld.ogg b/assets/music/terranigma-theunderworld.ogg new file mode 100644 index 0000000..92504ca Binary files /dev/null and b/assets/music/terranigma-theunderworld.ogg differ diff --git a/assets/sounds/AHHHHHHHHHHHHHHHHHHHHHHHHHHHH.ogg b/assets/sounds/AHHHHHHHHHHHHHHHHHHHHHHHHHHHH.ogg new file mode 100644 index 0000000..a6628f3 Binary files /dev/null and b/assets/sounds/AHHHHHHHHHHHHHHHHHHHHHHHHHHHH.ogg differ diff --git a/assets/sounds/Awww.ogg b/assets/sounds/Awww.ogg new file mode 100644 index 0000000..72ae355 Binary files /dev/null and b/assets/sounds/Awww.ogg differ diff --git a/assets/sounds/BLAAHLouder.ogg b/assets/sounds/BLAAHLouder.ogg new file mode 100644 index 0000000..6169d4f Binary files /dev/null and b/assets/sounds/BLAAHLouder.ogg differ diff --git a/assets/sounds/ItsBOSHYtime.ogg b/assets/sounds/ItsBOSHYtime.ogg new file mode 100644 index 0000000..af80104 Binary files /dev/null and b/assets/sounds/ItsBOSHYtime.ogg differ diff --git a/assets/sounds/Noho (2).ogg b/assets/sounds/Noho (2).ogg new file mode 100644 index 0000000..e949793 Binary files /dev/null and b/assets/sounds/Noho (2).ogg differ diff --git a/assets/sounds/SF33RD_0014.wav b/assets/sounds/SF33RD_0014.wav new file mode 100644 index 0000000..f917a0d Binary files /dev/null and b/assets/sounds/SF33RD_0014.wav differ diff --git a/assets/sounds/SF33RD_0054.wav b/assets/sounds/SF33RD_0054.wav new file mode 100644 index 0000000..ab1926a Binary files /dev/null and b/assets/sounds/SF33RD_0054.wav differ diff --git a/assets/sounds/Small_Explosion.ogg b/assets/sounds/Small_Explosion.ogg new file mode 100644 index 0000000..ae3d702 Binary files /dev/null and b/assets/sounds/Small_Explosion.ogg differ diff --git a/assets/sounds/SoFuckingClose.ogg b/assets/sounds/SoFuckingClose.ogg new file mode 100644 index 0000000..e53ee6e Binary files /dev/null and b/assets/sounds/SoFuckingClose.ogg differ diff --git a/assets/sounds/Solgryn_OMNOMNOM.ogg b/assets/sounds/Solgryn_OMNOMNOM.ogg new file mode 100644 index 0000000..80584e5 Binary files /dev/null and b/assets/sounds/Solgryn_OMNOMNOM.ogg differ diff --git a/assets/sounds/Solgryn_roar.ogg b/assets/sounds/Solgryn_roar.ogg new file mode 100644 index 0000000..bd0631f Binary files /dev/null and b/assets/sounds/Solgryn_roar.ogg differ diff --git a/assets/sounds/Solgryn_shoot (2).ogg b/assets/sounds/Solgryn_shoot (2).ogg new file mode 100644 index 0000000..0d530a8 Binary files /dev/null and b/assets/sounds/Solgryn_shoot (2).ogg differ diff --git a/assets/sounds/alien bomb explosion 2.ogg b/assets/sounds/alien bomb explosion 2.ogg new file mode 100644 index 0000000..4a10eda Binary files /dev/null and b/assets/sounds/alien bomb explosion 2.ogg differ diff --git a/assets/sounds/alien explosion.ogg b/assets/sounds/alien explosion.ogg new file mode 100644 index 0000000..d4c0006 Binary files /dev/null and b/assets/sounds/alien explosion.ogg differ diff --git a/assets/sounds/alienbomb explosion.ogg b/assets/sounds/alienbomb explosion.ogg new file mode 100644 index 0000000..02ef2b1 Binary files /dev/null and b/assets/sounds/alienbomb explosion.ogg differ diff --git a/assets/sounds/hyperbeam.ogg b/assets/sounds/hyperbeam.ogg new file mode 100644 index 0000000..791933b Binary files /dev/null and b/assets/sounds/hyperbeam.ogg differ diff --git a/assets/sounds/nooooooooooooooooooooooooooooooooo (2).ogg b/assets/sounds/nooooooooooooooooooooooooooooooooo (2).ogg new file mode 100644 index 0000000..e19df63 Binary files /dev/null and b/assets/sounds/nooooooooooooooooooooooooooooooooo (2).ogg differ diff --git a/assets/sounds/shoot.ogg b/assets/sounds/shoot.ogg new file mode 100644 index 0000000..e52845d Binary files /dev/null and b/assets/sounds/shoot.ogg differ diff --git a/assets/sounds/slag.ogg b/assets/sounds/slag.ogg new file mode 100644 index 0000000..f1ce2db Binary files /dev/null and b/assets/sounds/slag.ogg differ diff --git a/assets/sounds/solgryn_laser.ogg b/assets/sounds/solgryn_laser.ogg new file mode 100644 index 0000000..1bc6825 Binary files /dev/null and b/assets/sounds/solgryn_laser.ogg differ diff --git a/assets/sounds/solgryn_shielf_hurt.ogg b/assets/sounds/solgryn_shielf_hurt.ogg new file mode 100644 index 0000000..baf0f4c Binary files /dev/null and b/assets/sounds/solgryn_shielf_hurt.ogg differ diff --git a/assets/sounds/splash.ogg b/assets/sounds/splash.ogg new file mode 100644 index 0000000..d27a941 Binary files /dev/null and b/assets/sounds/splash.ogg differ diff --git a/assets/sounds/teleport (2).ogg b/assets/sounds/teleport (2).ogg new file mode 100644 index 0000000..1655d65 Binary files /dev/null and b/assets/sounds/teleport (2).ogg differ diff --git a/assets/sounds/teleport (3).ogg b/assets/sounds/teleport (3).ogg new file mode 100644 index 0000000..c1b69b1 Binary files /dev/null and b/assets/sounds/teleport (3).ogg differ diff --git a/assets/sprites/bigexplosion1.png b/assets/sprites/bigexplosion1.png new file mode 100644 index 0000000..947d00a Binary files /dev/null and b/assets/sprites/bigexplosion1.png differ diff --git a/assets/sprites/bigexplosion10.png b/assets/sprites/bigexplosion10.png new file mode 100644 index 0000000..ff2322d Binary files /dev/null and b/assets/sprites/bigexplosion10.png differ diff --git a/assets/sprites/bigexplosion11.png b/assets/sprites/bigexplosion11.png new file mode 100644 index 0000000..dc7abe4 Binary files /dev/null and b/assets/sprites/bigexplosion11.png differ diff --git a/assets/sprites/bigexplosion12.png b/assets/sprites/bigexplosion12.png new file mode 100644 index 0000000..1b0bf12 Binary files /dev/null and b/assets/sprites/bigexplosion12.png differ diff --git a/assets/sprites/bigexplosion13.png b/assets/sprites/bigexplosion13.png new file mode 100644 index 0000000..3925601 Binary files /dev/null and b/assets/sprites/bigexplosion13.png differ diff --git a/assets/sprites/bigexplosion14.png b/assets/sprites/bigexplosion14.png new file mode 100644 index 0000000..96ded1c Binary files /dev/null and b/assets/sprites/bigexplosion14.png differ diff --git a/assets/sprites/bigexplosion15.png b/assets/sprites/bigexplosion15.png new file mode 100644 index 0000000..f1780c3 Binary files /dev/null and b/assets/sprites/bigexplosion15.png differ diff --git a/assets/sprites/bigexplosion16.png b/assets/sprites/bigexplosion16.png new file mode 100644 index 0000000..7160306 Binary files /dev/null and b/assets/sprites/bigexplosion16.png differ diff --git a/assets/sprites/bigexplosion17.png b/assets/sprites/bigexplosion17.png new file mode 100644 index 0000000..6442f68 Binary files /dev/null and b/assets/sprites/bigexplosion17.png differ diff --git a/assets/sprites/bigexplosion18.png b/assets/sprites/bigexplosion18.png new file mode 100644 index 0000000..337e3e3 Binary files /dev/null and b/assets/sprites/bigexplosion18.png differ diff --git a/assets/sprites/bigexplosion19.png b/assets/sprites/bigexplosion19.png new file mode 100644 index 0000000..c852418 Binary files /dev/null and b/assets/sprites/bigexplosion19.png differ diff --git a/assets/sprites/bigexplosion2.png b/assets/sprites/bigexplosion2.png new file mode 100644 index 0000000..182bc65 Binary files /dev/null and b/assets/sprites/bigexplosion2.png differ diff --git a/assets/sprites/bigexplosion3.png b/assets/sprites/bigexplosion3.png new file mode 100644 index 0000000..97d1cb0 Binary files /dev/null and b/assets/sprites/bigexplosion3.png differ diff --git a/assets/sprites/bigexplosion4.png b/assets/sprites/bigexplosion4.png new file mode 100644 index 0000000..0018213 Binary files /dev/null and b/assets/sprites/bigexplosion4.png differ diff --git a/assets/sprites/bigexplosion5.png b/assets/sprites/bigexplosion5.png new file mode 100644 index 0000000..ead38f3 Binary files /dev/null and b/assets/sprites/bigexplosion5.png differ diff --git a/assets/sprites/bigexplosion6.png b/assets/sprites/bigexplosion6.png new file mode 100644 index 0000000..41bf524 Binary files /dev/null and b/assets/sprites/bigexplosion6.png differ diff --git a/assets/sprites/bigexplosion7.png b/assets/sprites/bigexplosion7.png new file mode 100644 index 0000000..1302e55 Binary files /dev/null and b/assets/sprites/bigexplosion7.png differ diff --git a/assets/sprites/bigexplosion8.png b/assets/sprites/bigexplosion8.png new file mode 100644 index 0000000..f0f07c7 Binary files /dev/null and b/assets/sprites/bigexplosion8.png differ diff --git a/assets/sprites/bigexplosion9.png b/assets/sprites/bigexplosion9.png new file mode 100644 index 0000000..9c6cb34 Binary files /dev/null and b/assets/sprites/bigexplosion9.png differ diff --git a/assets/sprites/black_background.png b/assets/sprites/black_background.png new file mode 100644 index 0000000..7926ec7 Binary files /dev/null and b/assets/sprites/black_background.png differ diff --git a/assets/sprites/black_sun_background.png b/assets/sprites/black_sun_background.png new file mode 100644 index 0000000..62fb81c Binary files /dev/null and b/assets/sprites/black_sun_background.png differ diff --git a/assets/sprites/boshy1.png b/assets/sprites/boshy1.png new file mode 100644 index 0000000..dd1a996 Binary files /dev/null and b/assets/sprites/boshy1.png differ diff --git a/assets/sprites/boshy2.png b/assets/sprites/boshy2.png new file mode 100644 index 0000000..cdc24c0 Binary files /dev/null and b/assets/sprites/boshy2.png differ diff --git a/assets/sprites/boshy_bullet.png b/assets/sprites/boshy_bullet.png new file mode 100644 index 0000000..95b89b3 Binary files /dev/null and b/assets/sprites/boshy_bullet.png differ diff --git a/assets/sprites/explosion1.png b/assets/sprites/explosion1.png new file mode 100644 index 0000000..4164985 Binary files /dev/null and b/assets/sprites/explosion1.png differ diff --git a/assets/sprites/explosion2.png b/assets/sprites/explosion2.png new file mode 100644 index 0000000..7d1e6b1 Binary files /dev/null and b/assets/sprites/explosion2.png differ diff --git a/assets/sprites/explosion3.png b/assets/sprites/explosion3.png new file mode 100644 index 0000000..9552877 Binary files /dev/null and b/assets/sprites/explosion3.png differ diff --git a/assets/sprites/nomnomnom1.png b/assets/sprites/nomnomnom1.png new file mode 100644 index 0000000..50781a1 Binary files /dev/null and b/assets/sprites/nomnomnom1.png differ diff --git a/assets/sprites/nomnomnom2.png b/assets/sprites/nomnomnom2.png new file mode 100644 index 0000000..2d5f5b7 Binary files /dev/null and b/assets/sprites/nomnomnom2.png differ diff --git a/assets/sprites/nomnomnom3.png b/assets/sprites/nomnomnom3.png new file mode 100644 index 0000000..a526060 Binary files /dev/null and b/assets/sprites/nomnomnom3.png differ diff --git a/assets/sprites/oatmeal1.png b/assets/sprites/oatmeal1.png new file mode 100644 index 0000000..0a088a2 Binary files /dev/null and b/assets/sprites/oatmeal1.png differ diff --git a/assets/sprites/oatmeal2.png b/assets/sprites/oatmeal2.png new file mode 100644 index 0000000..9c1f340 Binary files /dev/null and b/assets/sprites/oatmeal2.png differ diff --git a/assets/sprites/oatmeal3.png b/assets/sprites/oatmeal3.png new file mode 100644 index 0000000..c633671 Binary files /dev/null and b/assets/sprites/oatmeal3.png differ diff --git a/assets/sprites/openanimation1.png b/assets/sprites/openanimation1.png new file mode 100644 index 0000000..d9a9d07 Binary files /dev/null and b/assets/sprites/openanimation1.png differ diff --git a/assets/sprites/openanimation10.png b/assets/sprites/openanimation10.png new file mode 100644 index 0000000..4623096 Binary files /dev/null and b/assets/sprites/openanimation10.png differ diff --git a/assets/sprites/openanimation11.png b/assets/sprites/openanimation11.png new file mode 100644 index 0000000..f83602c Binary files /dev/null and b/assets/sprites/openanimation11.png differ diff --git a/assets/sprites/openanimation12.png b/assets/sprites/openanimation12.png new file mode 100644 index 0000000..f474274 Binary files /dev/null and b/assets/sprites/openanimation12.png differ diff --git a/assets/sprites/openanimation2.png b/assets/sprites/openanimation2.png new file mode 100644 index 0000000..ec233db Binary files /dev/null and b/assets/sprites/openanimation2.png differ diff --git a/assets/sprites/openanimation3.png b/assets/sprites/openanimation3.png new file mode 100644 index 0000000..75afbdc Binary files /dev/null and b/assets/sprites/openanimation3.png differ diff --git a/assets/sprites/openanimation4.png b/assets/sprites/openanimation4.png new file mode 100644 index 0000000..a811db2 Binary files /dev/null and b/assets/sprites/openanimation4.png differ diff --git a/assets/sprites/openanimation5.png b/assets/sprites/openanimation5.png new file mode 100644 index 0000000..c901040 Binary files /dev/null and b/assets/sprites/openanimation5.png differ diff --git a/assets/sprites/openanimation6.png b/assets/sprites/openanimation6.png new file mode 100644 index 0000000..442a798 Binary files /dev/null and b/assets/sprites/openanimation6.png differ diff --git a/assets/sprites/openanimation7.png b/assets/sprites/openanimation7.png new file mode 100644 index 0000000..dccaba0 Binary files /dev/null and b/assets/sprites/openanimation7.png differ diff --git a/assets/sprites/openanimation8.png b/assets/sprites/openanimation8.png new file mode 100644 index 0000000..b7bf1bc Binary files /dev/null and b/assets/sprites/openanimation8.png differ diff --git a/assets/sprites/openanimation9.png b/assets/sprites/openanimation9.png new file mode 100644 index 0000000..a415644 Binary files /dev/null and b/assets/sprites/openanimation9.png differ diff --git a/assets/sprites/portal1.png b/assets/sprites/portal1.png new file mode 100644 index 0000000..9456860 Binary files /dev/null and b/assets/sprites/portal1.png differ diff --git a/assets/sprites/portal10.png b/assets/sprites/portal10.png new file mode 100644 index 0000000..993d73f Binary files /dev/null and b/assets/sprites/portal10.png differ diff --git a/assets/sprites/portal11.png b/assets/sprites/portal11.png new file mode 100644 index 0000000..d6eab7e Binary files /dev/null and b/assets/sprites/portal11.png differ diff --git a/assets/sprites/portal12.png b/assets/sprites/portal12.png new file mode 100644 index 0000000..f72177d Binary files /dev/null and b/assets/sprites/portal12.png differ diff --git a/assets/sprites/portal13.png b/assets/sprites/portal13.png new file mode 100644 index 0000000..019ac21 Binary files /dev/null and b/assets/sprites/portal13.png differ diff --git a/assets/sprites/portal14.png b/assets/sprites/portal14.png new file mode 100644 index 0000000..349725e Binary files /dev/null and b/assets/sprites/portal14.png differ diff --git a/assets/sprites/portal15.png b/assets/sprites/portal15.png new file mode 100644 index 0000000..bedc9c3 Binary files /dev/null and b/assets/sprites/portal15.png differ diff --git a/assets/sprites/portal2.png b/assets/sprites/portal2.png new file mode 100644 index 0000000..2767264 Binary files /dev/null and b/assets/sprites/portal2.png differ diff --git a/assets/sprites/portal3.png b/assets/sprites/portal3.png new file mode 100644 index 0000000..3004d0a Binary files /dev/null and b/assets/sprites/portal3.png differ diff --git a/assets/sprites/portal4.png b/assets/sprites/portal4.png new file mode 100644 index 0000000..49a03d1 Binary files /dev/null and b/assets/sprites/portal4.png differ diff --git a/assets/sprites/portal5.png b/assets/sprites/portal5.png new file mode 100644 index 0000000..5d8b082 Binary files /dev/null and b/assets/sprites/portal5.png differ diff --git a/assets/sprites/portal6.png b/assets/sprites/portal6.png new file mode 100644 index 0000000..2fda26f Binary files /dev/null and b/assets/sprites/portal6.png differ diff --git a/assets/sprites/portal7.png b/assets/sprites/portal7.png new file mode 100644 index 0000000..33ead33 Binary files /dev/null and b/assets/sprites/portal7.png differ diff --git a/assets/sprites/portal8.png b/assets/sprites/portal8.png new file mode 100644 index 0000000..c13e185 Binary files /dev/null and b/assets/sprites/portal8.png differ diff --git a/assets/sprites/portal9.png b/assets/sprites/portal9.png new file mode 100644 index 0000000..ca463cf Binary files /dev/null and b/assets/sprites/portal9.png differ diff --git a/assets/sprites/shitbullet.png b/assets/sprites/shitbullet.png new file mode 100644 index 0000000..d53a4cf Binary files /dev/null and b/assets/sprites/shitbullet.png differ diff --git a/assets/sprites/skylaser1.png b/assets/sprites/skylaser1.png new file mode 100644 index 0000000..762cd21 Binary files /dev/null and b/assets/sprites/skylaser1.png differ diff --git a/assets/sprites/skylaser2.png b/assets/sprites/skylaser2.png new file mode 100644 index 0000000..65421e8 Binary files /dev/null and b/assets/sprites/skylaser2.png differ diff --git a/assets/sprites/skylaser3.png b/assets/sprites/skylaser3.png new file mode 100644 index 0000000..eb55807 Binary files /dev/null and b/assets/sprites/skylaser3.png differ diff --git a/assets/sprites/skylaser4.png b/assets/sprites/skylaser4.png new file mode 100644 index 0000000..f02bdb6 Binary files /dev/null and b/assets/sprites/skylaser4.png differ diff --git a/assets/sprites/skylaser5.png b/assets/sprites/skylaser5.png new file mode 100644 index 0000000..aec41ff Binary files /dev/null and b/assets/sprites/skylaser5.png differ diff --git a/assets/sprites/skylaser6.png b/assets/sprites/skylaser6.png new file mode 100644 index 0000000..3b87e39 Binary files /dev/null and b/assets/sprites/skylaser6.png differ diff --git a/assets/sprites/solgryn.png b/assets/sprites/solgryn.png new file mode 100644 index 0000000..0071230 Binary files /dev/null and b/assets/sprites/solgryn.png differ diff --git a/assets/sprites/solgryn_fight.png b/assets/sprites/solgryn_fight.png new file mode 100644 index 0000000..b169e07 Binary files /dev/null and b/assets/sprites/solgryn_fight.png differ diff --git a/assets/sprites/solgryn_open1.png b/assets/sprites/solgryn_open1.png new file mode 100644 index 0000000..f01d25a Binary files /dev/null and b/assets/sprites/solgryn_open1.png differ diff --git a/assets/sprites/solgryn_open2.png b/assets/sprites/solgryn_open2.png new file mode 100644 index 0000000..c77a14f Binary files /dev/null and b/assets/sprites/solgryn_open2.png differ diff --git a/assets/sprites/solgryn_open3.png b/assets/sprites/solgryn_open3.png new file mode 100644 index 0000000..ec27484 Binary files /dev/null and b/assets/sprites/solgryn_open3.png differ diff --git a/assets/sprites/solgryn_sun.png b/assets/sprites/solgryn_sun.png new file mode 100644 index 0000000..6fa73ac Binary files /dev/null and b/assets/sprites/solgryn_sun.png differ diff --git a/countlines.sh b/countlines.sh new file mode 100755 index 0000000..62858f9 --- /dev/null +++ b/countlines.sh @@ -0,0 +1,10 @@ +#!/usr/bin/bash +echo " +js lines of code: " +find . -name '*.js' | xargs wc -l + +echo " +scss lines of code: " +find . -name '*.scss' | xargs wc -l + +echo "" diff --git a/index.html b/index.html new file mode 100644 index 0000000..0597f29 --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..e43c3f2 --- /dev/null +++ b/index.js @@ -0,0 +1,32 @@ +import { Engine } from "./src/engine.js" +Engine.startEngine() + +// import { start, update, draw } from "./src/main.js"; +// const fps = 60 +// +// +// /* cap the game's fps */ +// let msPrev = window.performance.now() +// const msPerFrame = 1000 / fps +// let frames = 0 +// function gameloop() { +// window.requestAnimationFrame(gameloop) +// +// const msNow = window.performance.now() +// const msPassed = msNow - msPrev +// +// if (msPassed < msPerFrame) return +// +// const excessTime = msPassed % msPerFrame +// msPrev = msNow - excessTime +// +// frames++ +// +// update() +// draw() +// } +// +// /* call functions to start the game */ +// /* the game logic can be found in src */ +// start() +// gameloop() diff --git a/scss/index.scss b/scss/index.scss new file mode 100644 index 0000000..177f5fd --- /dev/null +++ b/scss/index.scss @@ -0,0 +1,35 @@ +body { + margin: 0; + background-color: grey; + width: 100%; + height: 100%; +} + +img { + position: absolute; + top: 0; + left: 0; +} + +.background { + width: 100%; + height: 100%; +} + +#spawn { + position: relative; + top: 0; + left: 0; + width: 0; + height: 0; +} + +#screen { + display: block; + overflow: hidden; + background-size: cover; + position: absolute; + top: 0; + left: 0; +} + diff --git a/src/assets.js b/src/assets.js new file mode 100644 index 0000000..4a51716 --- /dev/null +++ b/src/assets.js @@ -0,0 +1,22 @@ +export const BOSHY = { + NORMAL: "./assets/sprites/boshy1.png", + DAMAGED:"./assets/sprites/boshy2.png", + BULLET: "./assets/sprites/boshy_bullet.png", + + SOUNDS: { + SHOOT: "./assets/sounds/shoot.ogg", + INTRO: "./assets/sounds/ItsBOSHYtime.ogg", + } +} + +export const BACKGROUND = { + DEFAULT: "./assets/sprites/black_background.png", + DARK_SUN: "./assets/sprites/black_sun_background.png", +} + +export const MUSIC = { + SOLGRYN: './assets/music/Ace Combat Megalith.ogg', + DEATH: './assets/music/loludied.ogg', + PREQUEL: './assets/music/terranigma-theunderworld.ogg', + +} diff --git a/src/engine.js b/src/engine.js new file mode 100644 index 0000000..a7bb8a5 --- /dev/null +++ b/src/engine.js @@ -0,0 +1,34 @@ +import { start, update, draw } from "./main.js" +import { Screen } from "./engine/screen.js" +import { keys, setUpKeyboard } from "./engine/keyboard.js" +import { startClock } from "./engine/clock.js" + +export class Engine { + static frame = 0 + static audio + static screen = new Screen() + static keys = keys + static bgm + + static startEngine() { + setUpKeyboard() + start() + + startClock() + } + + static updateEngine() { + update() + draw() + } + + static playSound(file) { + let audio = new Audio(file) + audio.play() + } + + static playMusic(file) { + this.bgm = new Audio(file) + this.bgm.play() + } +} diff --git a/src/engine/clock.js b/src/engine/clock.js new file mode 100644 index 0000000..e817863 --- /dev/null +++ b/src/engine/clock.js @@ -0,0 +1,26 @@ +import { Engine } from "../engine.js" + +export { Engine } from "../engine.js" +const fps = 60 + +/* cap the game's fps */ +let msPrev = window.performance.now() +const msPerFrame = 1000 / fps +function tick() { + window.requestAnimationFrame(tick) + + const msNow = window.performance.now() + const msPassed = msNow - msPrev + + if (msPassed < msPerFrame) return + + const excessTime = msPassed % msPerFrame + msPrev = msNow - excessTime + + Engine.frame++ + Engine.updateEngine() +} + +export function startClock() { + tick() +} diff --git a/src/engine/keyboard.js b/src/engine/keyboard.js new file mode 100644 index 0000000..d634519 --- /dev/null +++ b/src/engine/keyboard.js @@ -0,0 +1,23 @@ +export function setUpKeyboard() { + document.addEventListener("keyup", k => trigger(k)) + document.addEventListener("keydown", k => trigger(k)) +} + +export const keys = { + right: false, + left: false, + up: false, + down: false, + shoot: false, +} + +function trigger(event) { + let on = event.type == "keydown" + switch (event.key) { + case "ArrowRight": keys.right = on; break; + case "ArrowLeft": keys.left = on; break; + case "ArrowUp": keys.up = on; break; + case "ArrowDown": keys.down = on; break; + case "z": case "Z": keys.shoot = on; break; + } +} diff --git a/src/engine/screen.js b/src/engine/screen.js new file mode 100644 index 0000000..2d32b62 --- /dev/null +++ b/src/engine/screen.js @@ -0,0 +1,87 @@ +import { Vector } from "./vector.js" +import { BACKGROUND } from "../assets.js" + +export class Screen { + viewport = new Vector(650, 500) + + ///////////////////// START ////////////////////// + constructor() { + this.createHTMLElements() + this.setUpTriggers() + this.resize() + } + + createHTMLElements() { + this.div + this.background + this.spawn + + /* create main div */ + this.div = document.createElement("div") + this.div.id = "screen" + this.div.style.backgroundColor = "black" + + /* create background image */ + this.background = document.createElement("img") + this.background.className = "background" + this.background.src = `${BACKGROUND.DEFAULT}` + this.background.style.visibility = "hidden" + this.div.appendChild(this.background) + + /* create relative div to append children */ + this.spawn = document.createElement("div") + this.div.appendChild(this.spawn) + document.body.appendChild(this.div) + } + + setUpTriggers() { + addEventListener("resize", () => { this.resize() }); + } + + + ///////////////////// RESIZE ////////////////////// + real_position = new Vector(0, 0) + real_size = new Vector(0, 0) + scale = new Vector(0, 0) + + resize() { + let w = new Vector(window.innerWidth, window.innerHeight) + + /* get max size keeping aspect ratio */ + if (w.y / this.viewport.y > w.x / this.viewport.x) { + this.real_size.x = w.x + this.real_size.y = Math.floor(w.x / this.viewport.x * this.viewport.y) + } else { + this.real_size.y = w.y + this.real_size.x = Math.floor(w.y / this.viewport.y * this.viewport.x) + } + this.div.style.width = `${this.real_size.x}px` + this.div.style.height = `${this.real_size.y}px` + + /* get centered position */ + this.real_position.x = w.x / 2 - this.real_size.x / 2 + this.real_position.y = w.y / 2 - this.real_size.y / 2 + this.real_position.floor() + + this.div.style.left = `${this.real_position.x}px` + this.div.style.top = `${this.real_position.y}px` + + /* set scale */ + this.scale = this.real_size.x / this.viewport.x + } + + + ///////////////////// COMMANDS ////////////////////// + append(element) { this.spawn.appendChild(element) } + + draw(span, position, size, /* rotation = 0 */) { + span.style.width = `${size.x * this.scale}px` + span.style.height = `${size.y * this.scale}px` + span.style.top = `${(position.y - size.x / 2) * this.scale}px` + span.style.left = `${(position.x - size.y / 2) * this.scale}px` + } + + setBackground(img) { this.background.src = img } + showBackground() { this.background.visibility = "visible" } + hideBackground() { this.background.visibility = "hidden" } +} diff --git a/src/engine/vector.js b/src/engine/vector.js new file mode 100644 index 0000000..452e47b --- /dev/null +++ b/src/engine/vector.js @@ -0,0 +1,47 @@ +export class Vector { + constructor(x=0, y=0) { + this.x = x + this.y = y + } + + add(newVector) { + this.x += newVector.x + this.y += newVector.y + return this + } + + normalize() { + if (this.x != 0 && 0 != this.y) { + let hyp = Math.abs(this.x) + let cSquared = Math.pow(hyp, 2) / 2 + let c = Math.sqrt(cSquared, 2) + + this.x = this.x / Math.abs(this.x) * c + this.y = this.y / Math.abs(this.x) * c + } + return this + } + + multiply(multiplier) { + this.x *= multiplier + this.y *= multiplier + return this + } + + clone() { + return new Vector(this.x, this.y) + } + + static division(vector_a, vector_b) { + return new Vector( + vector_a.x / vector_b.x, + vector_a.y / vector_b.y + ) + } + + floor() { + this.x = Math.floor(this.x) + this.y = Math.floor(this.y) + return this + } +} diff --git a/src/entities/boshy.js b/src/entities/boshy.js new file mode 100644 index 0000000..ea6068d --- /dev/null +++ b/src/entities/boshy.js @@ -0,0 +1,65 @@ +import { BOSHY } from "../assets.js" +import { Vector } from "../engine/vector.js" +import { Engine } from "../engine.js" +import { BoshyBullet } from "./boshybullet.js" +import { Entity } from "./entity.js" + +export class Boshy extends Entity { + reloadTime = 6 + lastShot = 0 + speed = 5 + + constructor() { + super({ + size: new Vector(30, 30), + position: new Vector(325, 400), + sprite: BOSHY.NORMAL, + }) + + Engine.playSound(BOSHY.SOUNDS.INTRO) + } + + update() { + let keys = Engine.keys + let viewport = Engine.screen.viewport + + /* get movement direction */ + let move = new Vector() + let speed = this.speed + if (keys.right) move.x += 1 + if (keys.left) move.x -= 1 + if (keys.up) move.y -= 1 + if (keys.down) move.y += 1 + if (keys.shoot) this.shoot() + + /* apply movement */ + move.normalize() + move.multiply(speed) + this.position.add(move) + + /* check limits */ + if (this.position.x < 0) this.position.x = 0 + if (this.position.y < 0) this.position.y = 0 + if (this.position.x > viewport.x) this.position.x = viewport.x + if (this.position.y > viewport.y) this.position.y = viewport.y + } + + shoot() { + /* check if it can shoot */ + if (Engine.frame < this.lastShot + this.reloadTime) { + return + } + + this.lastShot = Engine.frame /*(reset reload)*/ + + let bullet_a_position = this.position.clone() + let bullet_b_position = this.position.clone() + + bullet_a_position.x = bullet_a_position.x + 5 + bullet_b_position.x = bullet_b_position.x - 5 + + new BoshyBullet(bullet_a_position) + new BoshyBullet(bullet_b_position) + Engine.playSound(BOSHY.SOUNDS.SHOOT) + } +} diff --git a/src/entities/boshybullet.js b/src/entities/boshybullet.js new file mode 100644 index 0000000..ed91ede --- /dev/null +++ b/src/entities/boshybullet.js @@ -0,0 +1,30 @@ +import { BOSHY } from "../assets.js" +import { Vector } from "../engine/vector.js" +import { bullets } from "../main.js" +import { Entity } from "./entity.js" + +export class BoshyBullet extends Entity { + speed = 20 + + constructor(position = new Vector(0,0)) { + super({ + size: new Vector(5, 5), + position: position.floor(), + sprite: BOSHY.BULLET, + }) + + bullets.list.push(this) + } + + update() { + this.position.y -= this.speed + if (this.position.y < 0) { + this.span.remove() + bullets.remove(this) + } + } + + remove() { + this.span.remove() + } +} diff --git a/src/entities/entity.js b/src/entities/entity.js new file mode 100644 index 0000000..ac14d4b --- /dev/null +++ b/src/entities/entity.js @@ -0,0 +1,23 @@ +import { Vector } from "../engine/vector.js" +import { Engine } from "../engine.js" + +export class Entity { + constructor({ + size, + hitbox = size, + sprite, + position = new Vector(0,0), + }) { + this.size = size + this.hitbox = hitbox + this.position = position + + this.span = document.createElement("img") + this.span.src = sprite + Engine.screen.append(this.span) + } + + draw() { + Engine.screen.draw(this.span, this.position, this.size) + } +} diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..6822351 --- /dev/null +++ b/src/main.js @@ -0,0 +1,38 @@ +///////////////////// IMPORTS ////////////////////// +import { Boshy } from "./entities/boshy.js" +import { SCENE, SCENES } from "./scenes.js" + + +///////////////////// GLOBALS ////////////////////// +export let boshy +export const bullets = { + list: [], + remove: instance => { bullets.list = bullets.list.filter(b => b != instance) }, + clear: _ => { bullets.list.forEach(b => b.remove()) } +} + +///////////////////// GAME LOGIC ////////////////////// +export function start() { + console.log("game start") + changeScene(SCENES.PREQUEL) +} + +export function update() { + boshy.update() + bullets.list.forEach((bullet) => bullet.update()) + SCENE.update() +} + +export function draw() { + boshy.draw() + bullets.list.forEach((bullet) => bullet.draw()) + SCENE.draw() +} + + +///////////////////// SCENE METHODS ////////////////////// +export function changeScene(scene) { + SCENE.load(scene) + bullets.clear() + boshy = new Boshy() +} diff --git a/src/scenes.js b/src/scenes.js new file mode 100644 index 0000000..09ea493 --- /dev/null +++ b/src/scenes.js @@ -0,0 +1,30 @@ +import * as PREQUEL from "./scenes/prequel.js" +import * as GAME from "./scenes/game.js" + +export const SCENES = { + PREQUEL: "prequel", + GAME: "game", +} + +export const SCENE = { + load: loadScene, + update: null, + draw: null, +} + +let currentScene + +function loadScene(scene) { + currentScene = scene + if (currentScene == SCENES.PREQUEL) { + PREQUEL.start() + SCENE.update = PREQUEL.update + SCENE.draw = PREQUEL.draw + } + + if (currentScene == SCENES.GAME) { + GAME.start() + SCENE.update = GAME.update + SCENE.draw = GAME.draw + } +} diff --git a/src/scenes/game.js b/src/scenes/game.js new file mode 100644 index 0000000..1640aa5 --- /dev/null +++ b/src/scenes/game.js @@ -0,0 +1,13 @@ +import { Engine } from "../engine.js" +import { MUSIC } from "../assets.js" + +export function start() { + Engine.playMusic(MUSIC.SOLGRYN) +} + + +export function update() { +} + +export function draw() { +} diff --git a/src/scenes/prequel.js b/src/scenes/prequel.js new file mode 100644 index 0000000..f24ef99 --- /dev/null +++ b/src/scenes/prequel.js @@ -0,0 +1,13 @@ +import { Engine } from "../engine.js" +import { MUSIC } from "../assets.js" + +export function start() { + Engine.playMusic(MUSIC.PREQUEL) +} + + +export function update() { +} + +export function draw() { +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..9a64319 --- /dev/null +++ b/style.css @@ -0,0 +1,30 @@ +body { + margin: 0; + background-color: grey; + width: 100%; + height: 100%; } + +img { + position: absolute; + top: 0; + left: 0; } + +.background { + position: inline; + width: 100%; + height: 100%; } + +#spawn { + position: relative; + top: 0; + left: 0; + width: 0; + height: 0; } + +#screen { + display: block; + overflow: hidden; + background-size: cover; + position: absolute; + top: 0; + left: 0; } -- cgit v1.2.3