From 115dcb0666f83f67ca80f1253ea5c85e9fb8348e Mon Sep 17 00:00:00 2001 From: SolarLune Date: Wed, 26 Jan 2022 09:23:22 -0800 Subject: [PATCH] Adding Space.CheckCellsWorld(). Updating readme. --- readme.md | 2 +- space.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index b5f51ec..b6d0d48 100755 --- a/readme.md +++ b/readme.md @@ -223,7 +223,7 @@ func Update() { ___ -Welp, that's about it. If you want to see more info, feel free to examine the examples in the `examples` folder; the `worldPlatformer.go` example is particularly in-depth when it comes to movement and collision response. +Welp, that's about it. If you want to see more info, feel free to examine the examples in the `examples` folder; the `worldPlatformer.go` example is particularly in-depth when it comes to movement and collision response. You can run them by just calling `go run .` from the examples folder. [You can check out the documentation here, as well.](https://pkg.go.dev/github.com/solarlune/resolv) diff --git a/space.go b/space.go index ba3e25e..aba9e68 100755 --- a/space.go +++ b/space.go @@ -156,6 +156,18 @@ func (sp *Space) CheckCells(x, y, w, h int, tags ...string) *Object { } +// CheckCellsWorld checks the cells of the Grid with the given world coordinates. +// Internally, this is just syntactic sugar for calling Space.WorldToSpace() on the +// position and size given. +func (sp *Space) CheckCellsWorld(x, y, w, h float64, tags ...string) *Object { + + sx, sy := sp.WorldToSpace(x, y) + cw, ch := sp.WorldToSpace(w, h) + + return sp.CheckCells(sx, sy, cw, ch, tags...) + +} + // UnregisterAllObjects unregisters all Objects registered to Cells in the Space. func (sp *Space) UnregisterAllObjects() {