initial commit
Some checks failed
ci/woodpecker/manual/woodpecker Pipeline failed

This commit is contained in:
2026-01-30 01:01:36 +01:00
commit 2e91ed2224
6 changed files with 216 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
dist
*.zip
.version

34
.woodpecker.yml Normal file
View File

@@ -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

64
Makefile Normal file
View File

@@ -0,0 +1,64 @@
# -----------------------------------------
# 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
INDEX_HTML_URL = https://git.teletype.hu/tools/ebitengine-tools/raw/branch/master/web/index.html
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 "==> Downloading index.html"
curl -sSL $(INDEX_HTML_URL) -o $(DIST_DIR)/index.html
@echo "==> Packaging HTML/WASM for $(VERSION)"
zip -r $(OUTPUT_ZIP) -j $(DIST_DIR)/$(WASM_NAME) $(DIST_DIR)/wasm_exec.js $(DIST_DIR)/index.html
@echo "==> Cleaning temporary files"
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=ebitengine&version=$$VERSION"
.PHONY: all build wasm export watch clean ci-version ci-export ci-upload ci-update

17
go.mod Normal file
View File

@@ -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
)

22
go.sum Normal file
View File

@@ -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=

76
main.go Normal file
View File

@@ -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)
}
}