ayyo-wars icon indicating copy to clipboard operation
ayyo-wars copied to clipboard

An open and hackable 2D space battle game

Ayyo Wars ( Alpha )

Join the chat at https://gitter.im/ayyo-wars/dev

Ayyo Wars is an open-source and hackable 2d space battle game. It's built with Phaser.io and Node.js. It can be played in the browser.

Home Page

https://ayyowars.com

Project Goals

To create an amazing community built open-source video game which can be used as an educational tool for years to come. Blurring the lines between Programmer and Gamer. A homage to retro gaming. The next generation's MineCraft.

alpha-demo-quick

About

This repository is a fresh attempt of our project which has been in development for several years. We decided on a clean rewrite using Geoffrey and to make the project open-source. The following game elements are designed and planned for our Beta release:

  • Online Multiplayer Battles
  • Epic Local Play
  • 12 Unique Ships
  • 24 Unique Weapons
  • 6 Unique Game Modes
  • Much Alien Lore

Game Modes

Local Skirmish ( beta )

Two teams of ships battle each other until no ships are left. Can be played with up to four players or Artifical Intelligences.

Online Skirmish ( alpha )

Select a ship and connect online to battle other players. Uses WebRTC and UDP.

Galaxy Mode ( very alpha )

Explore the galaxy in a space ship. Build bases. Gather resources. Battle aliens. Defend and conquer territories.

Surival ( planned )

Choose a ship and battle Waves of enemies until you reach the end or die trying.

Level Editor ( planned )

Create and modify all game behaviors including ships, weapons, items, and levels.

Surface Mode ( planned )

Go on an away mission. Land on planets, moons, asteroids, and other celesetial bodies. Interact with worlds using a side-scrolling platformer view. Mine materials, discover ancient worlds, and try not to die before you get back to the ship!

Local Installation

git clone https://github.com/Marak/ayyo-wars
cd ayyo-wars
npm install
npm run web

This will start a simple webserver that hosts the game. You should then be able to open http://localhost:3000 in your browser to play.

Local Development

npm run watch

This will start a local build server that watches the project folder for changes. This will trigger a project build on code changes. Without running this command your code changes won't appear in the browser.

Multiplayer Server

npm run multiplayer

This will start a webserver to host the game, as well as an authoritative server, WebRTC server, and Websocket server. The authoritative server runs the game headlessly and the browser clients will broadcast their controller inputs to the server. In this mode, all game calculations run on the server and are broadcasted back to the client.

You should then be able to open http://localhost:3000/online in your browser to connect new players.

Game Architecture

Behaviors

Alien Wars utilizes a behavior based dependency injection pattern where each game object starts out as an empty Thing which can have Behaviors attached to it. Think of it as a functional composition approach for defining game objects and behaviors instead of object inheritance.

Ships or other game objects are represented as collections of behaviors that run every update of the game loop. These behaviors control how the game object will act. Complex behaviors can be created through seamlessly composing several smaller behaviors.

Behaviors can also be attached and detatched dynamically during game play. It's even safe to re-apply the same behavior twice to the same game object. All of this is very useful for keeping game scaffolding code to a minmial and allowing for features like live game editing.

See current game behaviors here: https://github.com/Marak/ayyo-wars/tree/master/lib/behaviors/index.js

Online Mode

Online Protocols

Ayyo Wars supports multiplayer through the use of an authoratitive server which runs all game calculations. Each client connects using UDP and Webrtc to create a direct peer connection to the server. Websockets are also used as a signaling server for the WebRTC connections.

Client-Side Prediction / Lag Compensation / Snapshot Interpolation

Through the use of the snapshot-interpolation library, Ayyo Wars is able to perform client-side prediction for all game object movement and then reconcile those objects against the server state. In online mode all clients broadcast their inputs to the authortative server, which then sends back the actual server-side calculated positions to the client which updates based on the snapshot state differential.

Modifying Game Contents

The G Scope

Each Thing will have a property called G, this is short for Geoffrey. Anything related to our game logic ( and not directly to Phaser.js ) will be stored in the G scope. This is super useful when creating or modifying game content. You can also modify G values live while the game is playing directly through the console.

Try: console.log(Things['PLAYER_1'].G)

Audio and Image Assets

Game audio and images are stored here: https://github.com/Marak/ayyo-wars/tree/master/public/assets

Any image or sound can be modified or replaced in the game. Simply search for the asset you want to modify and open it with your favorite editing application.

New assets can also be put into this folder, but you will need to be sure to preload them in your Behavior's preload function.

License

Ayyo Wars - Space Battle Game
Copyright (C) 2021 Marak Squires

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Starmap Data

Star Map 2D by Filip Hracek is licensed under a Creative Commons Attribution 4.0 International License.

https://starmap2d.appspot.com