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

18
main.go
View File

@@ -6,6 +6,7 @@ import (
_ "embed"
"log"
"net/http"
"os"
"github.com/google/uuid"
@@ -20,9 +21,11 @@ import (
"github.com/ryanhamamura/via/vianats"
)
var store = game.NewGameStore()
var snakeStore = snake.NewSnakeStore()
var queries *gen.Queries
var (
store = game.NewGameStore()
snakeStore = snake.NewSnakeStore()
queries *gen.Queries
)
//go:embed assets/css/output.css
var daisyUICSS []byte
@@ -35,6 +38,13 @@ func DaisyUIPlugin(v *via.V) {
v.AppendToHead(h.Link(h.Rel("stylesheet"), h.Href("/_plugins/daisyui/style.css")))
}
func port() string {
if p := os.Getenv("PORT"); p != "" {
return p
}
return "7331"
}
func main() {
if err := db.Init("c4.db"); err != nil {
log.Fatal(err)
@@ -60,7 +70,7 @@ func main() {
v.Config(via.Options{
LogLevel: via.LogLevelDebug,
DocumentTitle: "Game Lobby",
ServerAddress: ":7331",
ServerAddress: ":" + port(),
SessionManager: sessionManager,
PubSub: ns,
Plugins: []via.Plugin{DaisyUIPlugin},