Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box pos is not center. #1

Open
agentabstract opened this issue Apr 29, 2019 · 4 comments
Open

Box pos is not center. #1

agentabstract opened this issue Apr 29, 2019 · 4 comments

Comments

@agentabstract
Copy link

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-

@Tarliton
Copy link
Owner

Tarliton commented May 2, 2019

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!

@agentabstract
Copy link
Author

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.

@agentabstract
Copy link
Author

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.

@Tarliton
Copy link
Owner

The problem is here.
It should use center to calculate those corners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants