commit dbf384e47b1d1552016a3886cc0731707fda4811 Author: Zsolt Tasnadi Date: Fri Jul 31 18:34:22 2026 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34cb8bb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +dist +*.zip +.version diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5192398 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + // Copy to .vscode/tasks.json. + "version": "2.0.0", + "tasks": [ + { + "label": "Serve", + "type": "shell", + "command": "make serve", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build Web", + "type": "shell", + "command": "make web", + "problemMatcher": [] + }, + { + "label": "Make build", + "type": "shell", + "command": "make build" + } + ] +} diff --git a/.woodpecker.yaml b/.woodpecker.yaml new file mode 100644 index 0000000..ade6b4c --- /dev/null +++ b/.woodpecker.yaml @@ -0,0 +1,35 @@ +steps: + - name: version + image: alpine + commands: + - apk add --no-cache git make jq + - make ci-version + + - name: build + image: node:22-alpine + commands: + - apk add --no-cache zip make curl + - make ci-export + + - name: upload + 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://teletypegames.org + UPDATE_SECRET: + from_secret: update_secret_key + commands: + - apk add --no-cache make curl + - make ci-update diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8b034cd --- /dev/null +++ b/Makefile @@ -0,0 +1,82 @@ +# ----------------------------------------- +# Makefile – Phaser project builder +# ----------------------------------------- + +PROJECT = phaserdemo + +PHASER_VERSION = 3.90.0 + +SRC_DIR = src +DIST_DIR = dist +WEB_DIR = $(DIST_DIR)/web +OUTPUT_ZIP = $(PROJECT)-$(VERSION).html.zip + +VERSION_FILE = .version +PHASER_JS_URL = https://cdn.jsdelivr.net/npm/phaser@$(PHASER_VERSION)/dist/phaser.min.js +INDEX_HTML_URL = https://git.teletype.hu/tools/phaser-tools/raw/branch/master/web/index.html + +all: build + +build: + @echo "==> Checking JS syntax" + @for f in $(SRC_DIR)/*.js; do node --check $$f; done + +web: build + @mkdir -p $(WEB_DIR) + @echo "==> Downloading Phaser $(PHASER_VERSION)" + curl -sSL $(PHASER_JS_URL) -o $(WEB_DIR)/phaser.min.js + @echo "==> Downloading index.html" + curl -sSL $(INDEX_HTML_URL) -o $(WEB_DIR)/index.html + @echo "==> Bundling game sources" + cat $(SRC_DIR)/*.js > $(WEB_DIR)/game.js + +serve: web + @echo "==> Serving on http://localhost:8000" + python3 -m http.server -d $(WEB_DIR) 8000 + +export: web + @if [ -z "$(VERSION)" ]; then \ + echo "ERROR: VERSION not set!"; exit 1; \ + fi + @echo "==> Packaging web build for $(VERSION)" + cd $(WEB_DIR) && zip -r ../../$(OUTPUT_ZIP) . + @echo "==> Cleaning temporary files" + rm -rf $(WEB_DIR) + +watch: + fswatch -o $(SRC_DIR) | while read; do make build; done + +clean: + rm -rf $(DIST_DIR) + +ci-version: + @if [ -f metadata.json ]; then \ + VERSION=$$(jq -r '.version' metadata.json); \ + else \ + VERSION=$$(git rev-parse --short HEAD); \ + fi; \ + BRANCH=$$(git rev-parse --abbrev-ref HEAD); \ + if [ "$$BRANCH" != "main" ] && [ "$$BRANCH" != "master" ]; then \ + VERSION="dev-$$VERSION-$$BRANCH"; \ + fi; \ + echo $$VERSION > $(VERSION_FILE) + +ci-export: + @VERSION=$$(cat $(VERSION_FILE)); \ + $(MAKE) export VERSION=$$VERSION + +ci-upload: + @VERSION=$$(cat $(VERSION_FILE)); \ + FILE="$(PROJECT)-$$VERSION.html.zip"; \ + META_SRC="metadata.json"; \ + META_DST="$(PROJECT)-$$VERSION.metadata.json"; \ + cp $$META_SRC $$META_DST; \ + sshpass -p "$(DROPAREA_SSH_PASSWORD)" scp -o StrictHostKeyChecking=no -P $(DROPAREA_PORT) \ + $$FILE $$META_DST \ + $(DROPAREA_USER)@$(DROPAREA_HOST):$(DROPAREA_TARGET_PATH)/ + +ci-update: + @VERSION=$$(cat $(VERSION_FILE)); \ + curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=phaser&version=$$VERSION" + +.PHONY: all build web serve export watch clean ci-version ci-export ci-upload ci-update diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..da7c234 --- /dev/null +++ b/metadata.json @@ -0,0 +1,9 @@ +{ + "name": "phaserdemo", + "title": "Phaser Demo", + "author": "Teletype Games", + "desc": "It's a simple demo program in Phaser", + "site": "https://git.teletype.hu/games/phaserdemo", + "license": "MIT License", + "version": "1.0.0" +} diff --git a/src/game.js b/src/game.js new file mode 100644 index 0000000..a544cb9 --- /dev/null +++ b/src/game.js @@ -0,0 +1,47 @@ +// game.js + +const SCREEN_W = 640; +const SCREEN_H = 480; +const MESSAGE = 'TELETYPE GAMES'; +const CHAR_W = 40; +const WAVE_AMPLITUDE = 28; + +const PALETTE = ['#1a1c2c', '#5d275d', '#b13e53', '#ef7d57', '#ffcd75']; + +class DemoScene extends Phaser.Scene { + create() { + const totalW = MESSAGE.length * CHAR_W; + const startX = (SCREEN_W - totalW) / 2 + CHAR_W / 2; + + this.letters = MESSAGE.split('').map((ch, i) => { + const style = { fontFamily: 'monospace', fontSize: '48px', fontStyle: 'bold' }; + + const shadow = this.add.text(startX + i * CHAR_W + 4, SCREEN_H / 2 + 4, ch, style) + .setOrigin(0.5).setColor('#000000').setAlpha(0.7); + const text = this.add.text(startX + i * CHAR_W, SCREEN_H / 2, ch, style) + .setOrigin(0.5).setColor(PALETTE[i % PALETTE.length]); + + return { shadow, text }; + }); + } + + update(time) { + const t = time / 400; + this.letters.forEach(({ shadow, text }, i) => { + const y = SCREEN_H / 2 + Math.sin(t + i * 0.4) * WAVE_AMPLITUDE; + text.y = y; + shadow.y = y + 4; + text.setColor(PALETTE[(i + Math.floor(t * 2)) % PALETTE.length]); + }); + } +} + +new Phaser.Game({ + type: Phaser.AUTO, + width: SCREEN_W, + height: SCREEN_H, + backgroundColor: '#000000', + parent: 'game', + scene: DemoScene, + title: 'Teletype Games' +});