From ea407663cfac7ead472a515c3fe697152bde7a35 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Fri, 30 Jan 2026 01:01:36 +0100 Subject: [PATCH] initial commit --- .gitignore | 2 ++ .version | 1 + .woodpecker.yml | 34 ++++++++++++++++++++++ Makefile | 61 +++++++++++++++++++++++++++++++++++++++ go.mod | 17 +++++++++++ go.sum | 22 ++++++++++++++ main.go | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ web/index.html | 15 ++++++++++ 8 files changed, 228 insertions(+) create mode 100644 .gitignore create mode 100644 .version create mode 100644 .woodpecker.yml create mode 100644 Makefile create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 web/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..49cb471 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +dist +*.zip diff --git a/.version b/.version new file mode 100644 index 0000000..c46765f --- /dev/null +++ b/.version @@ -0,0 +1 @@ +21a0989 diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..85143f4 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,34 @@ +steps: + - name: version + image: alpine + commands: + - apk add --no-cache git make + - make ci-version + + - name: build + image: golang:1.22 + commands: + - make ci-export + + - name: artifact + image: alpine + environment: + DROPAREA_HOST: vps.teletype.hu + DROPAREA_PORT: 2223 + DROPAREA_TARGET_PATH: /home/drop + DROPAREA_USER: drop + DROPAREA_SSH_PASSWORD: + from_secret: droparea_ssh_password + commands: + - apk add --no-cache make openssh-client sshpass + - make ci-upload + + - name: update + image: alpine + environment: + UPDATE_SERVER: https://games.vps.teletype.hu + UPDATE_SECRET: + from_secret: update_secret_key + commands: + - apk add --no-cache make curl + - make ci-update \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..df7417c --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +# ----------------------------------------- +# Makefile – Ebitengine project builder +# ----------------------------------------- + +PROJECT = ebitenginedemo + +BIN_DIR = bin +DIST_DIR = dist +WASM_NAME = game.wasm +OUTPUT_BIN = $(BIN_DIR)/$(PROJECT) +OUTPUT_WASM = $(DIST_DIR)/$(WASM_NAME) +OUTPUT_JS = $(DIST_DIR)/wasm_exec.js +OUTPUT_ZIP = $(PROJECT)-$(VERSION).html.zip + +VERSION_FILE = .version + +all: build + +build: + @mkdir -p $(BIN_DIR) + go build -o $(OUTPUT_BIN) . + +wasm: + @mkdir -p $(DIST_DIR) + GOOS=js GOARCH=wasm go build -o $(OUTPUT_WASM) . + cp "$$(go env GOROOT)/lib/wasm/wasm_exec.js" $(OUTPUT_JS) + +export: wasm + @if [ -z "$(VERSION)" ]; then \ + echo "ERROR: VERSION not set!"; exit 1; \ + fi + @echo "==> Packaging HTML/WASM for $(VERSION)" + cp web/index.html $(DIST_DIR)/index.html + zip -r $(OUTPUT_ZIP) -j $(DIST_DIR)/$(WASM_NAME) $(DIST_DIR)/wasm_exec.js $(DIST_DIR)/index.html + rm -f $(DIST_DIR)/$(WASM_NAME) $(DIST_DIR)/wasm_exec.js $(DIST_DIR)/index.html + +watch: + fswatch -o . | while read; do make build; done + +clean: + rm -rf $(BIN_DIR) $(DIST_DIR) + +ci-version: + @VERSION=$$(git describe --tags --dirty --always); \ + echo $$VERSION > $(VERSION_FILE) + +ci-export: + @VERSION=$$(cat $(VERSION_FILE)); \ + $(MAKE) export VERSION=$$VERSION + +ci-upload: + @VERSION=$$(cat $(VERSION_FILE)); \ + FILE=$(OUTPUT_ZIP); \ + sshpass -p "$(DROPAREA_SSH_PASSWORD)" scp -o StrictHostKeyChecking=no -P $(DROPAREA_PORT) \ + $$FILE $(DROPAREA_USER)@$(DROPAREA_HOST):$(DROPAREA_TARGET_PATH)/ + +ci-update: + @VERSION=$$(cat $(VERSION_FILE)); \ + curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=web&version=$$VERSION" + +.PHONY: all build wasm export watch clean ci-version ci-export ci-upload ci-update \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..807a325 --- /dev/null +++ b/go.mod @@ -0,0 +1,17 @@ +module teletype-demo + +go 1.25.6 + +require ( + github.com/hajimehoshi/ebiten/v2 v2.9.8 + golang.org/x/image v0.35.0 +) + +require ( + github.com/ebitengine/gomobile v0.0.0-20250923094054-ea854a63cce1 // indirect + github.com/ebitengine/hideconsole v1.0.0 // indirect + github.com/ebitengine/purego v0.9.0 // indirect + github.com/jezek/xgb v1.1.1 // indirect + golang.org/x/sync v0.17.0 // indirect + golang.org/x/sys v0.36.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7b66bd8 --- /dev/null +++ b/go.sum @@ -0,0 +1,22 @@ +github.com/ebitengine/gomobile v0.0.0-20250923094054-ea854a63cce1 h1:+kz5iTT3L7uU+VhlMfTb8hHcxLO3TlaELlX8wa4XjA0= +github.com/ebitengine/gomobile v0.0.0-20250923094054-ea854a63cce1/go.mod h1:lKJoeixeJwnFmYsBny4vvCJGVFc3aYDalhuDsfZzWHI= +github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj1yReDqE= +github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A= +github.com/ebitengine/purego v0.9.0 h1:mh0zpKBIXDceC63hpvPuGLiJ8ZAa3DfrFTudmfi8A4k= +github.com/ebitengine/purego v0.9.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/hajimehoshi/bitmapfont/v4 v4.1.0 h1:eE3qa5Do4qhowZVIHjsrX5pYyyPN6sAFWMsO7QREm3U= +github.com/hajimehoshi/bitmapfont/v4 v4.1.0/go.mod h1:/PD+aLjAJ0F2UoQx6hkOfXqWN7BkroDUMr5W+IT1dpE= +github.com/hajimehoshi/ebiten/v2 v2.9.8 h1:xI0hIctuTMjFFk8lqEcUzoLjFy8d/FOBa9PDTWX+1rw= +github.com/hajimehoshi/ebiten/v2 v2.9.8/go.mod h1:DAt4tnkYYpCvu3x9i1X/nK/vOruNXIlYq/tBXxnhrXM= +github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4= +github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= +github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU= +github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +golang.org/x/image v0.35.0 h1:LKjiHdgMtO8z7Fh18nGY6KDcoEtVfsgLDPeLyguqb7I= +golang.org/x/image v0.35.0/go.mod h1:MwPLTVgvxSASsxdLzKrl8BRFuyqMyGhLwmC+TO1Sybk= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= +golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= diff --git a/main.go b/main.go new file mode 100644 index 0000000..7069e13 --- /dev/null +++ b/main.go @@ -0,0 +1,76 @@ +package main + +import ( + "image/color" + "log" + "math" + "time" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/text" + "golang.org/x/image/font/basicfont" +) + +const ( + screenW = 640 + screenH = 480 + scale = 6.0 + spacing = 1 +) + +type Game struct { + start time.Time +} + +var palette = []color.RGBA{ + {0x1a, 0x1c, 0x2c, 0xff}, + {0x5d, 0x27, 0x5d, 0xff}, + {0xb1, 0x3e, 0x53, 0xff}, + {0xef, 0x7d, 0x57, 0xff}, + {0xff, 0xcd, 0x75, 0xff}, +} + +func (g *Game) Update() error { return nil } + +func (g *Game) Draw(screen *ebiten.Image) { + screen.Fill(color.Black) + + msg := "TELETYPE GAMES" + t := float64(time.Since(g.start).Milliseconds()) / 400.0 + + charW := int(7*scale) + spacing + totalW := len(msg) * charW + startX := (screenW - totalW) / 2 + baseY := screenH / 2 + + for i, r := range msg { + x := startX + i*charW + y := baseY + int(math.Sin(t+float64(i)*0.4)*28) + col := palette[(i+int(t*2))%len(palette)] + + draw := func(dx, dy int, c color.Color) { + op := &ebiten.DrawImageOptions{} + op.GeoM.Scale(scale, scale) + op.GeoM.Translate(float64(x+dx), float64(y+dy)) + op.ColorScale.ScaleWithColor(c) + text.DrawWithOptions(screen, string(r), basicfont.Face7x13, op) + } + + draw(4, 4, color.RGBA{0, 0, 0, 180}) + draw(0, 0, col) + } +} + +func (g *Game) Layout(_, _ int) (int, int) { + return screenW, screenH +} + +func main() { + ebiten.SetWindowSize(screenW, screenH) + ebiten.SetWindowTitle("Teletype Games") + + game := &Game{start: time.Now()} + if err := ebiten.RunGame(game); err != nil { + log.Fatal(err) + } +} \ No newline at end of file diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..0696f37 --- /dev/null +++ b/web/index.html @@ -0,0 +1,15 @@ + + + + + Ebitengine Game + + + + + +