game Of Life

This commit is contained in:
JurajKubrican
2025-03-04 16:31:19 +01:00
parent 7ed413648c
commit 00c209032f
16 changed files with 540 additions and 346 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/labstack/gommon/log"
"knet.sk/src/boxes"
"knet.sk/src/draw"
)
@@ -25,10 +26,10 @@ func NewTemplates() *Templates {
}
type Page struct {
Boxes map[int]bool
Boxes []boxes.Box
}
func newPage(boxes map[int]bool) Page {
func newPage(boxes []boxes.Box) Page {
return Page{
Boxes: boxes,
}
@@ -50,20 +51,16 @@ func main() {
e.Static("/js", "js")
e.GET("/", func(c echo.Context) error {
return c.Render(200, "index", newPage(getBoxes()))
return c.Render(200, "index", newPage(boxes.GetBoxes()))
})
e.GET("/boxes/ws", boxes.InitWs)
e.GET("/ws", initWs)
//favicon
e.File("/favicon.ico", "images/favicon.ico")
e.GET("/draw", draw.Page)
e.GET("/draw/ws", draw.InitWs)
e.Logger.Fatal(e.Start(":54321"))
defer db.Close()
}
func healthCheck(c echo.Context) error {