From de5b309e0f06e93a963e09ef13c369ae7deeccc9 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sat, 25 Jul 2026 10:58:28 -0700 Subject: Port a game I wrote a long time ago to JS --- roseh.moe.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'roseh.moe.go') diff --git a/roseh.moe.go b/roseh.moe.go index 5a35147..f16ae55 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -189,7 +189,19 @@ func index(w http.ResponseWriter, _ *http.Request) { } var ( - //go:embed templates/pong.html.template + //go:embed templates/games/index.html.template + gamesIndexString string + gamesIndexTemplate = template.Must(outlinedTemplate(gamesIndexString)) +) + +func gamesIndex(w http.ResponseWriter, _ *http.Request) { + if err := gamesIndexTemplate.Execute(w, nil); err != nil { + log.Printf("Waning: gamesIndex: %s", err) + } +} + +var ( + //go:embed templates/games/pong.html.template pongString string pongTemplate = template.Must(template.New("pong").Parse(pongString)) ) @@ -200,6 +212,18 @@ func pong(w http.ResponseWriter, _ *http.Request) { } } +var ( + //go:embed templates/games/stallman-shooter.html.template + stallmanShooterString string + stallmanShooterTemplate = template.Must(outlinedTemplate(stallmanShooterString)) +) + +func stallmanShooter(w http.ResponseWriter, _ *http.Request) { + if err := stallmanShooterTemplate.Execute(w, nil); err != nil { + log.Printf("Warning: stallmanShooter: %s", err) + } +} + //go:embed static var staticFiles embed.FS @@ -897,7 +921,9 @@ func main() { mux := http.NewServeMux() mux.HandleFunc("GET /{$}", index) - mux.HandleFunc("GET /pong", pong) + mux.HandleFunc("GET /games/", gamesIndex) + mux.HandleFunc("GET /games/pong", pong) + mux.HandleFunc("GET /games/stallman", stallmanShooter) mux.HandleFunc("GET /qr.png", qrHandler) mux.HandleFunc("GET /wormhole", wormhole) mux.HandleFunc("POST /wormhole", wormholeUpload) -- cgit v1.3.1