Add visual smoothing for snake game and systemd deployment

CSS animations for smoother 60fps feel despite 7Hz game ticks:
- 130ms transitions on cell background/box-shadow
- Head pop-in animation on direction changes
- Food pulse animation
- Smooth death state fade with grayscale

Per-snake colored glow on head cells.

Make server port configurable via PORT env var (default 8080).

Add deploy/ with systemd service and scripts:
- setup.sh: create games user, /opt/c4, install unit
- deploy.sh: build and install binary, restart service
- package.sh: cross-compile, tarball, base64 split for transfer
- reassemble.sh: decode and extract on target server
This commit is contained in:
Ryan Hamamura
2026-02-04 06:50:18 -10:00
parent 038c4b3f22
commit 2dc75107d1
9 changed files with 307 additions and 1770 deletions

29
deploy/setup.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# One-time setup: create the games user, install directory, and systemd unit.
# Run as root (or with sudo).
set -euo pipefail
if [[ $EUID -ne 0 ]]; then
echo "Run as root: sudo $0" >&2
exit 1
fi
# Create system user if it doesn't exist
if ! id -u games &>/dev/null; then
useradd --system --shell /usr/sbin/nologin --home-dir /opt/c4 --create-home games
echo "Created system user: games"
else
echo "User 'games' already exists"
fi
# Ensure install directory exists with correct ownership
install -d -o games -g games -m 755 /opt/c4
install -d -o games -g games -m 755 /opt/c4/data
# Install systemd unit
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cp "$SCRIPT_DIR/c4.service" /etc/systemd/system/c4.service
systemctl daemon-reload
systemctl enable c4.service
echo "Setup complete. Run deploy.sh to build and start the service."