๐Ÿ“ฆ pi0 / space-invaders

๐Ÿ‘พ Space Invaders game in single (~4KB Gzipped) JavaScript file!

โ˜… 56 stars โ‘‚ 7 forks ๐Ÿ‘ 56 watching
๐Ÿ“ฅ Clone https://github.com/pi0/space-invaders.git
HTTPS git clone https://github.com/pi0/space-invaders.git
SSH git clone git@github.com:pi0/space-invaders.git
CLI gh repo clone pi0/space-invaders
pi0::agent pi0::agent feat: two-player mode with AI opponent (#3) b66797e 1 months ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“„ .gitignore
๐Ÿ“„ index.html
๐Ÿ“„ index.js
๐Ÿ“„ index.ts
๐Ÿ“„ package.json
๐Ÿ“„ pnpm-lock.yaml
๐Ÿ“„ README.md
๐Ÿ“„ screenshot.png
๐Ÿ“„ README.md

๐Ÿ‘พ Space Invaders

Space Invaders game in single (~4KB Gzipped) JavaScript file!

Play Online

Two-Player Mode (vs AI)

Battle against an AI opponent! Both players compete to destroy aliens and earn points.

Gameplay Screenshot

Features:

  • ๐ŸŽฎ Human player (green) at the bottom, AI player (red) at the top
  • ๐Ÿ‘พ Aliens spawn in the middle - both players shoot to destroy them
  • ๐Ÿ’ฅ Players can hit each other directly
  • ๐Ÿ† 3 waves of aliens - highest score wins!
  • ๐Ÿ“ฑ Touch controls supported for mobile
Controls:
  • โ† โ†’ Arrow keys to move
  • SPACE to shoot
  • ENTER to start

Using in your pages

Checkout index.html for additional styles.

<div id="game"></div>
<script type="module">
const { startGame } = await import("https://cdn.jsdelivr.net/gh/pi0/space-invaders/index.js");
startGame({ selector: "#game" });
</script>

License

MIT - Pooya Parsa

Based on a codepen by Anthony Del Ciotto (@adelciotto)