Skip to content

danacr/tiny-gba

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gopher Zuri

Presentation

Recording and slides

Heavily based on Learning Go by examples by Aurélie Vache article series on Dev.to.

Please check Tinygo package compatibility before importing different packages

General

This simple app/game run on Game Boy Advance portable console and:

  • display a screen with "Gopher" text and "Press START button"
  • display two gophers
  • When you press START button: your Gopher player just appear
  • With multi directionnal arrows you can move your Gopher at left, right, top or bottom
  • When you press A button: your Gopher jump :-D
  • When you press SELECT button, you go back to "Start" screen

Pre-requisites

Install Go in 1.16 version minimum.

Brew:

brew install go-task
brew install tinygo
brew install mgba

Run the app (during development)

task run

Gopher GBA game

Note: time does not work: https://remyhax.xyz/posts/gba-blog/ tinygo-org/tinygo#1578

Build the app

task build

Test the app/game

Let's run our app on mGBA emulator:

task mgba

mGBA Controls

Controls are configurable in the settings menu of mGBA. Many game controllers should be automatically mapped by default. The default keyboard controls are as follows:

A: X
B: Z
L: A
R: S
Start: Enter
Select: Backspace

My changes:

  • I've refactored some of the functions
  • Improved the speed of the Gopher movement by implementing the redrawing the gopher
  • Added a check if the gopher is within the display frame
  • Added a Game Kill Screen :)
  • Added a score that is calculated based on number of interrupts passed
  • Added wind to generate random movement, I think now we can call it a game

Gopher Sceen

Note: sometimes the game randomly crashes :)

M1 Mac support:

If you get the following error:

MacBook-Air tiny-gba % task build
task: [build] GOFLAGS=-mod=mod tinygo build -size short -o bin/gopher.gba -target=gameboy-advance .
/opt/homebrew/bin/tinygo: line 2: /opt/homebrew/Cellar/tinygo/0.27.0/libexec/tinygo: Bad CPU type in executable
/opt/homebrew/bin/tinygo: line 2: /opt/homebrew/Cellar/tinygo/0.27.0/libexec/tinygo: Undefined error: 0
task: Failed to run task "build": exit status 1

Do this:

softwareupdate --install-rosetta
GOFLAGS=-mod=mod arch -x86_64 tinygo build -size short -o bin/gopher.gba -target=gameboy-advance .

It seems that Mac OS will remember to run this binary in x86 mode. You can now use the regular task build, no need to modify the Taskfile.yml

About

A Game Boy Advance Game using TinyGo

Resources

Stars

Watchers

Forks

Languages

  • Go 100.0%