Skip to content

Commit 2b7b0c0

Browse files
committed
Initial commit
0 parents  commit 2b7b0c0

47 files changed

Lines changed: 1675 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CI.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Build Docker image (bananas-buildenv)
17+
run: bash scripts/init.sh
18+
19+
- name: Compile ROM
20+
run: bash scripts/build.sh
21+
22+
- name: Verify ROM
23+
run: |
24+
test -s build/bananas.gb
25+
# Nintendo logo magic byte at 0x0104 — proves cart header is well-formed
26+
xxd -s 0x104 -l 1 build/bananas.gb | grep -q "ce"
27+
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: bananas-gb
31+
path: build/bananas.gb

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build output
2+
build/
3+
4+
# GBDK intermediate files
5+
*.o
6+
*.lst
7+
*.sym
8+
*.map
9+
*.cdb
10+
*.ihx
11+
*.noi
12+
13+
# macOS
14+
.DS_Store
15+
16+
# editors
17+
.vscode/
18+
.idea/
19+
*.swp
20+
21+
.venv/

.vscode/tasks.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Bananas: Init Docker Container",
6+
"type": "shell",
7+
"command": "${workspaceFolder}/scripts/init.sh",
8+
"group": "build",
9+
"presentation": { "reveal": "always", "panel": "shared" },
10+
"problemMatcher": []
11+
},
12+
{
13+
"label": "Bananas: Build",
14+
"type": "shell",
15+
"command": "${workspaceFolder}/scripts/build.sh",
16+
"group": { "kind": "build", "isDefault": true },
17+
"presentation": { "reveal": "always", "panel": "shared" },
18+
"problemMatcher": []
19+
},
20+
{
21+
"label": "Bananas: Clean",
22+
"type": "shell",
23+
"command": "${workspaceFolder}/scripts/build.sh clean",
24+
"group": "build",
25+
"presentation": { "reveal": "always", "panel": "shared" },
26+
"problemMatcher": []
27+
},
28+
{
29+
"label": "Bananas: Play",
30+
"type": "shell",
31+
"command": "${workspaceFolder}/scripts/play.sh",
32+
"group": "test",
33+
"presentation": { "reveal": "always", "panel": "shared" },
34+
"problemMatcher": []
35+
},
36+
{
37+
"label": "Bananas: Build & Play",
38+
"dependsOrder": "sequence",
39+
"dependsOn": ["Bananas: Build", "Bananas: Play"],
40+
"group": "test",
41+
"presentation": { "reveal": "always", "panel": "shared" },
42+
"problemMatcher": []
43+
}
44+
]
45+
}

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM debian:bookworm-slim
4+
5+
ARG GBDK_VERSION=4.5.0
6+
ARG TARGETARCH
7+
8+
RUN apt-get update && \
9+
apt-get install -y --no-install-recommends \
10+
make \
11+
curl \
12+
ca-certificates \
13+
tar \
14+
xz-utils \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
RUN case "${TARGETARCH}" in \
18+
arm64) TARBALL="gbdk-linux-arm64.tar.gz" ;; \
19+
*) TARBALL="gbdk-linux64.tar.gz" ;; \
20+
esac && \
21+
curl -fsSL "https://github.com/gbdk-2020/gbdk-2020/releases/download/${GBDK_VERSION}/${TARBALL}" | tar -xz -C /opt
22+
23+
ENV PATH="/opt/gbdk/bin:${PATH}"
24+
ENV GBDK_HOME="/opt/gbdk"
25+
26+
WORKDIR /bananas

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
GBDK_HOME ?= /opt/gbdk
2+
3+
BUILD_DIR := build
4+
ROM := $(BUILD_DIR)/bananas.gb
5+
GEN_DIR := $(BUILD_DIR)/generated
6+
SRC_DIR := src
7+
ASSET_DIR := assets
8+
9+
CC := $(GBDK_HOME)/bin/lcc
10+
PNG2ASSET := $(GBDK_HOME)/bin/png2asset
11+
12+
ASSET_PNGS := $(wildcard $(ASSET_DIR)/*.png)
13+
ASSET_SRCS := $(patsubst $(ASSET_DIR)/%.png,$(GEN_DIR)/%.c,$(ASSET_PNGS))
14+
ASSET_HDRS := $(ASSET_SRCS:.c=.h)
15+
SRCS := $(shell find $(SRC_DIR) -name '*.c') $(ASSET_SRCS)
16+
HDRS := $(shell find $(SRC_DIR) -name '*.h') $(ASSET_HDRS)
17+
18+
CPPFLAGS := -I$(BUILD_DIR)
19+
20+
PNG2ASSET_FLAGS := -keep_duplicate_tiles -no_palettes -map -bpp 2 -tiles_only -pack_mode gb -noflip -keep_palette_order
21+
22+
all: $(ROM)
23+
24+
$(BUILD_DIR) $(GEN_DIR):
25+
mkdir -p $@
26+
27+
$(GEN_DIR)/%.c: $(ASSET_DIR)/%.png Makefile | $(GEN_DIR)
28+
$(PNG2ASSET) $< $(PNG2ASSET_FLAGS) -c $@
29+
30+
# png2asset writes the matching header as a side effect of generating the C file.
31+
$(GEN_DIR)/%.h: $(GEN_DIR)/%.c ;
32+
33+
$(ROM): $(SRCS) $(HDRS) | $(BUILD_DIR)
34+
$(CC) $(CPPFLAGS) -o $@ $(SRCS)
35+
36+
clean:
37+
rm -rf $(BUILD_DIR)
38+
39+
.PHONY: all clean

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Bananas
2+
3+
[![CI](https://github.com/mdeclerk/Bananas/actions/workflows/CI.yml/badge.svg)](https://github.com/mdeclerk/Bananas/actions/workflows/CI.yml)
4+
5+
A 2-player artillery game for the original Game Boy (DMG), inspired by the classic [Gorillas (1991)](https://en.wikipedia.org/wiki/Gorillas_(video_game)). Two kongs, randomized & destructible terrain, ballistic bananas.
6+
7+
<p align="center">
8+
<img src="docs/image1.png" alt="Title screen" width="360">
9+
&nbsp;&nbsp;
10+
<img src="docs/image2.png" alt="Gameplay" width="360">
11+
</p>
12+
13+
## Getting Started
14+
15+
```sh
16+
./scripts/init.sh # one-time Docker build env setup
17+
./scripts/build.sh # compile → build/bananas.gb
18+
./scripts/play.sh # launch SameBoy (or mGBA)
19+
```
20+
21+
All scripts are also available as VS Code tasks via **Terminal → Run Task** (Init, Build, Clean, Play, Build & Play).
22+
23+
## How to play
24+
25+
**Controls** — D-pad: aim · A: fire · B: peek at opponent
26+
27+
<p align="center">
28+
<img src="docs/gameplay.gif" alt="Gameplay demo" width="336">
29+
</p>
30+
31+
## Prerequisites
32+
33+
- Docker (containerized build environment)
34+
- [SameBoy](https://sameboy.github.io/) (GameBoy emulator)
35+
- macOS, Linux, or WSL. Apple Silicon supported (Dockerfile auto-selects arm64 GBDK).
36+
37+
Inside the container: GBDK-2020 4.5.0, `lcc`/SDCC, `png2asset`, `make`.
38+
39+
## Project Structure
40+
41+
```
42+
src/ Source code — gameplay, physics, rendering, input, sfx
43+
assets/ PNG images (auto-converted to GB tile data by png2asset)
44+
build/
45+
bananas.gb ROM output
46+
generated/ auto-generated source code
47+
scripts/ build scripts
48+
Makefile build rules + asset pipeline
49+
Dockerfile GBDK build environment
50+
```

assets/.tmp/image.png

12.3 KB
Loading

assets/.tmp/kong.png

1.05 MB
Loading

assets/banana.png

189 Bytes
Loading

assets/crosshair.png

134 Bytes
Loading

0 commit comments

Comments
 (0)