• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created about 3 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Binary Tetris

🎮 Bintris

Bintris is a mobile game developed in Go!

Support me by buying this game on Google PlayStore 💸: https://play.google.com/store/apps/details?id=go.lang.bintris

Or you can of course build it from source yourself (see instructions below 🪛).

Enjoy!

About The Game

Bintris is a small game inspired by Tetris. The goal is to flip the bits so that the bits represent the decimal number in the right column. When the bits represent the decimal number the line is cleared and points are gathered. Number of bits representing the decimal number is also how much points scored for the particular line.

Demo On Youtube

Bintris

About The Implementation

The game is developed in Go and is implemented using OpenGL (graphics) and OpenAL (sound). Gomobile is used to generate shared libraries that are used for the Android build. The game works just as good on Linux as on Android.

It all started as an experiment with Gomobile and ended up as a fully working game, after a lot of frustration and gotchas! ;) With that said, the source is a bit of a mess and I have some stuff on my todo-list such as implementing full parsing of wav header, a simple FSM for the game etc.

Building From Source

To just run the game on Linux, just issue the commands:

# First remove line for modified version of gomobile
sed -i '/nergal/d' go.mod
# Then run the game
go run .

Build For Android

First make sure you have built OpenAL (make openal). It's a bit complicated to make the OpenAL build work succesfully with current state of gomobile. I've added some notes below about this.

make android

Build For Android Studio

The repository includes a very small Android Studio project that is used to build AAB package format for Google PlayStore. This project handles AAB packaging and uses the shared objects (.so) files from the build.

To build/run via Android Studio (make sure to have OpenAL libraries first make openal, see requirements below):

  1. make studio
  2. Open the project in Android Studio
  3. Attach mobile or virtual device and run.

Details

OpenAL

Update toolchain.cmake to use -O3 -s to build smaller version of OpenAL (otherwise you will end up with ~30MB debug none stripped version) Also update to armv8 (line 578) in the toolchain from v7.

Using AAB packaging for PlayStore requires libraries loaded with dlopen to not use the path. Hence, the audio/al packages requires to just use dlopen("libopenal.so"). The base.apk in aab doesn't include the libraries rather they are included in the split_config.<arch>.apk.

AL/openal.h etc requires to be in audio/al package dir for rebuilding:

exp/audio/al/al_android.go:17

 // All other code for reading ENV can be removed.
 *handle = dlopen("libopenal.so", RTLD_LAZY);

Build OpenAL:

make openal

Go

Use `ldflags="-w" to remove debug information from the build (see Makefile)

Changes Required to Gomobile Command

Line 182 in mobile/cmd/init.go:

cmd := exec.Command(cmake, "-S",
	initOpenAL,
	"-DANDROID_PLATFORM=23",
	"-B", buildDir,
	"-DCMAKE_TOOLCHAIN_FILE="+ndkRoot+"/build/cmake/android.toolchain.cmake",
	"-DANDROID_HOST_TAG="+t.ClangPrefix())

ADB Debug

View logs from connected phone (developer mode):

adb logs

Debug using:

adb shell pm list packages -f |grep bintris

Then download:

adb pull <path to bintris package base path>

Too see what is included in the divided apk's.

License

GNU General Public License v3.0 (see COPYING)

More Repositories

1

gorss

Go Terminal Feed Reader
Go
391
star
2

voxelengine3

Voxel-engine in Javascript
JavaScript
330
star
3

wizardwarz

WebGL Multiplayer game with NodeJS backend
JavaScript
292
star
4

VoxLords

VoxLords - ThreeJS WebGL game with a simple voxel engine
JavaScript
178
star
5

vox2

Simple POC of PCG voxel-engine
JavaScript
142
star
6

gizmo

2D Pixel Destruction Game written in Go.
Go
138
star
7

Qake

Qake voxel-engine demo
JavaScript
132
star
8

voxelengine_urho3d

Voxel engine in C++ using Urho3D
C++
107
star
9

badsanta

BadSanta - Multiplayer HTML5 Game (http://santa.qake.se)
JavaScript
100
star
10

ParrotHunt

ParrotHunt - ThreeJS WebGL game (http://parrothunt.nergal.se)
JavaScript
91
star
11

doit

Simple Todo List - Wunderlist Replacement
Vue
80
star
12

rpicam

Raspberry PI Surveillance Automation
Shell
76
star
13

DungeonGenerator

Dungeon generator for games.
Perl
69
star
14

fireworks

WebGL Fireworks in VR
JavaScript
40
star
15

voxelengine_unity

Voxel engine made in C# for Unity
C#
39
star
16

spinc

Spark In Console - Cisco (WebEx)Spark Client for Linux/MacOS
Go
21
star
17

SavingNemo

SavingNemo - ThreeJS WebGL game with nodejs backend.
JavaScript
21
star
18

moonshot

Moonshot GitHubGameOff 2020 contribution
Go
16
star
19

smhialert

Home Assistant SMHI Warnings & Alerts
Python
10
star
20

hass-unifi

Unifi Person Detection with Home Assistant integration
Python
6
star
21

openfaas-demo

OpenFaaS demo using Function as a Service and object storage
Ruby
3
star
22

gruntbase

Grunt template for server/client NodeJS dev. environment.
JavaScript
2
star
23

varnish-visualizer

Varnish hit/pass visualisation in WebGL.
JavaScript
2
star
24

googlehome

Google Home (Assistant) Automation With NetHomeServer
Ruby
1
star
25

hydroponic

Hydroponic automation with ESP32 and sensors
C++
1
star
26

pointcloud

ThreeJS point cloud experiment
JavaScript
1
star