A programming game in which the user writes JavaScript code to control a spaceship in order to complete some objective.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
css
docs
lib
src
LICENSE.txt
Makefile
README.md
favicon.ico
index-dev.html
index.html

README.md

Space AI Game

This is a programming game in which the user writes JavaScript code to control a spaceship in order to complete some objective. The user gets an API with certain inputs and outputs to sense and react to the environment. This API includes functions for things like radar, checking ammo, checking objective location, accelerating, turning, firing, etc. Documentation is available to the player. The objective might be to get to a specified location, to destroy all enemy ships or outposts, to defend your own ships or outposts, etc. Each level can be specified as a JavaScript object in a simple format with initial conditions and win conditions, so it is easy to create new challenges.

Originally the idea was to have two or more players write some AI-like scripts and their ships would battle each other in space with additional obstacles like asteroids and planets. But for now the game is just a series of single-player challenges to complete.

Demo

A live demo of the latest version of the code is available at https://fotino.me/static/spaceship.codes.

Build

Building the code requires Webpack and UglifyJS for bundling the source into one file and then compressing that file. You can install these dependencies with:

npm install -g webpack
npm install -g uglify-js

Once you have Webpack and UglifyJS installed, you can build the code by running make (requires CMake). Other build commands include:

make watch   # Webpack watches source and rebuilds as needed
make bundle  # Only runs Webpack
make minify  # Only runs UglifyJS
make clean   # Removes already built files

The built files are build/space-ai.js and build/space-ai.min.js, which are the bundled code and the bundled + minified code, respectively. There are two HTML files that can be viewed in the browser to run the game: index-dev.html, which uses the unminified version of the code; and index.html, which uses the minified version.

Todo

  • Add health() and bounds() diagnostic functions for the user
  • Explosion animations
  • Viewport interactions like pan/zoom/focus
  • Immobile enemy ships
  • Mobile enemy ships
  • Mines that follow the player if they are within a certain proximity and explode on impact.
  • Be able to hover over objects and see information about them
  • Togglable debug mode where you see a 100px grid, info on all game objects, etc.
  • Packaging/minification of JavaScript files
  • About dialog
  • Menu dropdown for changing the view
  • Loading/saving of user code using local storage
  • Z-index for controlling drawing order of game objects
  • Some way to give a level description via initial comments, or have some initial code the user has to modify.
  • Weapon drops
  • CodeMirror theme selector
  • Clicking on game objects pops up a dialog with more information
  • Add examples to the docs
  • Add keyboard shortcuts to the docs
  • Add game object descriptions to the docs
  • Level design

Wishlist

  • Improved menu/button graphics
  • Mobile support
  • Minimap
  • More weapon types
  • Powerups like shields, health
  • Parallax movement of stars
  • Quad trees for efficient collision detection
  • More efficient scene rendering
  • Maximum radar distance on a per-level basis
  • Planets with gravity mechanics
  • Better styling for docs
  • Multiplayer versus mode