QRGame - storage a game inside a qr code

Overview
QRGame

QRGame

Can we storage a game inside a qr code? Yes! At least in theory. That was the question that started that entire project. QRGame is an Android project that uses QR code as a game cartridge allowing you to read and run a game stored inside it.

Table of Contents

Usage

To start using QRGame, just run the app on your smartphone and read the QR code bellow.

Qr code

You can clone this project and run it on Android Studio or download it from the Google Play Store.

Getting started

Prerequisites

If you want to create your own game to run on QRGame you will need to know some java script, be familiar with a code editor and a platform to create a QR code (there is one in the Links section ๐Ÿ˜„ ).

How it works

The QR code has instructions to fill specific functions with actions, when a button is pressed or actions that should be invoked before or after pause for instance. Furthermore, it's possible create new functions to make entire news behaves. In order to inform if a instruction should fill a specific function or is a new one, it's necessary informe a tag that way:

TAG~code instructions

Tags

Bellow you can see all tags and its descriptions.

Buttons

Each button can have three states, down, click and up. The down state is when a button is initially pressed (corresponds to onpointerdown in javascript), up when the button has been released (corresponds to onpointerup in javascript), and the click triggers when a full click has been performed, it mens, down and up (corresponds to onclick in javascript). Itยดs possible control each button separately or in groups.

Tag Description
BD All buttons down
Bk All buttons click
BU All buttons up
Tag Description
PD Up, right, down and left buttons down
Pk Up, right, down and left buttons click
PU Up, right, down and left buttons up
Tag Description
AD Q and R buttons down
AK Q and R buttons click
AU Q and R buttons up
Tag Description
UD Up button down
UK Up button click
UA Up button up
RD Right button down
RK Right button click
RU Right button up
DD Down button down
DK Down button click
DU Down button up
LD Left button down
LK Left button click
LU Left button up
Tag Description
QD Q button down
QK Q button click
QU Q button up
HD R button down
HK R button click
HU R button up

Pause

It's possible create custom behaviors to perform after and before pause.

Tag Description
AP After pause code
BP Before pause code

Relaod

Like pause, it's possible create custom behaviors to perform after and before reload.

Tag Description
AR After reload code
BR Before reload code

Start Game

Instructions in this tag will be called right after the screen is drawn for the first time. The perfect place to initialize variables and make the first settings.

Tag Description
SG Start game code

Update Game Area

At each screen update it is erased and redrawn, it is possible to create behaviors to be executed before and after the screen is erased.

Tag Description
AC After clean
BC Before clean

Source Game

This tag loads the core of the game, in it you can put any extra behavior you want. What is written for this tag will not be inside specific functions, so if you want to create functions you will have to declare it entirely inside the tag.

Tag Description
SC Source game code

For example, the qr code on Usage section has the follow instructions:

t.y+t.h||this.x+this.wt.x+t.w)||this.y>gA.cvsh-this.h||this.y<0)&&(iAlv=fl)}}function ac(t){gmPc.g=t}function evIn(t){return gA.frN/t%1==0?tr:fl} ">
BD~ac(-0.2);BU~ac(0.05);SG~scr=new cmpt(chpx(5),"Consolas","black",20,30,"text"),gmPc=new cmpt(chp(10),chp(10),"#e9472a",10,chp(30)),gmPc.g=.05;AC~for(i=0;i<obts.length;i+=1)gmPc.cCrh(obts[i]),iAlv||(stp=tr,cCP=fl);BC~if(1==gA.frN||evIn(tchp(36))){let t=gA.cvsh,c=chp(7),p=chp(74),h=mfmr(c,p),s=chp(20),e=chp(50),r=mfmr(s,e);obts.push(new cmpt(chp(3),h,"green",t,0)),obts.push(new cmpt(chp(3),t-h-r,"green",t,h+r))}for(i=0;i<obts.length;i+=1)obts[i].x+=-1,obts[i].upt();scr.text="SCORE: "+gA.frN,scr.upt(),gmPc.nPs(),gmPc.upt();SC~let gmPc,scr,iAlv=tr,obts=[];function cmpt(t,i,h,s,c,x){this.w=t,this.h=i,this.sX=0,this.sY=0,this.x=s,this.y=c,this.g=0,this.gS=0,this.upt=function(){ctx=gA.ctx,"text"==x?(ctx.font=this.w+" "+this.h,ctx.fillStyle=h,ctx.fillText(this.text,this.x,this.y)):(ctx.fillStyle=h,ctx.fillRect(this.x,this.y,this.w,this.h))},this.nPs=function(){this.gS+=this.g,this.x+=this.sX,this.y+=this.sY+this.gS},this.cCrh=function(t){(!(this.y+this.h<t.y||this.y>t.y+t.h||this.x+this.w<t.x||this.x>t.x+t.w)||this.y>gA.cvsh-this.h||this.y<0)&&(iAlv=fl)}}function ac(t){gmPc.g=t}function evIn(t){return gA.frN/t%1==0?tr:fl}

With breaklines to help see each tag:

t.y+t.h||this.x+this.wt.x+t.w)||this.y>gA.cvsh-this.h||this.y<0)&&(iAlv=fl)}}function ac(t){gmPc.g=t}function evIn(t){return gA.frN/t%1==0?tr:fl} ">
BD~ac(-0.2);

BU~ac(0.05);

SG~scr=new cmpt(chpx(5),"Consolas","black",20,30,"text"),gmPc=new cmpt(chp(10),chp(10),"#e9472a",10,chp(30)),gmPc.g=.05;

AC~for(i=0;i<obts.length;i+=1)gmPc.cCrh(obts[i]),iAlv||(stp=tr,cCP=fl);

BC~if(1==gA.frN||evIn(tchp(36))){let t=gA.cvsh,c=chp(7),p=chp(74),h=mfmr(c,p),s=chp(20),e=chp(50),r=mfmr(s,e);obts.push(new cmpt(chp(3),h,"green",t,0)),obts.push(new cmpt(chp(3),t-h-r,"green",t,h+r))}for(i=0;i<obts.length;i+=1)obts[i].x+=-1,obts[i].upt();scr.text="SCORE: "+gA.frN,scr.upt(),gmPc.nPs(),gmPc.upt();

SC~let gmPc,scr,iAlv=tr,obts=[];function cmpt(t,i,h,s,c,x){this.w=t,this.h=i,this.sX=0,this.sY=0,this.x=s,this.y=c,this.g=0,this.gS=0,this.upt=function(){ctx=gA.ctx,"text"==x?(ctx.font=this.w+" "+this.h,ctx.fillStyle=h,ctx.fillText(this.text,this.x,this.y)):(ctx.fillStyle=h,ctx.fillRect(this.x,this.y,this.w,this.h))},this.nPs=function(){this.gS+=this.g,this.x+=this.sX,this.y+=this.sY+this.gS},this.cCrh=function(t){(!(this.y+this.h<t.y||this.y>t.y+t.h||this.x+this.w<t.x||this.x>t.x+t.w)||this.y>gA.cvsh-this.h||this.y<0)&&(iAlv=fl)}}function ac(t){gmPc.g=t}function evIn(t){return gA.frN/t%1==0?tr:fl}

Note that the code is minified to be as small as possible to fit the qr code. If you look closely, you'll see some functions undeclared nowhere but being called, like the chp function. This is because there are already some functions declared to help with writing new qr code. These functions can be seen in the example project or in the template project.

Example

Inside the example folder you can see the same project that is inside the Usage section qr code. Or if you prefer, inside the template folder there is a clean project that you can start your project from zero.

Possible improvements

QRGame is a proof of concept, because that, there are a lot of possibilities to improve the project. For now I just want to show the poc, but the project is open to new ideas โ˜บ๏ธ .

Thanks โœจ

Thanks to these wonderful people for all their support, partnership and friendship:


Diego Luz


Erick


Jamile Lima


Marcelo Cardoso


Mateus Nascimento


Yago Ferreira

Links

Some sites used during project development:

License

Copyright (c) 2021-present Aislan Tavares (@thisaislan) and Contributors. QRGame is free and open-source software licensed under the MIT License.

Third-party library licenses

You might also like...
Basic template to create a game using minigdx

MiniGDX Game Template Create your first game using miniGDX by clicking the "Use this Template" button above. The game will be configured for: the JVM

 Android Kotlin: Matching Kitties: A Game Inspired by Cats
Android Kotlin: Matching Kitties: A Game Inspired by Cats

Android Kotlin: Matching Kitties: A Game Inspired by Cats A kotlin based Android memory game Screenshots | | | | | | | | | Viewing the App You can clo

a bitcoin key collision game for android

BitteryApp BitteryApp is an opensource bitcoin key collision game for Android. How to Build BitteryApp source code build in chromium building environm

Flappy Bird game
Flappy Bird game

Flappy Bird by Compose ๐Ÿ“œ Description Flappy Bird game built with Jetpack Compose. ๐Ÿ’ก Motivation and Context All UI built with Jeptack Compose Images

The second iteration of the Xlite game.

Xlite 2.0 Xlite is a modular kotlin based RSPS. The goal of Xlite 2.0 is to provide the community with a stable and powerful sandbox to experiment wit

The Xlite Game Server.

Xlite 2.0 Xlite is a modular kotlin based RSPS. The goal of Xlite 2.0 is to provide the community with a stable and powerful sandbox to experiment wit

A simple Snake game implemented using Compose for Desktop
A simple Snake game implemented using Compose for Desktop

A simple Snake game implemented using Compose for Desktop

๐ŸŽฎ A basic game template for Compose for Desktop
๐ŸŽฎ A basic game template for Compose for Desktop

compose-desktop-game-template Game Template - Compose for Desktop โœจ Demo โœ๏ธ Author ๐Ÿ‘ค theapache64 Twitter: @theapache64 Email: [email protected] F

ByteLegend is a free, opensource MMORPG game where you acquire realworld high-paying programming skills.
Owner
Aislan Tavares
I try!
Aislan Tavares
Game made with Korge (Kotlin Multiplatform game engine)

MolesAttack Kotlin Multiplatform Game Play Html/js: https://feliperce.github.io/MolesAttack-Distribution/ Jar: https://feliperce.github.io/MolesAttack

Felipe Rodrigues 10 May 30, 2022
Our maze game is an 2d-animation game developed using android studio.

Our maze game is an 2d-animation game developed using android studio. The game consists of a ball and a board with a hole in the center of it. We are using accelerometer as controller to guide ball towards the hole. T

Suraj Devgan 6 Nov 29, 2022
An easy open source Android Native Game FrameWork.

JustWeEngine - Android Game FrameWork An easy open source Android Native Game FrameWork. Engine Flow Chart How To Use? Import Engine's module as Libra

JustWe 767 Dec 8, 2022
Desktop/Android/HTML5/iOS Java game development framework

Cross-platform Game Development Framework libGDX is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux

libgdx 20.9k Jan 8, 2023
Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

cocos2d-x Win32 Others cocos2d-x is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is

cocos2d 16.7k Dec 31, 2022
Free Android 2D OpenGL Game Engine

AndEngine Donations While developing AndEngine was a lot of fun, it also also consumed many(!) months of my life. It actually continues to cost me a s

Nicolas Gramlich 3.2k Jan 5, 2023
A cross-platform Java game Engine (Framework) , support JavaFX / Android / IOS / HTML5 / Linux / MAC / Windows

Loon Game Engine (Java Game Framework) EN / KR Free Game Resources Links Download Loon Game Engine Only Android-studio Template : androidstudio-templa

cping 502 Jan 4, 2023
Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

cocos2d-x Win32 Others cocos2d-x is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is

cocos2d 16.7k Jan 7, 2023
Experimental multiplayer game

Enjoy retro games? Enjoy multiplayer games? Ever wanted to play one retro game against a different game in real time?

Super Retro Mega Wars 114 Dec 18, 2022
In-game editor for item NBT

Building Gradle - Dependency Management The GradleWrapper in included in this project. On Windows: gradlew.bat clean build On MacOS/Linux: ./gradlew

TabooLib Project 12 Dec 27, 2022