switched to yadu debug log
This commit is contained in:
parent
c9f8783521
commit
48396e7e0a
@ -2,10 +2,10 @@ package assets
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
|
"log/slog"
|
||||||
"openquell/util"
|
"openquell/util"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -128,10 +128,11 @@ func LoadLevels(dir string) []RawLevel {
|
|||||||
for _, levelfile := range entries {
|
for _, levelfile := range entries {
|
||||||
if levelfile.Type().IsRegular() && strings.Contains(levelfile.Name(), ".lvl") {
|
if levelfile.Type().IsRegular() && strings.Contains(levelfile.Name(), ".lvl") {
|
||||||
path := filepath.Join("assets", dir)
|
path := filepath.Join("assets", dir)
|
||||||
fmt.Printf("LOADING level %s/%s ... ", path, levelfile)
|
|
||||||
level := ParseRawLevel(path, levelfile)
|
level := ParseRawLevel(path, levelfile)
|
||||||
fmt.Printf("done\n")
|
|
||||||
levels = append(levels, level)
|
levels = append(levels, level)
|
||||||
|
|
||||||
|
slog.Debug("loaded level", "path", path, "file", levelfile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,10 @@ package assets
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
"log"
|
"log"
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -30,13 +30,8 @@ func LoadImages(dir string) AssetRegistry {
|
|||||||
log.Fatalf("failed to read assets dir %s: %s", dir, err)
|
log.Fatalf("failed to read assets dir %s: %s", dir, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range entries {
|
|
||||||
fmt.Println(entry.Name())
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, imagefile := range entries {
|
for _, imagefile := range entries {
|
||||||
path := filepath.Join("assets", dir, imagefile.Name())
|
path := filepath.Join("assets", dir, imagefile.Name())
|
||||||
fmt.Printf("LOADING %s ... ", path)
|
|
||||||
fd, err := os.Open(path)
|
fd, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to open image file %s: %s", imagefile.Name(), err)
|
log.Fatalf("failed to open image file %s: %s", imagefile.Name(), err)
|
||||||
@ -51,7 +46,8 @@ func LoadImages(dir string) AssetRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
images[name] = ebiten.NewImageFromImage(img)
|
images[name] = ebiten.NewImageFromImage(img)
|
||||||
fmt.Printf("done\n")
|
|
||||||
|
slog.Debug("loaded asset", "path", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return images
|
return images
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package components
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
"log/slog"
|
||||||
. "openquell/config"
|
. "openquell/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -83,10 +84,13 @@ func (tile *Position) Intersects(moving *Position, velocity *Velocity) (bool, *P
|
|||||||
|
|
||||||
is := tile.Rect.Bounds().Intersect(object.Rect.Bounds())
|
is := tile.Rect.Bounds().Intersect(object.Rect.Bounds())
|
||||||
if is != image.ZR {
|
if is != image.ZR {
|
||||||
fmt.Printf(" velocity: %d,%d\n", velocity.Data.X, velocity.Data.Y)
|
slog.Debug("Intersect",
|
||||||
fmt.Printf(" player: %s\n", moving.Rect)
|
"velocity", velocity.Data,
|
||||||
fmt.Printf("moved player: %s\n", object.Rect)
|
"player", moving.Rect,
|
||||||
fmt.Printf("collision at: %s\n", is)
|
"moved player", object.Rect,
|
||||||
|
"collision at", is,
|
||||||
|
)
|
||||||
|
|
||||||
// collision, snap into neighbouring tile depending on the direction
|
// collision, snap into neighbouring tile depending on the direction
|
||||||
switch velocity.Direction {
|
switch velocity.Direction {
|
||||||
case West:
|
case West:
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log/slog"
|
||||||
"openquell/assets"
|
"openquell/assets"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
@ -43,7 +43,7 @@ func (scene *LevelScene) SetNext() int {
|
|||||||
|
|
||||||
func (scene *LevelScene) Update() error {
|
func (scene *LevelScene) Update() error {
|
||||||
if scene.CurrentLevel != scene.Game.Observer.CurrentLevel {
|
if scene.CurrentLevel != scene.Game.Observer.CurrentLevel {
|
||||||
fmt.Printf("current: %d, next: %d\n", scene.CurrentLevel, scene.Game.Observer.CurrentLevel)
|
slog.Debug("level", "current", scene.CurrentLevel, "next", scene.Game.Observer.CurrentLevel)
|
||||||
scene.CurrentLevel = scene.Game.Observer.CurrentLevel
|
scene.CurrentLevel = scene.Game.Observer.CurrentLevel
|
||||||
scene.Levels[scene.CurrentLevel].SetupGrid(scene.Game)
|
scene.Levels[scene.CurrentLevel].SetupGrid(scene.Game)
|
||||||
}
|
}
|
||||||
|
|||||||
7
go.mod
7
go.mod
@ -10,10 +10,15 @@ require (
|
|||||||
require (
|
require (
|
||||||
github.com/alecthomas/repr v0.3.0 // indirect
|
github.com/alecthomas/repr v0.3.0 // indirect
|
||||||
github.com/ebitengine/purego v0.5.0 // indirect
|
github.com/ebitengine/purego v0.5.0 // indirect
|
||||||
|
github.com/fatih/color v1.16.0 // indirect
|
||||||
github.com/jezek/xgb v1.1.0 // indirect
|
github.com/jezek/xgb v1.1.0 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/tlinden/yadu v0.1.2 // indirect
|
||||||
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 // indirect
|
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 // indirect
|
||||||
golang.org/x/image v0.12.0 // indirect
|
golang.org/x/image v0.12.0 // indirect
|
||||||
golang.org/x/mobile v0.0.0-20230922142353-e2f452493d57 // indirect
|
golang.org/x/mobile v0.0.0-20230922142353-e2f452493d57 // indirect
|
||||||
golang.org/x/sync v0.3.0 // indirect
|
golang.org/x/sync v0.3.0 // indirect
|
||||||
golang.org/x/sys v0.12.0 // indirect
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
16
go.sum
16
go.sum
@ -2,12 +2,21 @@ github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8
|
|||||||
github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||||
github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
|
github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
|
||||||
github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
|
github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
|
||||||
|
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||||
|
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||||
github.com/hajimehoshi/ebiten/v2 v2.6.5 h1:lALv+qhEK3CBWViyiGpz4YcR6slVJEjCiS7sExKZ9OE=
|
github.com/hajimehoshi/ebiten/v2 v2.6.5 h1:lALv+qhEK3CBWViyiGpz4YcR6slVJEjCiS7sExKZ9OE=
|
||||||
github.com/hajimehoshi/ebiten/v2 v2.6.5/go.mod h1:TZtorL713an00UW4LyvMeKD8uXWnuIuCPtlH11b0pgI=
|
github.com/hajimehoshi/ebiten/v2 v2.6.5/go.mod h1:TZtorL713an00UW4LyvMeKD8uXWnuIuCPtlH11b0pgI=
|
||||||
github.com/jezek/xgb v1.1.0 h1:wnpxJzP1+rkbGclEkmwpVFQWpuE2PUGNUzP8SbfFobk=
|
github.com/jezek/xgb v1.1.0 h1:wnpxJzP1+rkbGclEkmwpVFQWpuE2PUGNUzP8SbfFobk=
|
||||||
github.com/jezek/xgb v1.1.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
github.com/jezek/xgb v1.1.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
||||||
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mlange-42/arche v0.10.0 h1:fEFDAYMAnWa+xHc1oq4gVcA4PuEQOCGSRXSKITXawMw=
|
github.com/mlange-42/arche v0.10.0 h1:fEFDAYMAnWa+xHc1oq4gVcA4PuEQOCGSRXSKITXawMw=
|
||||||
github.com/mlange-42/arche v0.10.0/go.mod h1:gJ5J8vBreqrf4TcBomBFPGnWdE5P3qa4LtxYHn1gDcg=
|
github.com/mlange-42/arche v0.10.0/go.mod h1:gJ5J8vBreqrf4TcBomBFPGnWdE5P3qa4LtxYHn1gDcg=
|
||||||
|
github.com/tlinden/yadu v0.1.2 h1:TYYVnUJwziRJ9YPbIbRf9ikmDw0Q8Ifixm+J/kBQFh8=
|
||||||
|
github.com/tlinden/yadu v0.1.2/go.mod h1:l3bRmHKL9zGAR6pnBHY2HRPxBecf7L74BoBgOOpTcUA=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
@ -33,9 +42,13 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
@ -49,3 +62,6 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
|
|||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
package grid
|
package grid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
"log"
|
"log"
|
||||||
|
"log/slog"
|
||||||
"openquell/assets"
|
"openquell/assets"
|
||||||
"openquell/components"
|
"openquell/components"
|
||||||
"openquell/config"
|
"openquell/config"
|
||||||
@ -66,7 +66,7 @@ func NewGrid(world *ecs.World,
|
|||||||
pos, _, render, speed, _ = playermapper.Get(entity)
|
pos, _, render, speed, _ = playermapper.Get(entity)
|
||||||
playerobserver.AddEntity(entity)
|
playerobserver.AddEntity(entity)
|
||||||
speed.Value = config.PLAYERSPEED
|
speed.Value = config.PLAYERSPEED
|
||||||
fmt.Printf("player start pos: %d,%d\n", point.X*tilesize, point.Y*tilesize)
|
slog.Debug("player start pos", "X", point.X*tilesize, "Y", point.Y*tilesize, "Z", 191)
|
||||||
case tile.Collectible:
|
case tile.Collectible:
|
||||||
entity := colmapper.New()
|
entity := colmapper.New()
|
||||||
pos, render, _ = colmapper.Get(entity)
|
pos, render, _ = colmapper.Get(entity)
|
||||||
|
|||||||
16
main.go
16
main.go
@ -2,9 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"log/slog"
|
||||||
"openquell/game"
|
"openquell/game"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
|
"github.com/tlinden/yadu"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -17,6 +20,19 @@ func main() {
|
|||||||
ebiten.SetWindowSize(width, height)
|
ebiten.SetWindowSize(width, height)
|
||||||
ebiten.SetWindowTitle("openquell")
|
ebiten.SetWindowTitle("openquell")
|
||||||
|
|
||||||
|
logLevel := &slog.LevelVar{}
|
||||||
|
opts := &yadu.Options{
|
||||||
|
Level: logLevel,
|
||||||
|
AddSource: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
logLevel.Set(slog.LevelDebug)
|
||||||
|
|
||||||
|
handler := yadu.NewHandler(os.Stdout, opts)
|
||||||
|
|
||||||
|
debuglogger := slog.New(handler)
|
||||||
|
slog.SetDefault(debuglogger)
|
||||||
|
|
||||||
g := game.NewGame(width, height, cellsize, 0, game.Play)
|
g := game.NewGame(width, height, cellsize, 0, game.Play)
|
||||||
|
|
||||||
err := ebiten.RunGame(g)
|
err := ebiten.RunGame(g)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package systems
|
package systems
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log/slog"
|
||||||
"openquell/assets"
|
"openquell/assets"
|
||||||
"openquell/components"
|
"openquell/components"
|
||||||
. "openquell/components"
|
. "openquell/components"
|
||||||
@ -54,7 +54,7 @@ func (system *CollectibleSystem) Update() {
|
|||||||
|
|
||||||
ok, _ := playerposition.Intersects(colposition, playervelocity)
|
ok, _ := playerposition.Intersects(colposition, playervelocity)
|
||||||
if ok {
|
if ok {
|
||||||
fmt.Printf("bumped into collectible %v\n", collectible)
|
slog.Debug("bumped into collectible", "collectible", collectible)
|
||||||
particlepositions = append(particlepositions, colposition)
|
particlepositions = append(particlepositions, colposition)
|
||||||
EntitiesToRemove = append(EntitiesToRemove, query.Entity())
|
EntitiesToRemove = append(EntitiesToRemove, query.Entity())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package systems
|
package systems
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
"image/draw"
|
"image/draw"
|
||||||
"openquell/components"
|
"openquell/components"
|
||||||
@ -141,16 +140,12 @@ func (system *GridSystem) BumpEdge(
|
|||||||
switch velocity.Direction {
|
switch velocity.Direction {
|
||||||
case East:
|
case East:
|
||||||
X = 0
|
X = 0
|
||||||
fmt.Println("east X=0")
|
|
||||||
case West:
|
case West:
|
||||||
X = system.Width - system.Tilesize
|
X = system.Width - system.Tilesize
|
||||||
fmt.Println("west X=max")
|
|
||||||
case South:
|
case South:
|
||||||
Y = 0
|
Y = 0
|
||||||
fmt.Println("south y=0")
|
|
||||||
case North:
|
case North:
|
||||||
Y = system.Height - system.Tilesize
|
Y = system.Height - system.Tilesize
|
||||||
fmt.Println("north y=max")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newpos.Update(X, Y, system.Tilesize)
|
newpos.Update(X, Y, system.Tilesize)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package systems
|
package systems
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log/slog"
|
||||||
. "openquell/components"
|
. "openquell/components"
|
||||||
. "openquell/config"
|
. "openquell/config"
|
||||||
|
|
||||||
@ -53,19 +53,17 @@ func (system PlayerSystem) Update() error {
|
|||||||
if velocity.Moving() {
|
if velocity.Moving() {
|
||||||
ok, newpos := system.Grid.BumpEdge(playerposition, velocity)
|
ok, newpos := system.Grid.BumpEdge(playerposition, velocity)
|
||||||
if ok {
|
if ok {
|
||||||
fmt.Printf("falling off the edge, new pos: %v\n", newpos)
|
slog.Debug("falling off the edge", "newpos", newpos)
|
||||||
playerposition.Set(newpos)
|
playerposition.Set(newpos)
|
||||||
} else {
|
} else {
|
||||||
ok, tilepos := system.Grid.GetSolidNeighborPosition(playerposition, velocity, true)
|
ok, tilepos := system.Grid.GetSolidNeighborPosition(playerposition, velocity, true)
|
||||||
if ok {
|
if ok {
|
||||||
intersects, newpos := tilepos.Intersects(playerposition, velocity)
|
intersects, newpos := tilepos.Intersects(playerposition, velocity)
|
||||||
if intersects {
|
if intersects {
|
||||||
fmt.Printf("collision detected. tile: %s\n", tilepos)
|
slog.Debug("collision detected", "tile",
|
||||||
fmt.Printf(" player: %s\n", playerposition)
|
tilepos, "player", playerposition, "new", newpos)
|
||||||
fmt.Printf(" new: %s\n", newpos)
|
|
||||||
|
|
||||||
playerposition.Set(newpos)
|
playerposition.Set(newpos)
|
||||||
fmt.Printf(" player new: %s\n", playerposition)
|
|
||||||
velocity.Change(Stop)
|
velocity.Change(Stop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user