Skip to content

Add Ebiten game example #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .github/.ci.conf
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
# SPDX-License-Identifier: MIT

PRE_TEST_HOOK=_install_gstreamer_hook
PRE_LINT_HOOK=_install_gstreamer_hook
GO_MOD_VERSION_EXPECTED=1.22
PRE_TEST_HOOK=_install_dependencies_hook
PRE_LINT_HOOK=_install_dependencies_hook
GO_MOD_VERSION_EXPECTED=1.23
SKIP_i386_TESTS=true
SKIP_API_DIFF=true

function _install_gstreamer_hook(){
set -e

sudo apt-get update
sudo apt-get purge -y libunwind-14-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y libavcodec-dev libavutil-dev libavfilter-dev libswscale-dev libavformat-dev libavdevice-dev
}

function _install_ebiten_hook(){
sudo apt-get install -y \
libasound2-dev libgl1-mesa-dev libxcursor-dev libxi-dev \
libxinerama-dev libxrandr-dev libxxf86vm-dev
}

function _install_dependencies_hook(){
set -e

sudo apt-get update
_install_gstreamer_hook
_install_ebiten_hook
}
319 changes: 319 additions & 0 deletions LICENSES/CC-BY-3.0.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ebiten-game/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## game/gopher.png

```
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
The design is licensed under the Creative Commons 4.0 Attributions license.
Read this article for more details: https://blog.golang.org/gopher
```
19 changes: 19 additions & 0 deletions ebiten-game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Ebitengine Game!

This is a pretty nifty demo on how to use [ebitengine](https://ebitengine.org/) and [pion](https://github.com/pion/webrtc) to pull off a cross platform game!

You can have a client running on the browser and one running on a desktop and they can talk to each other, provided they are connected to the same signaling server

Requires the signaling server to be running. To do go, just go inside the folder /signaling-server and do ``go run .``

you can then run the game by going in /game and doing either

``go run .`` for running the game on desktop

(see [this tutorial for more information on how to build for WebAssembly](https://ebitengine.org/en/documents/webassembly.html))

Click "Host Game" to get the lobby id, and then share that with the other clients to get connected

To play: Just move around with the arrow keys once you have connected!

Right now this only supports two clients in the same lobby
27 changes: 27 additions & 0 deletions ebiten-game/game/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2025 The Pion community <https://pion.ly>
# SPDX-License-Identifier: MIT

# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.wasm

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum
wasm_exec.js
Binary file added ebiten-game/game/gopher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions ebiten-game/game/gopher.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: 2016 The Go Authors
SPDX-License-Identifier: CC-BY-3.0
21 changes: 21 additions & 0 deletions ebiten-game/game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
SPDX-FileCopyrightText: 2025 The Pion community <https://pion.ly>
SPDX-License-Identifier: MIT
-->

<!DOCTYPE html>
<script src="wasm_exec.js"></script>
<script>
// Polyfill
if (!WebAssembly.instantiateStreaming) {
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
};
}

const go = new Go();
WebAssembly.instantiateStreaming(fetch("gopher-combat.wasm"), go.importObject).then(result => {
go.run(result.instance);
});
</script>
Loading
Loading