Skip to content

Conversation

@manuq
Copy link
Contributor

@manuq manuq commented Jun 27, 2024

To integer blocks for the viewport width and height. And one Vecto2 block for the viewport center.

@manuq
Copy link
Contributor Author

manuq commented Jun 27, 2024

Can be used like this:
Captura desde 2024-06-27 16-43-21

@manuq manuq force-pushed the viewport-value-blocks branch from 3a2d552 to cf4fa0d Compare June 27, 2024 19:47
Copy link
Contributor

@wnbaum wnbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely good to have some sort of blocks like these!

One issue I can think of is that the viewport width, height, and center are all in viewport pixel coordinates, not in our 2D scene coordinates. So when we get the viewport center, it is not the same as the 2D scene center that our camera is fixed on. We might want to add some extra conversion there.

Copy link
Contributor

@wnbaum wnbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's some suggestions that I forgot to add to the other review!

@manuq
Copy link
Contributor Author

manuq commented Jun 28, 2024

Definitely good to have some sort of blocks like these!

One issue I can think of is that the viewport width, height, and center are all in viewport pixel coordinates, not in our 2D scene coordinates. So when we get the viewport center, it is not the same as the 2D scene center that our camera is fixed on. We might want to add some extra conversion there.

Yes, this seems to be the convertion we need: https://forum.godotengine.org/t/how-do-i-get-the-center-of-the-screen-without-using-camera/20545/3?u=manuq

In the current architecture we can't do that easily. I managed to do it with lambda functions. The code looks bad but it works in Pong to reset the ball. See the fixup commit.

I also appended another commit to construct a Vector2 from X, Y float parameters. So these 2 are equivalent:
Captura desde 2024-06-28 10-34-02

manuq and others added 7 commits June 28, 2024 11:26
To integer blocks for the viewport width and height. And one Vecto2
block for the viewport center.
Co-authored-by: wnbaum <42101167+wnbaum@users.noreply.github.com>
Co-authored-by: wnbaum <42101167+wnbaum@users.noreply.github.com>
Co-authored-by: wnbaum <42101167+wnbaum@users.noreply.github.com>
@manuq manuq force-pushed the viewport-value-blocks branch from 7c8453e to c8808b9 Compare June 28, 2024 14:29
Copy link
Contributor

@wnbaum wnbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working as expected! Code looks good to me. The generated code with the lambdas is definitely ugly, but that's something to figure out in another PR.

@wnbaum wnbaum merged commit 896b230 into main Jun 28, 2024
@wnbaum wnbaum deleted the viewport-value-blocks branch June 28, 2024 20:53
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

Successfully merging this pull request may close these issues.

3 participants