collision2d
collision2d copied to clipboard
Box pos is not center.
The comment on NewBox shows that the position of the box is the center of the box, but it's the top left corner of the box, which is pretty standard. The comment just threw me off.
Great library! You're saving me a bunch of time. -TiM-
Hello!
I do not understand the problem. Could you show some code as an example?
With a test case we can fix either the code or the doc message.
Thank you!
Sure.
package main
import (
"fmt"
"github.com/Tarliton/collision2d"
)
func main(){
box1:=collision2d.NewBox(collision2d.Vector{X:0,Y:0},16,16)
polygon1:=box1.ToPolygon()
fmt.Println(polygon1)
}
The output is:
{Pos:{X:0.000000, Y:0.000000} Offset:{X:0.000000, Y:0.000000} Angle: 0.000000 Points: [{X:0.000000, Y:0.000000} {X:16.000000, Y:0.000000} {X:16.000000, Y:16.000000} {X:0.000000, Y:16.000000} ] CalcPoints: [{X:0.000000, Y:0.000000} {X:16.000000, Y:0.000000} {X:16.000000, Y:16.000000} {X:0.000000, Y:16.000000} ]}
So the points show 0,0 in the top left corner. Instead of 0,0 being the center.
You know I keep saying top left when really it's bottom left. I'm used to dealing with screens where 0,0 is the top left corner, and max width and height are the bottom right corner.
The problem is here.
It should use center to calculate those corners.