diff --git a/assets/CyberMenuSong.mp3 b/assets/CyberMenuSong.mp3 new file mode 100644 index 0000000..95029aa Binary files /dev/null and b/assets/CyberMenuSong.mp3 differ diff --git a/assets/RRES.mp3 b/assets/RRES.mp3 new file mode 100644 index 0000000..a7ea314 Binary files /dev/null and b/assets/RRES.mp3 differ diff --git a/assets/explosion.wav b/assets/explosion.wav new file mode 100644 index 0000000..fe1c0a3 Binary files /dev/null and b/assets/explosion.wav differ diff --git a/assets/kenney_pixel-shmup/License.txt b/assets/kenney_pixel-shmup/License.txt new file mode 100644 index 0000000..dce291a --- /dev/null +++ b/assets/kenney_pixel-shmup/License.txt @@ -0,0 +1,22 @@ + + + Pixel Shmup (1.1) + + Created/distributed by Kenney (www.kenney.nl) + Creation date: 01-11-2021 + + ------------------------------ + + License: (Creative Commons Zero, CC0) + http://creativecommons.org/publicdomain/zero/1.0/ + + This content is free to use in personal, educational and commercial projects. + Support us by crediting Kenney or www.kenney.nl (this is not mandatory) + + ------------------------------ + + Donate: http://support.kenney.nl + Patreon: http://patreon.com/kenney/ + + Follow on Twitter for updates: + http://twitter.com/KenneyNL \ No newline at end of file diff --git a/assets/kenney_pixel-shmup/Preview.png b/assets/kenney_pixel-shmup/Preview.png new file mode 100644 index 0000000..42f6036 Binary files /dev/null and b/assets/kenney_pixel-shmup/Preview.png differ diff --git a/assets/kenney_pixel-shmup/Sample.png b/assets/kenney_pixel-shmup/Sample.png new file mode 100644 index 0000000..cd5d365 Binary files /dev/null and b/assets/kenney_pixel-shmup/Sample.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0000.png b/assets/kenney_pixel-shmup/Ships/ship_0000.png new file mode 100644 index 0000000..b1b8a64 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0000.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0001.png b/assets/kenney_pixel-shmup/Ships/ship_0001.png new file mode 100644 index 0000000..7c79f4c Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0001.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0002.png b/assets/kenney_pixel-shmup/Ships/ship_0002.png new file mode 100644 index 0000000..649fa7c Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0002.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0003.png b/assets/kenney_pixel-shmup/Ships/ship_0003.png new file mode 100644 index 0000000..02d3b79 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0003.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0004.png b/assets/kenney_pixel-shmup/Ships/ship_0004.png new file mode 100644 index 0000000..4c5dec1 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0004.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0005.png b/assets/kenney_pixel-shmup/Ships/ship_0005.png new file mode 100644 index 0000000..076afbb Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0005.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0006.png b/assets/kenney_pixel-shmup/Ships/ship_0006.png new file mode 100644 index 0000000..9a02dba Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0006.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0007.png b/assets/kenney_pixel-shmup/Ships/ship_0007.png new file mode 100644 index 0000000..ac7ba5c Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0007.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0008.png b/assets/kenney_pixel-shmup/Ships/ship_0008.png new file mode 100644 index 0000000..8ccccbf Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0008.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0009.png b/assets/kenney_pixel-shmup/Ships/ship_0009.png new file mode 100644 index 0000000..5ef6075 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0009.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0010.png b/assets/kenney_pixel-shmup/Ships/ship_0010.png new file mode 100644 index 0000000..2b9ed7b Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0010.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0011.png b/assets/kenney_pixel-shmup/Ships/ship_0011.png new file mode 100644 index 0000000..327f745 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0011.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0012.png b/assets/kenney_pixel-shmup/Ships/ship_0012.png new file mode 100644 index 0000000..a161479 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0012.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0013.png b/assets/kenney_pixel-shmup/Ships/ship_0013.png new file mode 100644 index 0000000..0fce519 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0013.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0014.png b/assets/kenney_pixel-shmup/Ships/ship_0014.png new file mode 100644 index 0000000..8747b09 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0014.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0015.png b/assets/kenney_pixel-shmup/Ships/ship_0015.png new file mode 100644 index 0000000..d1a9c32 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0015.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0016.png b/assets/kenney_pixel-shmup/Ships/ship_0016.png new file mode 100644 index 0000000..e201d3f Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0016.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0017.png b/assets/kenney_pixel-shmup/Ships/ship_0017.png new file mode 100644 index 0000000..fc13379 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0017.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0018.png b/assets/kenney_pixel-shmup/Ships/ship_0018.png new file mode 100644 index 0000000..26cd433 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0018.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0019.png b/assets/kenney_pixel-shmup/Ships/ship_0019.png new file mode 100644 index 0000000..35c1f49 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0019.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0020.png b/assets/kenney_pixel-shmup/Ships/ship_0020.png new file mode 100644 index 0000000..f2b6334 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0020.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0021.png b/assets/kenney_pixel-shmup/Ships/ship_0021.png new file mode 100644 index 0000000..e7acecd Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0021.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0022.png b/assets/kenney_pixel-shmup/Ships/ship_0022.png new file mode 100644 index 0000000..9cbfad5 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0022.png differ diff --git a/assets/kenney_pixel-shmup/Ships/ship_0023.png b/assets/kenney_pixel-shmup/Ships/ship_0023.png new file mode 100644 index 0000000..6f251b5 Binary files /dev/null and b/assets/kenney_pixel-shmup/Ships/ship_0023.png differ diff --git a/assets/kenney_pixel-shmup/Tilemap/ships.png b/assets/kenney_pixel-shmup/Tilemap/ships.png new file mode 100644 index 0000000..8451c10 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tilemap/ships.png differ diff --git a/assets/kenney_pixel-shmup/Tilemap/ships_packed.png b/assets/kenney_pixel-shmup/Tilemap/ships_packed.png new file mode 100644 index 0000000..e586a1b Binary files /dev/null and b/assets/kenney_pixel-shmup/Tilemap/ships_packed.png differ diff --git a/assets/kenney_pixel-shmup/Tilemap/tiles.png b/assets/kenney_pixel-shmup/Tilemap/tiles.png new file mode 100644 index 0000000..7bbef6a Binary files /dev/null and b/assets/kenney_pixel-shmup/Tilemap/tiles.png differ diff --git a/assets/kenney_pixel-shmup/Tilemap/tiles_packed.png b/assets/kenney_pixel-shmup/Tilemap/tiles_packed.png new file mode 100644 index 0000000..20b6292 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tilemap/tiles_packed.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0000.png b/assets/kenney_pixel-shmup/Tiles/tile_0000.png new file mode 100644 index 0000000..27e7b87 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0000.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0001.png b/assets/kenney_pixel-shmup/Tiles/tile_0001.png new file mode 100644 index 0000000..5c50352 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0001.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0002.png b/assets/kenney_pixel-shmup/Tiles/tile_0002.png new file mode 100644 index 0000000..1ccf2cf Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0002.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0003.png b/assets/kenney_pixel-shmup/Tiles/tile_0003.png new file mode 100644 index 0000000..d91db61 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0003.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0004.png b/assets/kenney_pixel-shmup/Tiles/tile_0004.png new file mode 100644 index 0000000..5a91c24 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0004.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0005.png b/assets/kenney_pixel-shmup/Tiles/tile_0005.png new file mode 100644 index 0000000..3c1e1da Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0005.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0006.png b/assets/kenney_pixel-shmup/Tiles/tile_0006.png new file mode 100644 index 0000000..4df43a8 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0006.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0007.png b/assets/kenney_pixel-shmup/Tiles/tile_0007.png new file mode 100644 index 0000000..dec5a86 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0007.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0008.png b/assets/kenney_pixel-shmup/Tiles/tile_0008.png new file mode 100644 index 0000000..d1b6529 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0008.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0009.png b/assets/kenney_pixel-shmup/Tiles/tile_0009.png new file mode 100644 index 0000000..67a7719 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0009.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0010.png b/assets/kenney_pixel-shmup/Tiles/tile_0010.png new file mode 100644 index 0000000..844f9e8 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0010.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0011.png b/assets/kenney_pixel-shmup/Tiles/tile_0011.png new file mode 100644 index 0000000..8817ead Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0011.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0012.png b/assets/kenney_pixel-shmup/Tiles/tile_0012.png new file mode 100644 index 0000000..069dfaf Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0012.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0013.png b/assets/kenney_pixel-shmup/Tiles/tile_0013.png new file mode 100644 index 0000000..591f4dc Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0013.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0014.png b/assets/kenney_pixel-shmup/Tiles/tile_0014.png new file mode 100644 index 0000000..c2e1dd4 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0014.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0015.png b/assets/kenney_pixel-shmup/Tiles/tile_0015.png new file mode 100644 index 0000000..62199f7 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0015.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0016.png b/assets/kenney_pixel-shmup/Tiles/tile_0016.png new file mode 100644 index 0000000..3761111 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0016.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0017.png b/assets/kenney_pixel-shmup/Tiles/tile_0017.png new file mode 100644 index 0000000..0aad36f Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0017.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0018.png b/assets/kenney_pixel-shmup/Tiles/tile_0018.png new file mode 100644 index 0000000..a69e582 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0018.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0019.png b/assets/kenney_pixel-shmup/Tiles/tile_0019.png new file mode 100644 index 0000000..9417c79 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0019.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0020.png b/assets/kenney_pixel-shmup/Tiles/tile_0020.png new file mode 100644 index 0000000..3b72616 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0020.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0021.png b/assets/kenney_pixel-shmup/Tiles/tile_0021.png new file mode 100644 index 0000000..49de17a Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0021.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0022.png b/assets/kenney_pixel-shmup/Tiles/tile_0022.png new file mode 100644 index 0000000..bb569e5 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0022.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0023.png b/assets/kenney_pixel-shmup/Tiles/tile_0023.png new file mode 100644 index 0000000..eb8e429 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0023.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0024.png b/assets/kenney_pixel-shmup/Tiles/tile_0024.png new file mode 100644 index 0000000..c37dcb4 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0024.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0025.png b/assets/kenney_pixel-shmup/Tiles/tile_0025.png new file mode 100644 index 0000000..3ea4b57 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0025.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0026.png b/assets/kenney_pixel-shmup/Tiles/tile_0026.png new file mode 100644 index 0000000..0efd5b5 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0026.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0027.png b/assets/kenney_pixel-shmup/Tiles/tile_0027.png new file mode 100644 index 0000000..e4909e6 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0027.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0028.png b/assets/kenney_pixel-shmup/Tiles/tile_0028.png new file mode 100644 index 0000000..fe77955 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0028.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0029.png b/assets/kenney_pixel-shmup/Tiles/tile_0029.png new file mode 100644 index 0000000..ebac093 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0029.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0030.png b/assets/kenney_pixel-shmup/Tiles/tile_0030.png new file mode 100644 index 0000000..38c2902 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0030.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0031.png b/assets/kenney_pixel-shmup/Tiles/tile_0031.png new file mode 100644 index 0000000..315fdbb Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0031.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0032.png b/assets/kenney_pixel-shmup/Tiles/tile_0032.png new file mode 100644 index 0000000..ddab4bd Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0032.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0033.png b/assets/kenney_pixel-shmup/Tiles/tile_0033.png new file mode 100644 index 0000000..b7269fd Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0033.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0034.png b/assets/kenney_pixel-shmup/Tiles/tile_0034.png new file mode 100644 index 0000000..58eb4f2 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0034.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0035.png b/assets/kenney_pixel-shmup/Tiles/tile_0035.png new file mode 100644 index 0000000..620fcbd Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0035.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0036.png b/assets/kenney_pixel-shmup/Tiles/tile_0036.png new file mode 100644 index 0000000..67d3c05 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0036.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0037.png b/assets/kenney_pixel-shmup/Tiles/tile_0037.png new file mode 100644 index 0000000..71a37c9 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0037.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0038.png b/assets/kenney_pixel-shmup/Tiles/tile_0038.png new file mode 100644 index 0000000..d651aae Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0038.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0039.png b/assets/kenney_pixel-shmup/Tiles/tile_0039.png new file mode 100644 index 0000000..367b6a9 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0039.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0040.png b/assets/kenney_pixel-shmup/Tiles/tile_0040.png new file mode 100644 index 0000000..c8edb1e Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0040.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0041.png b/assets/kenney_pixel-shmup/Tiles/tile_0041.png new file mode 100644 index 0000000..91a9763 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0041.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0042.png b/assets/kenney_pixel-shmup/Tiles/tile_0042.png new file mode 100644 index 0000000..ce0040f Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0042.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0043.png b/assets/kenney_pixel-shmup/Tiles/tile_0043.png new file mode 100644 index 0000000..5dd66ba Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0043.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0044.png b/assets/kenney_pixel-shmup/Tiles/tile_0044.png new file mode 100644 index 0000000..e3011a0 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0044.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0045.png b/assets/kenney_pixel-shmup/Tiles/tile_0045.png new file mode 100644 index 0000000..4717045 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0045.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0046.png b/assets/kenney_pixel-shmup/Tiles/tile_0046.png new file mode 100644 index 0000000..28ab59d Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0046.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0047.png b/assets/kenney_pixel-shmup/Tiles/tile_0047.png new file mode 100644 index 0000000..96771d7 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0047.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0048.png b/assets/kenney_pixel-shmup/Tiles/tile_0048.png new file mode 100644 index 0000000..17f80dc Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0048.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0049.png b/assets/kenney_pixel-shmup/Tiles/tile_0049.png new file mode 100644 index 0000000..0310829 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0049.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0050.png b/assets/kenney_pixel-shmup/Tiles/tile_0050.png new file mode 100644 index 0000000..32a8747 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0050.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0051.png b/assets/kenney_pixel-shmup/Tiles/tile_0051.png new file mode 100644 index 0000000..1a58296 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0051.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0052.png b/assets/kenney_pixel-shmup/Tiles/tile_0052.png new file mode 100644 index 0000000..f4cc30d Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0052.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0053.png b/assets/kenney_pixel-shmup/Tiles/tile_0053.png new file mode 100644 index 0000000..0eb497b Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0053.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0054.png b/assets/kenney_pixel-shmup/Tiles/tile_0054.png new file mode 100644 index 0000000..f572a44 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0054.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0055.png b/assets/kenney_pixel-shmup/Tiles/tile_0055.png new file mode 100644 index 0000000..388d84f Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0055.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0056.png b/assets/kenney_pixel-shmup/Tiles/tile_0056.png new file mode 100644 index 0000000..5d09b88 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0056.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0057.png b/assets/kenney_pixel-shmup/Tiles/tile_0057.png new file mode 100644 index 0000000..c007a88 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0057.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0058.png b/assets/kenney_pixel-shmup/Tiles/tile_0058.png new file mode 100644 index 0000000..18d1c04 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0058.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0059.png b/assets/kenney_pixel-shmup/Tiles/tile_0059.png new file mode 100644 index 0000000..8a254a5 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0059.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0060.png b/assets/kenney_pixel-shmup/Tiles/tile_0060.png new file mode 100644 index 0000000..1df1e2e Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0060.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0061.png b/assets/kenney_pixel-shmup/Tiles/tile_0061.png new file mode 100644 index 0000000..a91abeb Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0061.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0062.png b/assets/kenney_pixel-shmup/Tiles/tile_0062.png new file mode 100644 index 0000000..4be82e7 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0062.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0063.png b/assets/kenney_pixel-shmup/Tiles/tile_0063.png new file mode 100644 index 0000000..6674da4 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0063.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0064.png b/assets/kenney_pixel-shmup/Tiles/tile_0064.png new file mode 100644 index 0000000..221f305 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0064.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0065.png b/assets/kenney_pixel-shmup/Tiles/tile_0065.png new file mode 100644 index 0000000..7ca8b3f Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0065.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0066.png b/assets/kenney_pixel-shmup/Tiles/tile_0066.png new file mode 100644 index 0000000..40d0565 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0066.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0067.png b/assets/kenney_pixel-shmup/Tiles/tile_0067.png new file mode 100644 index 0000000..f058b05 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0067.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0068.png b/assets/kenney_pixel-shmup/Tiles/tile_0068.png new file mode 100644 index 0000000..82fa685 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0068.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0069.png b/assets/kenney_pixel-shmup/Tiles/tile_0069.png new file mode 100644 index 0000000..28bcd42 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0069.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0070.png b/assets/kenney_pixel-shmup/Tiles/tile_0070.png new file mode 100644 index 0000000..a9e45dd Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0070.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0071.png b/assets/kenney_pixel-shmup/Tiles/tile_0071.png new file mode 100644 index 0000000..871e7b7 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0071.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0072.png b/assets/kenney_pixel-shmup/Tiles/tile_0072.png new file mode 100644 index 0000000..7350b3a Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0072.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0073.png b/assets/kenney_pixel-shmup/Tiles/tile_0073.png new file mode 100644 index 0000000..8beee53 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0073.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0074.png b/assets/kenney_pixel-shmup/Tiles/tile_0074.png new file mode 100644 index 0000000..557106e Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0074.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0075.png b/assets/kenney_pixel-shmup/Tiles/tile_0075.png new file mode 100644 index 0000000..e57811b Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0075.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0076.png b/assets/kenney_pixel-shmup/Tiles/tile_0076.png new file mode 100644 index 0000000..ab9d5ee Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0076.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0077.png b/assets/kenney_pixel-shmup/Tiles/tile_0077.png new file mode 100644 index 0000000..0304e8d Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0077.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0078.png b/assets/kenney_pixel-shmup/Tiles/tile_0078.png new file mode 100644 index 0000000..3c95c11 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0078.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0079.png b/assets/kenney_pixel-shmup/Tiles/tile_0079.png new file mode 100644 index 0000000..ee40e8b Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0079.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0080.png b/assets/kenney_pixel-shmup/Tiles/tile_0080.png new file mode 100644 index 0000000..96b9b7f Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0080.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0081.png b/assets/kenney_pixel-shmup/Tiles/tile_0081.png new file mode 100644 index 0000000..9ae4a86 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0081.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0082.png b/assets/kenney_pixel-shmup/Tiles/tile_0082.png new file mode 100644 index 0000000..835a36c Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0082.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0083.png b/assets/kenney_pixel-shmup/Tiles/tile_0083.png new file mode 100644 index 0000000..615ab9c Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0083.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0084.png b/assets/kenney_pixel-shmup/Tiles/tile_0084.png new file mode 100644 index 0000000..5d7c797 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0084.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0085.png b/assets/kenney_pixel-shmup/Tiles/tile_0085.png new file mode 100644 index 0000000..989ffb8 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0085.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0086.png b/assets/kenney_pixel-shmup/Tiles/tile_0086.png new file mode 100644 index 0000000..ea2edd0 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0086.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0087.png b/assets/kenney_pixel-shmup/Tiles/tile_0087.png new file mode 100644 index 0000000..d6a5717 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0087.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0088.png b/assets/kenney_pixel-shmup/Tiles/tile_0088.png new file mode 100644 index 0000000..5646e9c Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0088.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0089.png b/assets/kenney_pixel-shmup/Tiles/tile_0089.png new file mode 100644 index 0000000..f93b5db Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0089.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0090.png b/assets/kenney_pixel-shmup/Tiles/tile_0090.png new file mode 100644 index 0000000..6843b95 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0090.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0091.png b/assets/kenney_pixel-shmup/Tiles/tile_0091.png new file mode 100644 index 0000000..bae6960 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0091.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0092.png b/assets/kenney_pixel-shmup/Tiles/tile_0092.png new file mode 100644 index 0000000..f8dfb94 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0092.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0093.png b/assets/kenney_pixel-shmup/Tiles/tile_0093.png new file mode 100644 index 0000000..e976c31 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0093.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0094.png b/assets/kenney_pixel-shmup/Tiles/tile_0094.png new file mode 100644 index 0000000..692cd2f Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0094.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0095.png b/assets/kenney_pixel-shmup/Tiles/tile_0095.png new file mode 100644 index 0000000..4b22d9c Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0095.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0096.png b/assets/kenney_pixel-shmup/Tiles/tile_0096.png new file mode 100644 index 0000000..77f0756 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0096.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0097.png b/assets/kenney_pixel-shmup/Tiles/tile_0097.png new file mode 100644 index 0000000..3a0ea5f Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0097.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0098.png b/assets/kenney_pixel-shmup/Tiles/tile_0098.png new file mode 100644 index 0000000..1cd89a4 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0098.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0099.png b/assets/kenney_pixel-shmup/Tiles/tile_0099.png new file mode 100644 index 0000000..cddfe15 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0099.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0100.png b/assets/kenney_pixel-shmup/Tiles/tile_0100.png new file mode 100644 index 0000000..c58f462 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0100.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0101.png b/assets/kenney_pixel-shmup/Tiles/tile_0101.png new file mode 100644 index 0000000..f1a0af9 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0101.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0102.png b/assets/kenney_pixel-shmup/Tiles/tile_0102.png new file mode 100644 index 0000000..faa774a Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0102.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0103.png b/assets/kenney_pixel-shmup/Tiles/tile_0103.png new file mode 100644 index 0000000..c022e1b Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0103.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0104.png b/assets/kenney_pixel-shmup/Tiles/tile_0104.png new file mode 100644 index 0000000..04b99a9 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0104.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0105.png b/assets/kenney_pixel-shmup/Tiles/tile_0105.png new file mode 100644 index 0000000..9314993 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0105.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0106.png b/assets/kenney_pixel-shmup/Tiles/tile_0106.png new file mode 100644 index 0000000..1c380d3 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0106.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0107.png b/assets/kenney_pixel-shmup/Tiles/tile_0107.png new file mode 100644 index 0000000..7045c44 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0107.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0108.png b/assets/kenney_pixel-shmup/Tiles/tile_0108.png new file mode 100644 index 0000000..0379acc Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0108.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0109.png b/assets/kenney_pixel-shmup/Tiles/tile_0109.png new file mode 100644 index 0000000..be8455d Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0109.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0110.png b/assets/kenney_pixel-shmup/Tiles/tile_0110.png new file mode 100644 index 0000000..edaaa59 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0110.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0111.png b/assets/kenney_pixel-shmup/Tiles/tile_0111.png new file mode 100644 index 0000000..deba627 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0111.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0112.png b/assets/kenney_pixel-shmup/Tiles/tile_0112.png new file mode 100644 index 0000000..283cd6b Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0112.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0113.png b/assets/kenney_pixel-shmup/Tiles/tile_0113.png new file mode 100644 index 0000000..5ec836c Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0113.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0114.png b/assets/kenney_pixel-shmup/Tiles/tile_0114.png new file mode 100644 index 0000000..797bf84 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0114.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0115.png b/assets/kenney_pixel-shmup/Tiles/tile_0115.png new file mode 100644 index 0000000..eba06af Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0115.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0116.png b/assets/kenney_pixel-shmup/Tiles/tile_0116.png new file mode 100644 index 0000000..f47f95a Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0116.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0117.png b/assets/kenney_pixel-shmup/Tiles/tile_0117.png new file mode 100644 index 0000000..76afcd9 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0117.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0118.png b/assets/kenney_pixel-shmup/Tiles/tile_0118.png new file mode 100644 index 0000000..e5e2581 Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0118.png differ diff --git a/assets/kenney_pixel-shmup/Tiles/tile_0119.png b/assets/kenney_pixel-shmup/Tiles/tile_0119.png new file mode 100644 index 0000000..94d799e Binary files /dev/null and b/assets/kenney_pixel-shmup/Tiles/tile_0119.png differ diff --git a/assets/kenney_pixel-shmup/Tilesheet (Ships).txt b/assets/kenney_pixel-shmup/Tilesheet (Ships).txt new file mode 100644 index 0000000..9e48a73 --- /dev/null +++ b/assets/kenney_pixel-shmup/Tilesheet (Ships).txt @@ -0,0 +1,9 @@ +Tilesheet information: + +Tile size • 32px × 32px +Space between tiles • 1px × 1px +--- +Total tiles (horizontal) • 4 tiles +Total tiles (vertical) • 6 tiles +--- +Total tiles in sheet • 24 tiles \ No newline at end of file diff --git a/assets/kenney_pixel-shmup/Tilesheet (Tiles).txt b/assets/kenney_pixel-shmup/Tilesheet (Tiles).txt new file mode 100644 index 0000000..f2b5fea --- /dev/null +++ b/assets/kenney_pixel-shmup/Tilesheet (Tiles).txt @@ -0,0 +1,9 @@ +Tilesheet information: + +Tile size • 16px × 16px +Space between tiles • 1px × 1px +--- +Total tiles (horizontal) • 12 tiles +Total tiles (vertical) • 10 tiles +--- +Total tiles in sheet • 120 tiles \ No newline at end of file diff --git a/assets/kenney_pixel-shmup/Visit Kenney.url b/assets/kenney_pixel-shmup/Visit Kenney.url new file mode 100644 index 0000000..fbdde43 --- /dev/null +++ b/assets/kenney_pixel-shmup/Visit Kenney.url @@ -0,0 +1,2 @@ +[InternetShortcut] +URL=http://www.kenney.nl/ \ No newline at end of file diff --git a/assets/kenney_pixel-shmup/Visit Patreon.url b/assets/kenney_pixel-shmup/Visit Patreon.url new file mode 100644 index 0000000..439ef26 --- /dev/null +++ b/assets/kenney_pixel-shmup/Visit Patreon.url @@ -0,0 +1,2 @@ +[InternetShortcut] +URL=https://www.patreon.com/kenney/ \ No newline at end of file diff --git a/index.html b/index.html index 31f4f70..dbaad1c 100644 --- a/index.html +++ b/index.html @@ -4,19 +4,47 @@ Bullet Time + + + +
+
+ +
- - - - + - + + + - - -
- \ No newline at end of file diff --git a/src/Scenes/ArrayBoom.js b/src/Scenes/ArrayBoom.js index 8f18b41..01dcd41 100644 --- a/src/Scenes/ArrayBoom.js +++ b/src/Scenes/ArrayBoom.js @@ -1,29 +1,83 @@ class ArrayBoom extends Phaser.Scene { constructor() { super("arrayBoom"); - - // Initialize a class variable "my" which is an object. - // The object has two properties, both of which are objects - // - "sprite" holds bindings (pointers) to created sprites - // - "text" holds bindings to created bitmap text objects this.my = {sprite: {}, text: {}}; - // Create a property inside "sprite" named "bullet". - // The bullet property has a value which is an array. - // This array will hold bindings (pointers) to bullet sprites - this.my.sprite.bullet = []; - this.maxBullets = 10; // Don't create more than this many bullets - - this.myScore = 0; // record a score as a class variable - // More typically want to use a global variable for score, since - // it will be used across multiple scenes + this.playerSpeed = 600; + + this.bulletCooldown = 250; // Number of update() calls to wait before making a new bullet + this.bulletCooldownCounter = 0; + + this.enemies = []; + this.enemyWaveCount = 0; + this.wave = 1; + + //startX, startY, enemyNum + this.levelObjectArr = [ + { + level: "Level 1", + fighter: [0, 0, 0], + bomber: [92, 92, 4], + twinShooter: [0, 184, 1], + support: [128, 184, 3], + }, + { + level: "Level 2", + fighter: [92, 92, 3], + bomber: [0, 0, 0], + twinShooter: [128, 184, 2], + support: [0, 0, 0], + }, + { + level: "Level 3", + fighter: [128, 138, 3], + bomber: [92, 92, 4], + twinShooter: [0, 0, 0], + support: [128, 184, 7], + }, + { + level: "Level 4", + fighter: [0, 0, 0], + bomber: [0, 0, 0], + twinShooter: [64, 92, 2], + support: [128, 230, 7], + }, + { + level: "Level 5", + fighter: [128, 138, 3], + bomber: [0, 92, 1], + twinShooter: [64, 184, 4], + support: [128, 230, 7], + }, + ]; + this.showHitboxes = false; } preload() { + this.load.setPath("./assets/"); - this.load.image("elephant", "elephant.png"); - this.load.image("heart", "heart.png"); - this.load.image("hippo", "hippo.png"); + + //Player Sprites + this.load.image("playerShip", "kenney_pixel-shmup/Ships/ship_0012.png"); + this.load.image("playerShot", "kenney_pixel-shmup/Tiles/tile_0000.png"); + + //Fighter Sprites + this.load.image("fighter", "kenney_pixel-shmup/Ships/ship_0002.png"); + + //Bomber Sprites + this.load.image("bomber", "kenney_pixel-shmup/Ships/ship_0003.png"); + this.load.image("bomb0", "kenney_pixel-shmup/Tiles/tile_0004.png"); + this.load.image("bomb1", "kenney_pixel-shmup/Tiles/tile_0006.png"); + this.load.image("bomb2", "kenney_pixel-shmup/Tiles/tile_0005.png"); + this.load.image("bomb3", "kenney_pixel-shmup/Tiles/tile_0007.png"); + this.load.image("bomb4", "kenney_pixel-shmup/Tiles/tile_0008.png"); + + //Twinshooter Sprites + this.load.image("twinshooter", "kenney_pixel-shmup/Ships/ship_0008.png"); + this.load.image("twinshot", "kenney_pixel-shmup/Tiles/tile_0001.png"); + + //Support sprites + this.load.image("support", "kenney_pixel-shmup/Ships/ship_0009.png"); // For animation this.load.image("whitePuff00", "whitePuff00.png"); @@ -31,32 +85,97 @@ class ArrayBoom extends Phaser.Scene { this.load.image("whitePuff02", "whitePuff02.png"); this.load.image("whitePuff03", "whitePuff03.png"); - // Load the Kenny Rocket Square bitmap font - // This was converted from TrueType format into Phaser bitmap - // format using the BMFont tool. - // BMFont: https://www.angelcode.com/products/bmfont/ - // Tutorial: https://dev.to/omar4ur/how-to-create-bitmap-fonts-for-phaser-js-with-bmfont-2ndc + //Load Bitmap Font this.load.bitmapFont("rocketSquare", "KennyRocketSquare_0.png", "KennyRocketSquare.fnt"); - - // Sound asset from the Kenny Music Jingles pack - // https://kenney.nl/assets/music-jingles - // Upon pain of 💀 do not use in your game projects. - // (It's that bad) - this.load.audio("dadada", "jingles_NES13.ogg"); + + this.load.audio("DeathEmit", "explosion.wav"); } create() { let my = this.my; - my.sprite.elephant = this.add.sprite(game.config.width/2, game.config.height - 40, "elephant"); - my.sprite.elephant.setScale(0.25); + // Create key objects + this.left = this.input.keyboard.addKey("A"); + this.right = this.input.keyboard.addKey("D"); + this.nextScene = this.input.keyboard.addKey("S"); + this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + + my.sprite.playerShip = new Player(this, game.config.width/2, game.config.height - 40, "playerShip", null, this.left, this.right, this.playerSpeed, this.showHitboxes); + my.sprite.playerShip.setScale(2.0); - my.sprite.hippo = this.add.sprite(game.config.width/2, 80, "hippo"); - my.sprite.hippo.setScale(0.25); - my.sprite.hippo.scorePoints = 25; + ///////////////////////// + // Player Bullet Group // + ///////////////////////// - // Notice that in this approach, we don't create any bullet sprites in create(), - // and instead wait until we need them, based on the number of space bar presses + my.sprite.bulletGroup = this.add.group({ + active: true, + defaultKey: "playerShot", + maxSize: 5, + runChildUpdate: true + } + ) + + //Create bullets at once + my.sprite.bulletGroup.createMultiple({ + classType: Bullet, + active: false, + key: my.sprite.bulletGroup.defaultKey, + setScale: { + x:2.0, + y:2.0 + }, + repeat: my.sprite.bulletGroup.maxSize-1 + }); + + my.sprite.bulletGroup.propertyValueSet("speed", -this.bulletSpeed); + + my.sprite.bulletGroup.getChildren().forEach(element => { + element.makeInactive(); + }); + + //////////////////////// + // Enemy Bullet Group // + //////////////////////// + + let enemyBGMax = 300; + + my.sprite.enemyBulletGroup = this.add.group({ + active: true, + defaultKey: "playerShot", + maxSize: enemyBGMax, + runChildUpdate: true + } + ) + + //Create bullets at once + my.sprite.enemyBulletGroup.createMultiple({ + classType: Bullet, + active: false, + key: my.sprite.bulletGroup.defaultKey, + setScale: { + x:2.0, + y:-2.0 + }, + repeat: enemyBGMax-1 + }); + + my.sprite.enemyBulletGroup.propertyValueSet("speed", 400); + + my.sprite.enemyBulletGroup.getChildren().forEach(element => { + element.makeInactive(); + }); + + // Player Hit + this.anims.create({ + key: "playerHit", + frames: [ + { key: "bomb3" }, + { key: "bomb4" }, + ], + frameRate: 8, // Note: case sensitive (thank you Ivy!) + repeat: 0, + hideOnComplete: true + }); // Create white puff animation this.anims.create({ @@ -72,122 +191,433 @@ class ArrayBoom extends Phaser.Scene { hideOnComplete: true }); - // Create key objects - this.left = this.input.keyboard.addKey("A"); - this.right = this.input.keyboard.addKey("D"); - this.nextScene = this.input.keyboard.addKey("S"); - this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - - // Set movement speeds (in pixels/sec) - this.playerSpeed = 300; - this.bulletSpeed = 300; + // Bomb animation + this.anims.create({ + key: "ANIMbomb", + frames: [ + { key: "bomb0" }, + { key: "bomb1" }, + ], + frameRate: 8, // Note: case sensitive (thank you Ivy!) + repeat: -1, + hideOnComplete: true + }); - // update HTML description - document.getElementById('description').innerHTML = '

Array Boom.js


A: left // D: right // Space: fire/emit // S: Next Scene' + // On hit explosion + this.anims.create({ + key: "explosion", + frames: [ + { key: "bomb1" }, + { key: "bomb2" }, + { key: "bomb3" }, + { key: "bomb4" }, + ], + frameRate: 8, // Note: case sensitive (thank you Ivy!) + repeat: 0, + hideOnComplete: true + }); // Put score on screen - my.text.score = this.add.bitmapText(580, 0, "rocketSquare", "Score " + this.myScore); - - // Put title on screen - this.add.text(10, 5, "Hippo Hug!", { - fontFamily: 'Times, serif', - fontSize: 24, - wordWrap: { - width: 60 - } + my.text.score = this.add.bitmapText(game.config.width, 0, "rocketSquare", "Score " + this.game.config.score); + my.text.score.x -= my.text.score.displayWidth + 5; + + my.text.waveText = this.add.bitmapText(0, 0, "rocketSquare", "Wave " + this.wave); + my.text.waveText.setScale(2.0); + my.text.waveText.x = game.config.width/2 - my.text.waveText.displayWidth/2; + my.text.waveText.y = game.config.height/2 - my.text.waveText.displayHeight/2; + + // Game Over Text + my.text.gameOverText = this.add.bitmapText(0, 0, "rocketSquare", "GAME OVER"); + my.text.gameOverText.setScale(2.0); + my.text.gameOverText.x = game.config.width/2 - my.text.gameOverText.displayWidth/2; + my.text.gameOverText.y = game.config.height/2 - my.text.gameOverText.displayHeight/2; + my.text.gameOverText.alpha = 0; + + this.waveTween = this.tweens.chain({ + targets: my.text.waveText, + tweens: [ + { alpha: 0, duration: 1000, ease: 'Sine.easeInOut', repeat: 2}, + { + alpha: 0, + duration: 500, + onComplete: () => { + this.waveTween.destroy(); + this.resetEnemies(); + } + } + ] }); + my.explodeSFX = this.sound.add('DeathEmit', { volume: 0.5, loop: false }); + + // update HTML description + document.getElementById('description').innerHTML = '

Array Boom.js


A: left // D: right // Space: fire/emit // S: Next Scene' } update(time, delta) { let my = this.my; - let dt = delta / 1000; + let dt = delta/1000; + + this.bulletCooldownCounter -= delta; - // Moving left - if (this.left.isDown) { - // Check to make sure the sprite can actually move left - if (my.sprite.elephant.x > (my.sprite.elephant.displayWidth/2)) { - my.sprite.elephant.x -= this.playerSpeed * dt; + // Check for bullet being fired + if (Phaser.Input.Keyboard.JustDown(this.space) && my.sprite.playerShip.isActive) { + if (this.bulletCooldownCounter < 0) { + // Get the first inactive bullet, and make it active + let bullet = my.sprite.bulletGroup.getFirstDead(); + // bullet will be null if there are no inactive (available) bullets + if (bullet != null) { + this.bulletCooldownCounter = this.bulletCooldown; + bullet.makeInactive(); + bullet.makeActive(); + bullet.x = my.sprite.playerShip.x; + bullet.y = my.sprite.playerShip.y - (my.sprite.playerShip.displayHeight/2); + bullet.speed = my.sprite.playerShip.bulletSpeed; + } } } - // Moving right - if (this.right.isDown) { - // Check to make sure the sprite can actually move right - if (my.sprite.elephant.x < (game.config.width - (my.sprite.elephant.displayWidth/2))) { - my.sprite.elephant.x += this.playerSpeed * dt; + // update the player avatar by by calling the playerShip's update() + my.sprite.playerShip.update(time, delta); + + // Hit Enemy + for(let enemy of this.enemies){ + if(!enemy.active || !enemy.visible) continue; + + enemy.firingEnabled = true; + + //Call enemy update + //this.callEnemyUpdate(time, delta, enemy); + enemy.update(time, delta, my.sprite.playerShip.x, my.sprite.enemyBulletGroup); + + if(!enemy.hitbox) continue; + + // Check for collision with the enemy + for(let bullet of my.sprite.bulletGroup.getChildren()){ + if(!bullet.active) continue; + + let bulletBox = { + x: bullet.x, + y: bullet.y, + w: bullet.displayWidth, + h: bullet.displayHeight, + }; + + if(Collisionbox.overlaps(enemy.hitbox, bulletBox)){ + this.hitEnemy(enemy, bullet); + } } } + + // Hit Player + for (let bullet of my.sprite.enemyBulletGroup.getChildren()) { + if (!bullet.active) continue; - // Check for bullet being fired - if (Phaser.Input.Keyboard.JustDown(this.space)) { - // Are we under our bullet quota? - if (my.sprite.bullet.length < this.maxBullets) { - my.sprite.bullet.push(this.add.sprite( - my.sprite.elephant.x, my.sprite.elephant.y-(my.sprite.elephant.displayHeight/2), "heart") - ); + let bulletBox = { + x: bullet.x, + y: bullet.y, + w: bullet.displayWidth, + h: bullet.displayHeight, + }; + + if(Collisionbox.overlaps(my.sprite.playerShip.hitbox, bulletBox)){ + if(bullet.bulletHitAnim){ + console.log("ZOINKS"); + this.explode = this.add.sprite(bullet.x, bullet.y, "bomb1").setScale(2.0).play(bullet.bulletHitAnim); + } + bullet.makeInactive(); + this.puff = this.add.sprite(my.sprite.playerShip.x, my.sprite.playerShip.y, "whitePuff03").setScale(0.25).play("puff"); + my.sprite.playerShip.visible = false; + my.sprite.playerShip.isActive = false; + + //let lastPuff = this.puff; + //lastPuff.once(Phaser.Animations.Events.ANIMATION_COMPLETE, () => { + // this.scene.start("arrayBoom"); + //}, this); + my.explodeSFX.play(); + this.gameOver(); } } - // Remove all of the bullets which are offscreen - // filter() goes through all of the elements of the array, and - // only returns those which **pass** the provided test (conditional) - // In this case, the condition is, is the y value of the bullet - // greater than zero minus half the display height of the bullet? - // (i.e., is the bullet fully offscreen to the top?) - // We store the array returned from filter() back into the bullet - // array, overwriting it. - // This does have the impact of re-creating the bullet array on every - // update() call. - my.sprite.bullet = my.sprite.bullet.filter((bullet) => bullet.y > -(bullet.displayHeight/2)); - - // Check for collision with the hippo - for (let bullet of my.sprite.bullet) { - if (this.collides(my.sprite.hippo, bullet)) { + // Enemy Player Collide + if(!my.sprite.playerShip.hitbox) return; + for (let enemy of this.enemies) { + if(!enemy.active || !enemy.visible || !enemy.hitbox) continue; + if(Collisionbox.overlaps(enemy.hitbox, my.sprite.playerShip.hitbox)){ + + enemy.health = 0; + // start animation - this.puff = this.add.sprite(my.sprite.hippo.x, my.sprite.hippo.y, "whitePuff03").setScale(0.25).play("puff"); - // clear out bullet -- put y offscreen, will get reaped next update - bullet.y = -100; - my.sprite.hippo.visible = false; - my.sprite.hippo.x = -100; - // Update score - this.myScore += my.sprite.hippo.scorePoints; - this.updateScore(); - // Play sound - this.sound.play("dadada", { - volume: 1 // Can adjust volume using this, goes from 0 to 1 - }); - // Have new hippo appear after end of animation - this.puff.on(Phaser.Animations.Events.ANIMATION_COMPLETE, () => { - this.my.sprite.hippo.visible = true; - this.my.sprite.hippo.x = Math.random()*config.width; - }, this); + this.enemypuff = this.add.sprite(enemy.x, enemy.y, "whitePuff03").setScale(0.25).play("puff"); + this.playerpuff = this.add.sprite(my.sprite.playerShip.x, my.sprite.playerShip.y, "whitePuff03").setScale(0.25).play("puff"); + + enemy.visible = false; + enemy.x = -100; + + my.sprite.playerShip.visible = false; + my.sprite.playerShip.isActive = false; + + my.explodeSFX.play(); + this.gameOver(); } } - // Make all of the bullets move - for (let bullet of my.sprite.bullet) { - bullet.y -= this.bulletSpeed * dt; + } + + /* + callEnemyUpdate(time, delta, enemy){ + + let my = this.my; + let type = enemy.constructor.name; + + switch(type){ + case "Fighter": + //console.log("Fighter"); + enemy.update(time, delta, my.sprite.playerShip.x, my.sprite.enemyBulletGroup); + break; + case "Bomber": + //console.log("Bomber"); + enemy.update(time, delta, my.sprite.playerShip.x, my.sprite.enemyBulletGroup); + break; + case "TwinShooter": + //console.log("TwinShooter"); + enemy.update(time, delta, my.sprite.playerShip.x, my.sprite.enemyBulletGroup); + break; + default: + //console.log("Support"); + enemy.update(time, delta, my.sprite.playerShip.x, my.sprite.enemyBulletGroup); + break; + } + } + */ + + gameOver(){ + + let my = this.my; + + my.sprite.playerShip.destroy(); + + this.gameOverTween = this.tweens.chain({ + targets: my.text.gameOverText, + tweens: [ + { + alpha: 1, + duration: 1000, + ease: 'Sine.easeInOut', + }, + { + alpha: 0, + duration: 500, + onComplete: () => { + this.resetSelf(); + this.scene.start("scoreboard"); + } + } + ] + }); + } + + hitEnemy(enemy, bullet){ + + enemy.health --; + bullet.makeInactive(); + + if(enemy.health > 0){ + this.playerHit = this.add.sprite(enemy.x, enemy.y, "bomb3").setScale(2.0).play("playerHit"); + if(enemy.constructor.name === "Bomber") enemy.increaseBulletSpreadCount(); + return; + } + + // start animation + this.puff = this.add.sprite(enemy.x, enemy.y, "whitePuff03").setScale(0.25).play("puff"); + + enemy.visible = false; + enemy.x = -100; + // Update score + this.game.config.score += enemy.scorePoints; + this.updateScore(); + // Play sound + this.my.explodeSFX.play(); + + this.enemyWaveCount --; + if(this.enemyWaveCount > 0) return; + + // Have new wave appear if count is 0 + let lastPuff = this.puff; + lastPuff.once(Phaser.Animations.Events.ANIMATION_COMPLETE, () => { + this.nextWave(); + }, this); + } + + resetEnemies(){ + + let my = this.my; + + my.sprite.enemyBulletGroup.getChildren().forEach(element => { + element.makeInactive(); + }); + + for(let enemy of this.enemies){ + enemy.destroy(); } - if (Phaser.Input.Keyboard.JustDown(this.nextScene)) { - this.scene.start("singleBullet"); + this.enemies = []; + + this.levelCreator(); + + if(this.enemyContainer) this.enemyContainer.destroy(); + this.enemyContainer = this.add.container(0, 0, this.enemies); + + let tweenTargets = this.enemies.filter( + enemy => !(enemy instanceof Bomber) && + !(enemy instanceof TwinShooter) && + !(enemy instanceof Support) + ); + + if(this.moveXTween) this.moveXTween.destroy(); + if(tweenTargets.length > 0){ + this.moveXTween = this.tweens.add({ + targets: tweenTargets, + x: { + getStart: (target) => target.startX, + getEnd: (target) => target.startX - 64, + }, + duration: 500, + ease: 'Sine.easeInOut', + yoyo: true, + repeat: -1 + }); } + if(this.moveYTween) this.moveYTween.destroy(); + this.moveYTween = this.tweens.add({ + targets: this.enemyContainer, + y: { + getStart: (target) => 0, + getEnd: (target) => -25, + }, + duration: 1500, + ease: 'Quad.easeInOut', + yoyo: true, + repeat: -1 + }); + + //this.myScore += this.wave * 1000; + //this.wave += 1; + //this.updateScore(); + + this.enemyWaveCount = this.enemies.length; } - // A center-radius AABB collision check - collides(a, b) { - if (Math.abs(a.x - b.x) > (a.displayWidth/2 + b.displayWidth/2)) return false; - if (Math.abs(a.y - b.y) > (a.displayHeight/2 + b.displayHeight/2)) return false; - return true; + nextWave(){ + this.game.config.score += 500; + this.updateScore(); + + this.enemyMaxWaveCount += 4; + if(this.enemyMaxWaveCount>54){ + this.enemyMaxWaveCount = 54; + } + + this.wave++; + this.updateWave(); } updateScore() { let my = this.my; - my.text.score.setText("Score " + this.myScore); + my.text.score.setText("Score " + this.game.config.score); + my.text.score.x = game.config.width - (my.text.score.displayWidth + 5); + } + + updateWave(){ + let my = this.my; + + my.text.waveText.setText("Wave " + this.wave); + my.text.waveText.x = game.config.width/2 - my.text.waveText.displayWidth/2; + my.text.waveText.y = game.config.height/2 - my.text.waveText.displayHeight/2; + //my.text.waveText.alpha = 1.0; + + this.waveTween = this.tweens.chain({ + targets: my.text.waveText, + tweens: [ + { alpha: 1, duration: 1000, ease: 'Sine.easeInOut', repeat: 2}, + { + alpha: 0, + duration: 500, + onComplete: () => { + this.waveTween.destroy(); + this.resetEnemies(); + } + } + ] + }); + } + + levelCreator(){ + + let lvl = this.wave - 1; + + if(lvl > this.levelObjectArr.length - 1) lvl = this.getIntFromRange(0, this.levelObjectArr.length - 1); + + console.log(lvl); + let levelObj = this.levelObjectArr[lvl]; + + this.createRow(levelObj.fighter[0], levelObj.fighter[1], levelObj.fighter[2], Fighter); + this.createRow(levelObj.bomber[0], levelObj.bomber[1], levelObj.bomber[2], Bomber); + this.createRow(levelObj.twinShooter[0], levelObj.twinShooter[1], levelObj.twinShooter[2], TwinShooter); + this.createRow(levelObj.support[0], levelObj.support[1], levelObj.support[2], Support); + + } + + createRow(startX, startY, enemyNum, enemyType){ + + if(enemyNum<=0) return; + + startX = (enemyNum > 1) ? startX : game.config.width/2; + let endX = game.config.width - startX; + let dx = endX - startX; + let inc = (enemyNum > 1) ? dx / (enemyNum - 1) : 0; + + for(let i=0; i < enemyNum; i++){ + + //let col = i % columns; + //let row = Math.floor(i/columns); + + //let x = startX + col * size; + //let y = startY + row * size; + + let x = startX + i * inc; + let y = startY; + + this.enemies.push(new enemyType(this, x, y, this.my.sprite.playerShip)); + + } + } + resetSelf(){ + + this.my.sprite.playerShip.setActive(); + this.playerSpeed = 600; + + this.bulletCooldown = 250; // Number of update() calls to wait before making a new bullet + this.bulletCooldownCounter = 0; + + for(let enemy of this.enemies){ + enemy.destroy(); + } + + this.enemies = []; + + this.enemyWaveCount = 0; + this.wave = 1; + + } + + getIntFromRange(min, max){ + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; + } } \ No newline at end of file diff --git a/src/Scenes/ArrayBullet.js b/src/Scenes/ArrayBullet.js deleted file mode 100644 index ba9b44b..0000000 --- a/src/Scenes/ArrayBullet.js +++ /dev/null @@ -1,101 +0,0 @@ -class ArrayBullet extends Phaser.Scene { - constructor() { - super("arrayBullet"); - - // Initialize a class variable "my" which is an object. - // The object has one property, "sprite" which is also an object. - // This will be used to hold bindings (pointers) to created sprites. - this.my = {sprite: {}}; - - // Create a property inside "sprite" named "bullet". - // The bullet property has a value which is an array. - // This array will hold bindings (pointers) to bullet sprites - this.my.sprite.bullet = []; - this.maxBullets = 10; // Don't create more than this many bullets - - } - - preload() { - this.load.setPath("./assets/"); - this.load.image("elephant", "elephant.png"); - this.load.image("heart", "heart.png"); - } - - create() { - let my = this.my; - - my.sprite.elephant = this.add.sprite(game.config.width/2, game.config.height - 40, "elephant"); - my.sprite.elephant.setScale(0.25); - - // Notice that in this approach, we don't create any bullet sprites in create(), - // and instead wait until we need them, based on the number of space bar presses - - // Create key objects - this.left = this.input.keyboard.addKey("A"); - this.right = this.input.keyboard.addKey("D"); - this.nextScene = this.input.keyboard.addKey("S"); - this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - - // Set movement speeds (in pixels/sec) - this.playerSpeed = 300; - this.bulletSpeed = 300; - - // update HTML description - document.getElementById('description').innerHTML = '

Array Bullet.js


A: left // D: right // Space: fire/emit // S: Next Scene' - - } - - update(time, delta) { - let my = this.my; - let dt = delta / 1000; - - // Moving left - if (this.left.isDown) { - // Check to make sure the sprite can actually move left - if (my.sprite.elephant.x > (my.sprite.elephant.displayWidth/2)) { - my.sprite.elephant.x -= this.playerSpeed * dt; - } - } - - // Moving right - if (this.right.isDown) { - // Check to make sure the sprite can actually move right - if (my.sprite.elephant.x < (game.config.width - (my.sprite.elephant.displayWidth/2))) { - my.sprite.elephant.x += this.playerSpeed * dt; - } - } - - // Check for bullet being fired - if (Phaser.Input.Keyboard.JustDown(this.space)) { - // Are we under our bullet quota? - if (my.sprite.bullet.length < this.maxBullets) { - my.sprite.bullet.push(this.add.sprite( - my.sprite.elephant.x, my.sprite.elephant.y-(my.sprite.elephant.displayHeight/2), "heart") - ); - } - } - - // Make all of the bullets move - for (let bullet of my.sprite.bullet) { - bullet.y -= this.bulletSpeed * dt; - } - - // Remove all of the bullets which are offscreen - // filter() goes through all of the elements of the array, and - // only returns those which **pass** the provided test (conditional) - // In this case, the condition is, is the y value of the bullet - // greater than zero minus half the display height of the bullet? - // (i.e., is the bullet fully offscreen to the top?) - // We store the array returned from filter() back into the bullet - // array, overwriting it. - // This does have the impact of re-creating the bullet array on every - // update() call (not great, leads to more garbage collection over time). - my.sprite.bullet = my.sprite.bullet.filter((bullet) => bullet.y > -(bullet.displayHeight/2)); - - if (Phaser.Input.Keyboard.JustDown(this.nextScene)) { - this.scene.start("fixedArrayBullet"); - } - - } -} - \ No newline at end of file diff --git a/src/Scenes/ClassBullet.js b/src/Scenes/ClassBullet.js deleted file mode 100644 index 402eb37..0000000 --- a/src/Scenes/ClassBullet.js +++ /dev/null @@ -1,94 +0,0 @@ -class ClassBullet extends Phaser.Scene { - constructor() { - super("classBullet"); - - // Initialize a class variable "my" which is an object. - // The object has one property, "sprite" which is also an object. - // This will be used to hold bindings (pointers) to created sprites. - this.my = {sprite: {}}; - - // Set movement speeds (in pixels/sec) - this.playerSpeed = 300; - this.bulletSpeed = 300; - - this.bulletCooldown = 3; // Number of update() calls to wait before making a new bullet - this.bulletCooldownCounter = 0; - - } - - preload() { - this.load.setPath("./assets/"); - this.load.image("elephant", "elephant.png"); - this.load.image("heart", "heart.png"); - } - - create() { - let my = this.my; - - // Create key objects - this.left = this.input.keyboard.addKey("A"); - this.right = this.input.keyboard.addKey("D"); - this.nextScene = this.input.keyboard.addKey("S"); - this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - - my.sprite.elephant = new Player(this, game.config.width/2, game.config.height - 40, "elephant", null, - this.left, this.right, this.playerSpeed); - my.sprite.elephant.setScale(0.25); - - // In this approach, we create a single "group" game object which then holds up - // to 10 bullet sprites - // See more configuration options here: - // https://rexrainbow.github.io/phaser3-rex-notes/docs/site/group/ - my.sprite.bulletGroup = this.add.group({ - active: true, - defaultKey: "heart", - maxSize: 10, - runChildUpdate: true - } - ) - - // Create all of the bullets at once, and set them to inactive - // See more configuration options here: - // https://rexrainbow.github.io/phaser3-rex-notes/docs/site/group/ - my.sprite.bulletGroup.createMultiple({ - classType: Bullet, - active: false, - key: my.sprite.bulletGroup.defaultKey, - repeat: my.sprite.bulletGroup.maxSize-1 - }); - my.sprite.bulletGroup.propertyValueSet("speed", this.bulletSpeed); - - // update HTML description - document.getElementById('description').innerHTML = '

Class Bullet.js


A: left // D: right // Space: fire/emit // S: Next Scene' - - } - - update(time, delta) { - let my = this.my; - this.bulletCooldownCounter--; - - // Check for bullet being fired - if (this.space.isDown) { - if (this.bulletCooldownCounter < 0) { - // Get the first inactive bullet, and make it active - let bullet = my.sprite.bulletGroup.getFirstDead(); - // bullet will be null if there are no inactive (available) bullets - if (bullet != null) { - this.bulletCooldownCounter = this.bulletCooldown; - bullet.makeActive(); - bullet.x = my.sprite.elephant.x; - bullet.y = my.sprite.elephant.y - (my.sprite.elephant.displayHeight/2); - } - } - } - - // update the player avatar by by calling the elephant's update() - my.sprite.elephant.update(time, delta); - - if (Phaser.Input.Keyboard.JustDown(this.nextScene)) { - this.scene.start("arrayBoom"); - } - - } -} - \ No newline at end of file diff --git a/src/Scenes/FixedArrayBullet.js b/src/Scenes/FixedArrayBullet.js deleted file mode 100644 index 852d273..0000000 --- a/src/Scenes/FixedArrayBullet.js +++ /dev/null @@ -1,114 +0,0 @@ -class FixedArrayBullet extends Phaser.Scene { - constructor() { - super("fixedArrayBullet"); - - // Initialize a class variable "my" which is an object. - // The object has one property, "sprite" which is also an object. - // This will be used to hold bindings (pointers) to created sprites. - this.my = {sprite: {}}; - - // Create a property inside "sprite" named "bullet". - // The bullet property has a value which is an array. - // This array will hold bindings (pointers) to bullet sprites - this.my.sprite.bullet = []; - this.maxBullets = 10; // Don't create more than this many bullets - this.bulletCooldown = 3; // Number of update() calls to wait before making a new bullet - this.bulletCooldownCounter = 0; - - } - - preload() { - this.load.setPath("./assets/"); - this.load.image("elephant", "elephant.png"); - this.load.image("heart", "heart.png"); - } - - create() { - let my = this.my; - - my.sprite.elephant = this.add.sprite(game.config.width/2, game.config.height - 40, "elephant"); - my.sprite.elephant.setScale(0.25); - - // In this approach we *do* create all of the bullet sprites in create(), since we will just - // keep reusing them - for (let i=0; i < this.maxBullets; i++) { - // create a sprite which is offscreen and invisible - my.sprite.bullet.push(this.add.sprite(-100, -100, "heart")); - my.sprite.bullet[i].visible = false; - } - - // Create key objects - this.left = this.input.keyboard.addKey("A"); - this.right = this.input.keyboard.addKey("D"); - this.nextScene = this.input.keyboard.addKey("S"); - this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - - // Set movement speeds (in pixels/sec) - this.playerSpeed = 300; - this.bulletSpeed = 300; - - // update HTML description - document.getElementById('description').innerHTML = '

Fixed Array Bullet.js


A: left // D: right // Space: fire/emit // S: Next Scene' - - } - - update(time, delta) { - let my = this.my; - let dt = delta / 1000; - this.bulletCooldownCounter--; - - // Moving left - if (this.left.isDown) { - // Check to make sure the sprite can actually move left - if (my.sprite.elephant.x > (my.sprite.elephant.displayWidth/2)) { - my.sprite.elephant.x -= this.playerSpeed * dt; - } - } - - // Moving right - if (this.right.isDown) { - // Check to make sure the sprite can actually move right - if (my.sprite.elephant.x < (game.config.width - (my.sprite.elephant.displayWidth/2))) { - my.sprite.elephant.x += this.playerSpeed * dt; - } - } - - // Check for bullet being fired - if (this.space.isDown) { - if (this.bulletCooldownCounter < 0) { - // Check for an available bullet - for (let bullet of my.sprite.bullet) { - // If the bullet is invisible, it's available - if (!bullet.visible) { - bullet.x = my.sprite.elephant.x; - bullet.y = my.sprite.elephant.y - (bullet.displayHeight/2); - bullet.visible = true; - this.bulletCooldownCounter = this.bulletCooldown; - break; // Exit the loop, so we only activate one bullet at a time - } - } - } - - } - - // Make all of the bullets move - for (let bullet of my.sprite.bullet) { - // if the bullet is visibile it's active, so move it - if (bullet.visible) { - bullet.y -= this.bulletSpeed * dt; - } - // Did the bullet move offscreen? If so, - // make it inactive (make it invisible) - // This allows us to re-use bullet sprites - if (bullet.y < -(bullet.displayHeight/2)) { - bullet.visible = false; - } - } - - if (Phaser.Input.Keyboard.JustDown(this.nextScene)) { - this.scene.start("groupBullet"); - } - - } -} - \ No newline at end of file diff --git a/src/Scenes/GroupBullet.js b/src/Scenes/GroupBullet.js deleted file mode 100644 index c898320..0000000 --- a/src/Scenes/GroupBullet.js +++ /dev/null @@ -1,116 +0,0 @@ -class GroupBullet extends Phaser.Scene { - constructor() { - super("groupBullet"); - - // Initialize a class variable "my" which is an object. - // The object has one property, "sprite" which is also an object. - // This will be used to hold bindings (pointers) to created sprites. - this.my = {sprite: {}}; - - this.bulletCooldown = 3; // Number of update() calls to wait before making a new bullet - this.bulletCooldownCounter = 0; - - } - - preload() { - this.load.setPath("./assets/"); - this.load.image("elephant", "elephant.png"); - this.load.image("heart", "heart.png"); - } - - create() { - let my = this.my; - - my.sprite.elephant = this.add.sprite(game.config.width/2, game.config.height - 40, "elephant"); - my.sprite.elephant.setScale(0.25); - - // In this approach, we create a single "group" game object which then holds up - // to 10 bullet sprites - // See more configuration options here: - // https://rexrainbow.github.io/phaser3-rex-notes/docs/site/group/ - my.sprite.bulletGroup = this.add.group({ - defaultKey: "heart", - maxSize: 10 - } - ) - - // Create all of the bullets at once, and set them to inactive - // See more configuration options here: - // https://rexrainbow.github.io/phaser3-rex-notes/docs/site/group/ - my.sprite.bulletGroup.createMultiple({ - active: false, - key: my.sprite.bulletGroup.defaultKey, - repeat: my.sprite.bulletGroup.maxSize-1 - }); - - // Create key objects - this.left = this.input.keyboard.addKey("A"); - this.right = this.input.keyboard.addKey("D"); - this.nextScene = this.input.keyboard.addKey("S"); - this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - - // Set movement speeds (in pixels/sec) - this.playerSpeed = 300; - this.bulletSpeed = 300; - - // update HTML description - document.getElementById('description').innerHTML = '

Game Object Group Bullet.js


A: left // D: right // Space: fire/emit // S: Next Scene' - - } - - update(time, delta) { - let my = this.my; - let dt = delta / 1000; - - this.bulletCooldownCounter--; - - // Moving left - if (this.left.isDown) { - // Check to make sure the sprite can actually move left - if (my.sprite.elephant.x > (my.sprite.elephant.displayWidth/2)) { - my.sprite.elephant.x -= this.playerSpeed * dt; - } - } - - // Moving right - if (this.right.isDown) { - // Check to make sure the sprite can actually move right - if (my.sprite.elephant.x < (game.config.width - (my.sprite.elephant.displayWidth/2))) { - my.sprite.elephant.x += this.playerSpeed * dt; - } - } - - // Check for bullet being fired - if (this.space.isDown) { - if (this.bulletCooldownCounter < 0) { - // Get the first inactive bullet, and make it active - let bullet = my.sprite.bulletGroup.getFirstDead(); - // bullet will be null if there are no inactive (available) bullets - if (bullet != null) { - bullet.active = true; - bullet.visible = true; - bullet.x = my.sprite.elephant.x; - bullet.y = my.sprite.elephant.y - (my.sprite.elephant.displayHeight/2); - this.bulletCooldownCounter = this.bulletCooldown; - } - } - } - - // check for bullet going offscreen - for (let bullet of my.sprite.bulletGroup.getChildren()) { - if (bullet.y < -(bullet.displayHeight/2)) { - bullet.active = false; - bullet.visible = false; - } - } - - // move bullets - my.sprite.bulletGroup.incY(-this.bulletSpeed*dt); - - if (Phaser.Input.Keyboard.JustDown(this.nextScene)) { - this.scene.start("classBullet"); - } - - } -} - \ No newline at end of file diff --git a/src/Scenes/MainMenu.js b/src/Scenes/MainMenu.js new file mode 100644 index 0000000..fbe5095 --- /dev/null +++ b/src/Scenes/MainMenu.js @@ -0,0 +1,82 @@ +class MainMenu extends Phaser.Scene { + constructor() { + super("mainMenu"); + this.my = {sprite: {}, text: {}}; + } + + preload() { + + this.load.setPath("./assets/"); + + //Player Sprites + this.load.image("playerShip", "kenney_pixel-shmup/Ships/ship_0012.png"); + this.load.image("playerShot", "kenney_pixel-shmup/Tiles/tile_0000.png"); + + //Fighter Sprites + this.load.image("fighter", "kenney_pixel-shmup/Ships/ship_0002.png"); + + //Bomber Sprites + this.load.image("bomber", "kenney_pixel-shmup/Ships/ship_0003.png"); + this.load.image("bomb0", "kenney_pixel-shmup/Tiles/tile_0004.png"); + this.load.image("bomb1", "kenney_pixel-shmup/Tiles/tile_0006.png"); + this.load.image("bomb2", "kenney_pixel-shmup/Tiles/tile_0005.png"); + this.load.image("bomb3", "kenney_pixel-shmup/Tiles/tile_0007.png"); + this.load.image("bomb4", "kenney_pixel-shmup/Tiles/tile_0008.png"); + + //Twinshooter Sprites + this.load.image("twinshooter", "kenney_pixel-shmup/Ships/ship_0008.png"); + this.load.image("twinshot", "kenney_pixel-shmup/Tiles/tile_0001.png"); + + //Support sprites + this.load.image("support", "kenney_pixel-shmup/Ships/ship_0009.png"); + + //Load Bitmap Font + this.load.bitmapFont("rocketSquare", "KennyRocketSquare_0.png", "KennyRocketSquare.fnt"); + + // Audio + this.load.audio("BGM", "CyberMenuSong.mp3"); + //this.load.audio("Death", "RRES.ogg"); + } + + create() { + let my = this.my; + + // Create key objects + this.left = this.input.keyboard.addKey("A"); + this.right = this.input.keyboard.addKey("D"); + this.nextScene = this.input.keyboard.addKey("S"); + this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + + my.text.mainMenuText = this.add.bitmapText(0, 0, "rocketSquare", "JetFighter"); + my.text.mainMenuText.setScale(2.0); + my.text.mainMenuText.scaleY *= 4.0; + my.text.mainMenuText.x = game.config.width/2 - my.text.mainMenuText.displayWidth/2; + my.text.mainMenuText.y = game.config.height/2 - my.text.mainMenuText.displayHeight/2; + + my.text.mainMenuText.setInteractive(); + + my.text.mainMenuText.on('pointerdown', (pointer) => { + this.scene.start("arrayBoom"); + }); + + my.sprite.menuFighter = this.add.sprite(game.config.width/2, game.config.height/2, "fighter"); + my.sprite.menuFighter.setScale(12.0); + my.sprite.menuFighter.rotation = 202.5 * (Math.PI / 180); + my.sprite.menuFighter.setDepth(-1); + + this.mainMenuTween = this.tweens.chain({ + targets: [my.text.mainMenuText, my.sprite.menuFighter], + tweens: [ + { y: '-= 50', duration: 1000, ease: 'Sine.easeInOut', repeat: -1, yoyo: true}, + ] + }); + + this.backgroundMusic = this.sound.add('BGM', { volume: 0.5, loop: true }); + this.backgroundMusic.play(); + } + + + //if (Phaser.Input.Keyboard.JustDown(this.nextScene)) { + // this.scene.start("fixedArrayBullet"); + // } +} \ No newline at end of file diff --git a/src/Scenes/Scoreboard.js b/src/Scenes/Scoreboard.js new file mode 100644 index 0000000..134c576 --- /dev/null +++ b/src/Scenes/Scoreboard.js @@ -0,0 +1,106 @@ +class Scoreboard extends Phaser.Scene { + constructor() { + super("scoreboard"); + this.my = {sprite: {}, text: {}}; + } + + preload() { + + this.load.setPath("./assets/"); + + //Load Bitmap Font + this.load.bitmapFont("rocketSquare", "KennyRocketSquare_0.png", "KennyRocketSquare.fnt"); + + } + + create() { + let my = this.my; + + // Create key objects + this.left = this.input.keyboard.addKey("A"); + this.right = this.input.keyboard.addKey("D"); + this.nextScene = this.input.keyboard.addKey("S"); + this.space = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + + my.text.scoreBoard = this.add.bitmapText(0, 0, "rocketSquare", "Scoreboard"); + my.text.scoreBoard.setScale(2.0); + my.text.scoreBoard.x = game.config.width/2 - my.text.scoreBoard.displayWidth/2 + my.text.scoreBoard.y = 10; + + my.text.scoreText = this.add.bitmapText(0, 0, "rocketSquare", "Score: 0"); + my.text.scoreText.setScale(1.0); + my.text.scoreText.x = game.config.width/2 - my.text.scoreText.displayWidth/2; + my.text.scoreText.y = game.config.height/2 - my.text.scoreText.displayHeight/2; + + my.text.menuText = this.add.bitmapText(0, 0, "rocketSquare", "Main Menu"); + my.text.menuText.setScale(1.0); + my.text.menuText.x = 5; + my.text.menuText.y = game.config.height - my.text.menuText.displayHeight - 5; + my.text.menuText.setInteractive(); + + my.text.menuText.on('pointerdown', (pointer) => { + this.game.config.score = 0; + this.scene.start("mainMenu"); + }); + + my.text.returnText = this.add.bitmapText(0, 0, "rocketSquare", "Return?"); + my.text.returnText.setScale(1.0); + my.text.returnText.x = game.config.width - my.text.returnText.displayWidth; + my.text.returnText.y = game.config.height - my.text.returnText.displayHeight - 5; + my.text.returnText.setInteractive(); + + my.text.returnText.on('pointerdown', (pointer) => { + this.game.config.score = 0; + this.scene.start("arrayBoom"); + }); + + let t = {progress: 0}; + + let scoreScale = 1.0; + + if(this.game.config.score >= 1000){ + scoreScale = 1.5; + } if(this.game.config.score >= 5000){ + scoreScale = 1.75; + } if(this.game.config.score >= 10000){ + scoreScale = 2.0; + } + + this.scoreTween = this.tweens.add({ + targets: [t, my.text.scoreText], + scale: scoreScale, + progress: 1, + duration: 10000, + ease: 'Expo.easeIn', + onUpdate: () => { + let scorePrint = this.game.config.score * t.progress; + + my.text.scoreText.setText(`Score: ${(this.game.config.score * t.progress).toFixed(0)}`); + my.text.scoreText.x = game.config.width/2 - my.text.scoreText.displayWidth/2; + my.text.scoreText.y = game.config.height/2 - my.text.scoreText.displayHeight/2; + }, + onComplete: () => { + this.game.config.score = 0; + //console.log(this.game.config.score); + } + }); + + +/* + my.sprite.menuFighter = this.add.sprite(game.config.width/2, game.config.height/2, "fighter"); + my.sprite.menuFighter.setScale(12.0); + my.sprite.menuFighter.rotation = 202.5 * (Math.PI / 180); + my.sprite.menuFighter.setDepth(-1); + + this.mainMenuTween = this.tweens.chain({ + targets: [my.text.mainMenuText, my.sprite.menuFighter], + tweens: [ + { y: '-= 50', duration: 1000, ease: 'Sine.easeInOut', repeat: -1, yoyo: true}, + ] + }); + */ + } + //if (Phaser.Input.Keyboard.JustDown(this.nextScene)) { + // this.scene.start("fixedArrayBullet"); + // } +} \ No newline at end of file diff --git a/src/Sprites/Bullet.js b/src/Sprites/Bullet.js index d29a00c..1932181 100644 --- a/src/Sprites/Bullet.js +++ b/src/Sprites/Bullet.js @@ -3,14 +3,76 @@ class Bullet extends Phaser.GameObjects.Sprite { super(scene, x, y, texture, frame); this.visible = false; this.active = false; - return this; + + this.bulletAnim = null; + this.bulletHitAnim = null; + this.speed = 0; + this.velocityX = 0; + this.velocityY = 0; + this.useVelocity = false; + + // Twinshooter wiggle state + this.wiggle = false; + this.baseX = 0; + this.baseY = 0; + this.wiggleTime = 0; + this.wiggleFrequency = 0; + this.wiggleAmp = 0; + this.baseAngle = 0; + this.twinShotDir = 0; + + // Bomber Bomb State + this.isBomb = false; + this.bomberAimAngle = 0; + this.bombThreshold = 0; + this.onBombThreshold = null; + this.enemyBulletGroup = null; + } update(time, delta) { let dt = delta / 1000; if (this.active) { - this.y -= this.speed * dt; - if (this.y < -(this.displayHeight/2)) { + if(this.wiggle){ + + this.wiggleTime += dt; + + let travelDist = this.speed * (delta / 1000); + this.baseX += Math.cos(this.baseAngle) * travelDist; + this.baseY += Math.sin(this.baseAngle) * travelDist; + + let perpX = -Math.sin(this.baseAngle); + let perpY = Math.cos(this.baseAngle); + + let displacement = this.wiggleAmp * Math.sin(this.wiggleTime * this.wiggleFrequency * Math.PI * 2.0) * this.twinShotDir; + + this.x = this.baseX + perpX * displacement; + this.y = this.baseY + perpY * displacement; + } + else{ + if(this.useVelocity){ + this.x += this.velocityX * dt; + this.y += this.velocityY * dt; + } else { + this.y += this.speed * dt; + } + } + + if(this.isBomb && this.onBombThreshold && this.y >= this.bombThreshold){ + let cb = this.onBombThreshold; + let group = this.enemyBulletGroup; + + this.onBombThreshold = null; + this.enemyBulletGroup = null; + cb(this, group); + } + + if ( + this.y < -(this.displayHeight/2) || + this.y > this.scene.scale.height + this.displayHeight || + this.x < -(this.displayWidth/2) || + this.x > this.scene.scale.width + this.displayWidth + ) { this.makeInactive(); } } @@ -22,8 +84,36 @@ class Bullet extends Phaser.GameObjects.Sprite { } makeInactive() { + this.visible = false; this.active = false; + if(this.anims) this.anims.stop(); + + this.bulletAnim = null; + this.bulletHitAnim = null; + this.speed = 0; + this.useVelocity = false; + this.velocityX = 0; + this.velocityY = 0; + this.flipY = false; + this.rotation = 0; + + // Twinshooter wiggle state + this.wiggle = false; + this.baseX = 0; + this.baseY = 0; + this.wiggleTime = 0; + this.wiggleFrequency = 0; + this.wiggleAmp = 0; + this.baseAngle = 0; + this.twinShotDir = 0; + + // Bomber Bomb State + this.isBomb = false; + this.bomberAimAngle = 0; + this.bombThreshold = 0; + this.onBombThreshold = null; + this.enemyBulletGroup = null; } } \ No newline at end of file diff --git a/src/Sprites/Collisionbox.js b/src/Sprites/Collisionbox.js new file mode 100644 index 0000000..3d2b646 --- /dev/null +++ b/src/Sprites/Collisionbox.js @@ -0,0 +1,43 @@ +class Collisionbox { + + constructor(scene, owner, width, height, debugShow = false){ + this.scene = scene; + this.owner = owner; + this.w = width; + this.h = height; + this.debugShow = debugShow; + + this.x = 0; + this.y = 0; + + this.gfx = scene.add.graphics(); + this.gfx.setDepth(9999); + } + + update(worldX, worldY){ + this.x = worldX; + this.y = worldY; + + this.gfx.clear(); + if(!this.debugShow) return; + + this.gfx.lineStyle(1, 0x0000ff, 1); + this.gfx.strokeRect( + this.x - this.w/2, + this.y - this.h/2, + this.w, + this.h, + ); + } + + static overlaps(a,b){ + return( + (Math.abs(a.x - b.x) <= (a.w/2 + b.w/2)) && + (Math.abs(a.y - b.y) <= (a.h/2 + b.h/2)) + ); + } + + destroy(){ + this.gfx.destroy(); + } +} \ No newline at end of file diff --git a/src/Sprites/Enemy.js b/src/Sprites/Enemy.js new file mode 100644 index 0000000..1747781 --- /dev/null +++ b/src/Sprites/Enemy.js @@ -0,0 +1,611 @@ +class Enemy extends Phaser.GameObjects.Sprite { + constructor(scene, x, y, texture, health, scorePoints){ + super(scene, x, y, texture); + scene.add.existing(this); + + this.health = health; + this.scorePoints = scorePoints; + this.startX = x; + this.startY = y; + this.firingEnabled = false; + + this.hitbox = null; + } + + initHitbox(width, height){ + let show = this.scene.showHitboxes || false; + this.hitbox = new Collisionbox(this.scene, this, width, height, show); + } + + updateHitbox(worldX, worldY){ + if(this.hitbox) this.hitbox.update(worldX, worldY); + } + + spawnBullet(enemyBulletGroup, worldX, worldY){ + let bullet = enemyBulletGroup.getFirstDead(); + if(!bullet) return null; + + bullet.makeInactive(); + bullet.makeActive(); + bullet.setTexture(this.bulletTexture); + bullet.bulletAnim = this.bulletAnim; + bullet.bulletHitAnim = this.bulletHitAnim; + bullet.speed = this.shotSpeed; + bullet.setScale(this.bulletScale); + bullet.flipY = true; + bullet.useVelocity = false; + bullet.velocityX = 0; + bullet.velocityY = 0; + bullet.x = worldX; + bullet.y = worldY; + bullet.rotation = 0; + + // Twinshooter wiggle state + bullet.wiggle = false; + bullet.baseX = 0; + bullet.baseY = 0; + bullet.wiggleTime = 0; + bullet.wiggleFrequency = 0; + bullet.wiggleAmp = 0; + bullet.baseAngle = 0; + bullet.twinShotDir = 0; + + // Bomber Bomb State + bullet.isBomb = false; + bullet.bomberAimAngle = 0; + + if(bullet.bulletAnim){ + bullet.play(this.bulletAnim); + } else { + bullet.stop(); + } + + return bullet; + } + + destroy(fromScene){ + if(this.hitbox) this.hitbox.destroy(); + super.destroy(fromScene); + } +} + +class Fighter extends Enemy{ + constructor(scene, x, y){ + super(scene, x, y, "fighter", 2, 100); + this.setScale(2.0); + this.flipY = true; + + this.shotSpeed = 500; + this.firingEnabled = false; + this.fireCooldown = 5000; + this.fireCooldownCounter = (Math.random() * this.fireCooldown / 2.0) + (this.fireCooldown / 2.0); + this.bulletTexture = "playerShot"; + this.bulletScale = 2.0; + this.bulletAnim = null; + this.bulletHitAnim = null; + + //Shotgun + this.bulletSpreadCount = 5; + this.bulletSpread = 10; + + //Dive Stuffs + this.diveSpeed = 400; + this.diving = false; + this.reentering = false; + this.follower = null; + this.divePath = null; + this.callShotGun = false; + + this.diveAngle = 0; + + this.initHitbox(28, 32); + } + + startDive(playerX, enemyBulletGroup){ + let container = this.scene.enemyContainer; + + let worldX = this.x + container.x; + let worldY = this.y + container.y; + + let targetX = playerX; + let targetY = this.scene.scale.height + this.displayHeight; + + this.divePath = new Phaser.Curves.Path(worldX, worldY); + this.divePath.lineTo(targetX, targetY); + + let pathLen = Phaser.Math.Distance.Between(worldX, worldY, targetX, targetY); + let duration = (pathLen / this.diveSpeed) * 1000; // MS for delta + + this.follower = this.scene.add.follower(this.divePath, worldX, worldY, "fighter"); + this.follower.setScale(0); //Invisible to move enemy sprite manually + this.follower.startFollow({ + duration: duration, + ease: "Linear", + repeat: 0, + rotateToPath: false, + onComplete: () => this.endDive() + }); + + let dx = targetX - worldX; + let dy = targetY - worldY; + this.diveAngle = Math.atan2(dy, dx); + this.rotation = this.diveAngle - Math.PI / 2; + + this.diving = true; + + this.diveShotgun(worldX, worldY, enemyBulletGroup); + } + + diveShotgun(worldX, worldY, enemyBulletGroup){ + this.callShotGun = false; + let spreadRad = this.bulletSpread * Math.PI / 180.0; + let initAngle = this.diveAngle - spreadRad * (this.bulletSpreadCount - 1) / 2; + for(let i=0; i { + this.reentering = false; + this.fireCooldownCounter = this.fireCooldown; + } + }); + + } + + update(time, delta, playerX, enemyBulletGroup){ + + if(!this.firingEnabled) return; + + if(this.diving) { + if(this.follower){ + + let container = this.scene.enemyContainer; + + this.x = this.follower.x - container.x; + this.y = this.follower.y - container.y; + + let worldX = this.follower.x; + let worldY = this.follower.y; + + //console.log(`(${worldX}, ${worldY})`); + this.updateHitbox(worldX, worldY); + } + return; + } + + let worldX = this.x + this.scene.enemyContainer.x; + let worldY = this.y + this.scene.enemyContainer.y; + + this.updateHitbox(worldX, worldY); + + //if(this.callShotGun) this.diveShotgun(worldX, worldY, enemyBulletGroup); + if (this.reentering) return; + + this.fireCooldownCounter -= delta; + if(this.fireCooldownCounter > 0) return; + this.startDive(playerX, enemyBulletGroup); + } +} + +class Bomber extends Enemy{ + constructor(scene, x, y){ + super(scene, x, y, "bomber", 1, 100); + this.setScale(2.0); + this.flipY = true; + + this.shotSpeed = 250; + this.firingEnabled = false; + this.fireCooldown = 7500; + this.fireCooldownCounter = (Math.random() * this.fireCooldown / 4.0) + 3.0 * (this.fireCooldown / 4.0); + this.bulletTexture = "bomb1"; + this.bulletScale = 3.0; + this.bulletAnim = "ANIMbomb"; + this.bulletHitAnim = "explosion"; + + //Emits on explosion + this.bulletSpreadCount = 8; + this.bulletSpreadSpeed = 100; + this.bulletSpreadRatio = 0.6; // When the bullets explode + + this.initHitbox(30, 30); + } + + update(time, delta, playerX, enemyBulletGroup){ + + if(!this.firingEnabled) return; + + let worldX = this.x + this.scene.enemyContainer.x; + let worldY = this.y + this.scene.enemyContainer.y; + + this.updateHitbox(worldX, worldY); + + let dx = playerX - worldX; + let dy = this.scene.scale.height - worldY; + let aimAngle = Math.atan2(dy, dx); + this.rotation = aimAngle - Math.PI / 2.0; + + this.fireCooldownCounter -= delta; + if(this.fireCooldownCounter > 0) return; + this.fireCooldownCounter = this.fireCooldown; + + let bullet = this.spawnBullet(enemyBulletGroup, worldX, worldY); + if(!bullet) return; + + bullet.isBomb = true; + bullet.bomberAimAngle = aimAngle; + bullet.useVelocity = true; + bullet.velocityX = Math.cos(aimAngle) * this.shotSpeed; + bullet.velocityY = Math.sin(aimAngle) * this.shotSpeed; + bullet.rotation = aimAngle - Math.PI / 2.0; + bullet.bombThreshold = this.scene.scale.height * this.bulletSpreadRatio; + bullet.enemyBulletGroup = enemyBulletGroup; + bullet.onBombThreshold = (b, group) => this.explodeBomb(b, group); + } + + explodeBomb(bomb, enemyBulletGroup){ + + let bx = bomb.x; + let by = bomb.y; + let aimAngle = bomb.bomberAimAngle; + bomb.makeInactive(); + + this.scene.add.sprite(bx, by, "bomb1").setScale(this.bulletScale).play("explosion"); + + + for(let i = 0; i < this.bulletSpreadCount; i++){ + let angle = aimAngle + (i / this.bulletSpreadCount) * Math.PI * 2.0; + let bullet = enemyBulletGroup.getFirstDead(); + if(!bullet) continue; + + bullet.makeInactive(); + bullet.makeActive(); + + bullet.setTexture("playerShot"); + bullet.setScale(2.0); + bullet.bulletAnim = null; + bullet.stop(); + bullet.bulletHitAnim = null; + bullet.flipY = false; + bullet.useVelocity = true; + bullet.isBomb = false; + bullet.velocityX = Math.cos(angle) * this.bulletSpreadSpeed; + bullet.velocityY = Math.sin(angle) * this.bulletSpreadSpeed; + bullet.rotation = angle - Math.PI / 2.0; + bullet.x = bx; + bullet.y = by; + + const b = bullet; + let vX = bullet.velocityX; + let vY = bullet.velocityY; + let endvX = vX * 8.0; + let endvY = vY * 8.0; + let t = {progress: 0}; + + this.scene.tweens.add({ + targets: t, + progress: 1, + duration: 2000, + ease: 'Sine.easeOut', + onUpdate: () => { + if(!b.active) return; + b.velocityX = Phaser.Math.Linear(vX, endvX, t.progress); + b.velocityY = Phaser.Math.Linear(vY, endvY, t.progress); + } + }); + } + + } + + increaseBulletSpreadCount(){ + this.bulletSpreadCount *= 2; + } +} + +class TwinShooter extends Enemy{ + constructor(scene, x, y){ + super(scene, x, y, "twinshooter", 1, 50); + this.setScale(2.0); + this.flipY = true; + + this.shotSpeed = 400; + this.firingEnabled = false; + this.fireCooldown = 1200; + this.fireCooldownCounter = (Math.random() * this.fireCooldown / 2.0) + (this.fireCooldown / 2.0); + this.bulletTexture = "twinshot"; + this.bulletScale = 2.0; + this.bulletAnim = null; + this.bulletHitAnim = null; + + this.bulletSpread = 0; + + // Path Follower System + this.follower = null; + this.loopPath = null; + this.pathBuild = false; + + // Wiggle + this.wiggleFrequency = 0.75; + this.wiggleAmp = 75.0; + + // Path Dimensions + this.pathRadiusX = 80; + this.pathRadiusY = 35; + this.pathDuration = 4000; // MS + + this.initHitbox(26, 26); + } + + buildFig8(cx, cy){ + + let rx = this.pathRadiusX; + let ry = this.pathRadiusY; + + let path = new Phaser.Curves.Path(cx, cy); + + //- Top Loop ------------------------------ + + path.cubicBezierTo( + cx + rx, cy - ry, + cx + rx, cy, + cx + rx, cy - ry, + ); + + path.cubicBezierTo( + cx, cy, + cx + rx, cy - ry * 2, + cx - rx, cy - ry * 2, + ); + + path.cubicBezierTo( + cx - rx, cy - ry, + cx - rx, cy - ry * 2, + cx - rx, cy - ry, + ); + + /*path.cubicBezierTo( + cx, cy, + cx - rx, cy, + cx, cy, + );*/ + + //- Bottom Loop --------------------------- + + path.cubicBezierTo( + cx + rx, cy + ry, + cx + rx, cy, + cx + rx, cy + ry, + ); + + path.cubicBezierTo( + cx, cy, + cx + rx, cy + ry * 2, + cx - rx, cy + ry * 2, + ); + + path.cubicBezierTo( + cx - rx, cy + ry, + cx - rx, cy + ry * 2, + cx - rx, cy + ry, + ); + + /* + path.cubicBezierTo( + cx, cy, + cx - rx, cy, + cx, cy, + );*/ + + return path; + + } + + initFollower(){ + + let container = this.scene.enemyContainer; + + let cx = this.startX + container.x; + let cy = this.startY + container.y; + + this.loopPath = this.buildFig8(cx, cy); + + this.follower = this.scene.add.follower(this.loopPath, cx, cy, "twinshooter"); + this.follower.setScale(0); + this.follower.startFollow({ + duration: this.pathDuration, + ease: "Linear.easeInOut", + repeat: -1, + rotateToPath: false, + }); + + this.pathBuild = true; + } + + update(time, delta, playerX, enemyBulletGroup){ + + if(!this.firingEnabled) return; + + if(!this.pathBuild) this.initFollower(); + + let container = this.scene.enemyContainer; + this.x = this.follower.x - container.x; + this.y = this.follower.y - container.y; + let worldX = this.follower.x; + let worldY = this.follower.y; + let dx = playerX - worldX; + let dy = this.scene.scale.height - worldY; + this.rotation = Math.atan2(dy, dx) - Math.PI / 2.0; + + this.updateHitbox(worldX, worldY); + + /*for(let bullet of enemyBulletGroup.getChildren()){ + if(!bullet.active || !bullet.wiggle) continue; + + bullet.wiggleTime += delta / 1000; + + let travelDist = bullet.speed * (delta / 1000); + bullet.baseX += Math.cos(bullet.baseAngle) * travelDist; + bullet.baseY += Math.sin(bullet.baseAngle) * travelDist; + + let perpX = -Math.sin(bullet.baseAngle); + let perpY = Math.cos(bullet.baseAngle); + + let displacement = bullet.wiggleAmp * Math.sin(bullet.wiggleTime * bullet.wiggleFrequency * Math.PI * 2.0) * bullet.twinShotDir; + + bullet.x = bullet.baseX + perpX * displacement; + bullet.y = bullet.baseY + perpY * displacement; + //bullet.rotation = Math.atan(bullet.y, bullet.x) - Math.PI/2.0; + } + */ + + this.fireCooldownCounter -= delta; + if(this.fireCooldownCounter > 0) return; + this.fireCooldownCounter = (Math.random() * this.fireCooldown / 2.0) + (this.fireCooldown / 2.0);; + + let forwardAngle = this.rotation + Math.PI/2.0; + + let spreadRad = this.bulletSpread * Math.PI / 180.0; + let angles = [forwardAngle - (spreadRad / 2), forwardAngle + (spreadRad / 2)]; + + //Shot 1 + let bullet1 = this.spawnBullet(enemyBulletGroup, worldX, worldY); + if(!bullet1) return; + bullet1.useVelocity = false; + bullet1.rotation = angles[0] - Math.PI / 2; + + //Oscilation + bullet1.wiggle = true; + bullet1.baseX = worldX; + bullet1.baseY = worldY; + bullet1.wiggleTime = 0; + bullet1.wiggleFrequency = this.wiggleFrequency; + bullet1.wiggleAmp = this.wiggleAmp; + bullet1.baseAngle = angles[0]; + bullet1.twinShotDir = -1; + + //Shot 2 + let bullet2 = this.spawnBullet(enemyBulletGroup, worldX, worldY); + if(!bullet2) return; + bullet2.useVelocity = false; + bullet2.rotation = angles[1] - Math.PI / 2; + + //Oscilation + bullet2.wiggle = true; + bullet2.baseX = worldX; + bullet2.baseY = worldY; + bullet2.wiggleTime = 0; + bullet2.wiggleFrequency = this.wiggleFrequency; + bullet2.wiggleAmp = this.wiggleAmp; + bullet2.baseAngle = angles[1]; + bullet2.twinShotDir = 1; + + } +} + +class Support extends Enemy{ + constructor(scene, x, y, player){ + super(scene, x, y, "support", 1, 5); + this.player = player; + this.setScale(2.0); + this.flipY = true; + + this.shotSpeed = 800; + this.firingEnabled = false; + this.fireCooldown = 2000; + this.fireCooldownCounter = Math.random() * this.fireCooldown; + this.bulletTexture = "playerShot"; + this.bulletScale = 2.0; + this.bulletAnim = null; + this.bulletHitAnim = null; + + this.deadzone = 30; + this.isHovering = false; + + this.initHitbox(26, 26); + } + + update(time, delta, playerX, enemyBulletGroup){ + + if(!this.firingEnabled) return; + + let container = this.scene.enemyContainer; + let worldX = this.x + container.x; + let worldY = this.y + container.y; + + this.updateHitbox(worldX, worldY); + + if(!this.isHovering){ + this.isHovering = true; + this.startHoverTween(); + } + + this.fireCooldownCounter -= delta; + if(this.fireCooldownCounter > 0) return; + this.fireCooldownCounter = this.fireCooldown; + + let dx = Math.abs(worldX - this.player.x); + if(dx > this.deadzone){ + let bullet = this.spawnBullet(enemyBulletGroup, worldX, worldY); + if(bullet) bullet.useVelocity = false; + } + } + + startHoverTween(){ + + let container = this.scene.enemyContainer; + let worldX = this.x + container.x; + let playerX = this.player.x; + let configLen = this.scene.scale.width; + + let overshoot = (Math.abs(worldX - playerX) / 2) + 20 + 10 * Math.random(); + let direction = (worldX < playerX) ? 1 : -1; + let overshootWorld = playerX + direction * overshoot; + overshootWorld = (overshootWorld > configLen) ? configLen - 1 : overshootWorld; + overshootWorld = (overshootWorld < 0) ? 1 : overshootWorld; + + let targetLocalX = overshootWorld - container.x; + + this.scene.tweens.add({ + targets: this, + x: targetLocalX, + duration: 300 + Math.random() * 100, + ease: 'Sine.easeInOut', + onComplete: () => { + this.startHoverTween(); + } + }); + } + + destroy(fromScene){ + + if(this.scene && this.scene.tweens) this.scene.tweens.killTweensOf(this); + super.destroy(fromScene); + } +} \ No newline at end of file diff --git a/src/Sprites/Player.js b/src/Sprites/Player.js index ae4d388..078a1d5 100644 --- a/src/Sprites/Player.js +++ b/src/Sprites/Player.js @@ -4,24 +4,32 @@ class Player extends Phaser.GameObjects.Sprite { // spriteKey - key for the sprite image asset // leftKey - key for moving left // rightKey - key for moving right - constructor(scene, x, y, texture, frame, leftKey, rightKey, playerSpeed) { + constructor(scene, x, y, texture, frame, leftKey, rightKey, playerSpeed, showHitboxes = false) { super(scene, x, y, texture, frame); this.left = leftKey; this.right = rightKey; this.playerSpeed = playerSpeed; + + this.score = 0; + this.bulletSpeed = -1000; + this.isActive = true; scene.add.existing(this); + this.hitbox = new CollisionBox(scene, this, 20, 30, showHitboxes); return this; } update(time, delta) { let dt = delta / 1000; + + if(!this.isActive) return; + // Moving left if (this.left.isDown) { // Check to make sure the sprite can actually move left - if (this.x > (this.displayWidth/2)) { + if (this.x > 0) { this.x -= this.playerSpeed * dt; } } @@ -29,10 +37,35 @@ class Player extends Phaser.GameObjects.Sprite { // Moving right if (this.right.isDown) { // Check to make sure the sprite can actually move right - if (this.x < (game.config.width - (this.displayWidth/2))) { + if (this.x < (game.config.width)) { this.x += this.playerSpeed * dt; } } + + if(!this.hitbox) return; + this.hitbox.update(this.x, this.y); + } + + checkActive(){ + return this.isActive; + } + + setInactive(){ + this.isActive = false; + this.visible = false; + this.hitbox.destroy(); + } + + setActive(){ + this.isActive = true; + this.visible = true; + if(this.hitbox) return; + this.hitbox = new Collisionbox(scene, this, 20, 30, showHitboxes); + } + + destroy(fromScene){ + if(this.hitbox) this.hitbox.destroy(); + super.destroy(fromScene); } } \ No newline at end of file diff --git a/src/main.js b/src/main.js index c8d2773..90eb002 100644 --- a/src/main.js +++ b/src/main.js @@ -19,11 +19,13 @@ let config = { render: { pixelArt: true // prevent pixel art from getting blurred when scaled }, - fps: { forceSetTimeOut: true, target: 60 }, // ensure consistent timing across machines - width: 800, - height: 600, - scene: [SingleBullet, ArrayBullet, FixedArrayBullet, GroupBullet, ClassBullet, ArrayBoom] + fps: { forceSetTimeOut: true, target: 360 }, // ensure consistent timing across machines + width: 600, + height: 800, + scene: [MainMenu, Scoreboard, ArrayBoom] } -const game = new Phaser.Game(config); \ No newline at end of file +const game = new Phaser.Game(config); + +game.config.score = 0; \ No newline at end of file