Skip to content

Commit 5e72bdf

Browse files
ValorZardJoeTurki
authored andcommitted
Add Ebiten game example
1 parent af3aed7 commit 5e72bdf

File tree

15 files changed

+1676
-10
lines changed

15 files changed

+1676
-10
lines changed

.github/.ci.conf

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
22
# SPDX-License-Identifier: MIT
33

4-
PRE_TEST_HOOK=_install_gstreamer_hook
5-
PRE_LINT_HOOK=_install_gstreamer_hook
6-
GO_MOD_VERSION_EXPECTED=1.22
4+
PRE_TEST_HOOK=_install_dependencies_hook
5+
PRE_LINT_HOOK=_install_dependencies_hook
6+
GO_MOD_VERSION_EXPECTED=1.23
77
SKIP_i386_TESTS=true
88
SKIP_API_DIFF=true
99

1010
function _install_gstreamer_hook(){
11-
set -e
12-
13-
sudo apt-get update
1411
sudo apt-get purge -y libunwind-14-dev
1512
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
1613
sudo apt-get install -y libavcodec-dev libavutil-dev libavfilter-dev libswscale-dev libavformat-dev libavdevice-dev
1714
}
15+
16+
function _install_ebiten_hook(){
17+
sudo apt-get install -y \
18+
libasound2-dev libgl1-mesa-dev libxcursor-dev libxi-dev \
19+
libxinerama-dev libxrandr-dev libxxf86vm-dev
20+
}
21+
22+
function _install_dependencies_hook(){
23+
set -e
24+
25+
sudo apt-get update
26+
_install_gstreamer_hook
27+
_install_ebiten_hook
28+
}

LICENSES/CC-BY-3.0.txt

Lines changed: 319 additions & 0 deletions
Large diffs are not rendered by default.

ebiten-game/LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## game/gopher.png
2+
3+
```
4+
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
5+
The design is licensed under the Creative Commons 4.0 Attributions license.
6+
Read this article for more details: https://blog.golang.org/gopher
7+
```

ebiten-game/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Ebitengine Game!
2+
3+
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!
4+
5+
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
6+
7+
Requires the signaling server to be running. To do go, just go inside the folder /signaling-server and do ``go run .``
8+
9+
you can then run the game by going in /game and doing either
10+
11+
``go run .`` for running the game on desktop
12+
13+
(see [this tutorial for more information on how to build for WebAssembly](https://ebitengine.org/en/documents/webassembly.html))
14+
15+
Click "Host Game" to get the lobby id, and then share that with the other clients to get connected
16+
17+
To play: Just move around with the arrow keys once you have connected!
18+
19+
Right now this only supports two clients in the same lobby

ebiten-game/game/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: 2025 The Pion community <https://pion.ly>
2+
# SPDX-License-Identifier: MIT
3+
4+
# If you prefer the allow list template instead of the deny list, see community template:
5+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
6+
#
7+
# Binaries for programs and plugins
8+
*.exe
9+
*.exe~
10+
*.dll
11+
*.so
12+
*.dylib
13+
*.wasm
14+
15+
# Test binary, built with `go test -c`
16+
*.test
17+
18+
# Output of the go coverage tool, specifically when used with LiteIDE
19+
*.out
20+
21+
# Dependency directories (remove the comment below to include it)
22+
# vendor/
23+
24+
# Go workspace file
25+
go.work
26+
go.work.sum
27+
wasm_exec.js

ebiten-game/game/gopher.png

42.7 KB
Loading

ebiten-game/game/gopher.png.license

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: 2016 The Go Authors
2+
SPDX-License-Identifier: CC-BY-3.0

ebiten-game/game/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 The Pion community <https://pion.ly>
3+
SPDX-License-Identifier: MIT
4+
-->
5+
6+
<!DOCTYPE html>
7+
<script src="wasm_exec.js"></script>
8+
<script>
9+
// Polyfill
10+
if (!WebAssembly.instantiateStreaming) {
11+
WebAssembly.instantiateStreaming = async (resp, importObject) => {
12+
const source = await (await resp).arrayBuffer();
13+
return await WebAssembly.instantiate(source, importObject);
14+
};
15+
}
16+
17+
const go = new Go();
18+
WebAssembly.instantiateStreaming(fetch("gopher-combat.wasm"), go.importObject).then(result => {
19+
go.run(result.instance);
20+
});
21+
</script>

0 commit comments

Comments
 (0)