Git Product home page Git Product logo

airconsole-ebiten's Introduction

AirConsole + Ebiten Boilerplate

Overview

This boilerplate project provides a basic setup for developing games that integrate AirConsole for input handling and Ebiten for game logic. It demonstrates how to set up a web-based controller interface and a Go-based game engine that communicates with it.

Structure

The project is divided into two main parts:

  • web/ */: This directory contains the web frontend. It includes the HTML (controller.html, screen.html), JavaScript (script.js), and CSS (style.css) files necessary for both the controller interface and the html that will render the WASM
  • game/ */: This houses the Go codebase for the game. The Go code is compiled to WebAssembly, enabling it to run in the browser and interact with the web-based controller.

Hosting

This project can be hosted in various ways, but below are instructions for using PHP as a local server for development and testing.

General Hosting Guidelines

  • WebAssembly Compilation: Compile the Go code in the game/ directory into WebAssembly and place the compiled file in the web/build directory.
  • Static File Server: Any static file server can be used to serve the files in the web/ directory. This can range from a simple server in Python or Node.js to more robust servers like Apache or Nginx.

Hosting with PHP

For local development, PHP's built-in server is a convenient option. Follow these steps to use PHP:

  • Check PHP Installation: Ensure PHP is installed on your machine. Verify this by running php -v in your command line.
  • Start PHP Server: In the command line, navigate to the web/ directory and start the server:
php -S 0.0.0.0:8000
  • Access The Project: With the server running, you can access the game and controller interfaces at: Game interface: http://localhost:8000/screen.html Controller interface: http://localhost:8000/controller.html. Depending on how you are hosting, you may want to setup a redirect at the route of the web folder to the screen.html

  • The PHP server will serve your static files, and any changes will be reflected upon refreshing the browser.

Playing the game

Building the Go game web assembly

In order to actually play our Go game, we need to compile it to web assembly so that it is served up from our web directly. To compile it, we follow the instructions from [https://ebitengine.org/en/documents/webassembly.html](Option 2) Instructions for Windows below, it should be pretty clear from the above link how to do it on linux.

Windows (powershell)

This defines the build destination in the web/build directory. Be sure to put the same URL as defined in your go.mod. Execute this from within the game folder.

$Env:GOOS = 'js'
$Env:GOARCH = 'wasm'
go build -o ../web/build/game.wasm github.com/jacovanc/airconsole-ebiten/game
Remove-Item Env:GOOS
Remove-Item Env:GOARCH

We then need to create an executable that can be executed from our html

$goroot = go env GOROOT
cp $goroot\misc\wasm\wasm_exec.js ../web/build/wasm_exec.js

airconsole-ebiten's People

Contributors

jacovanc avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.