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

Vector line draw functions #64

Closed
wants to merge 5 commits into from
Closed

Vector line draw functions #64

wants to merge 5 commits into from

Conversation

Leo-MathGuy
Copy link
Contributor

@Leo-MathGuy Leo-MathGuy commented Aug 6, 2023

Screen.deg_line(x0, y0, degrees, magnitude) -> Line with origin, degrees, and magnitude
Screen.rad_line(x0, y0, radians, magnitude) -> Line with origin, radians, and magnitude

Partially fixes #35 but wont be fully fixed until lists get added

This might be useful for game design, animations, and if someone decides to recreate a ti-84 in mindustry

Also fixes a small bug in sorted config test file

Copy link
Owner

@Lonami Lonami left a comment

Choose a reason for hiding this comment

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

pyndustri.pyi should be updated to explain what these do.

@Leo-MathGuy
Copy link
Contributor Author

Ok going to do that

@Leo-MathGuy
Copy link
Contributor Author

Done

Copy link
Owner

@Lonami Lonami left a comment

Choose a reason for hiding this comment

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

Thanks. These functions only work with literals, and won't work with runtime variable values, right? So I'm wondering how useful are they, in practice?

@Leo-MathGuy
Copy link
Contributor Author

Hmmm, I think its like that because it does the trig calculations during compilation of the program.
Is there a was in ast to get the value of a? (like *a in C to get the value of the variable from pointer a)

Like
`a = 50
b = 50

for i in range(0, 360):
Screen.deg_line(a, b, i, 10)

Screen.flush()`

Because the trig calculations are done during compilation, it tries to use "a" as the x0, not the value of a.

@Leo-MathGuy
Copy link
Contributor Author

Because of that its useless for now

@Leo-MathGuy
Copy link
Contributor Author

Leo-MathGuy commented Aug 6, 2023

Like if you do a/2 it tries to use "__pyc_tmp_3" (string) as x0

@Leo-MathGuy
Copy link
Contributor Author

@Lonami Is there a way in ast to check if a variable is a literal or variable name? And how to get the value of that variable?

@Lonami
Copy link
Owner

Lonami commented Aug 8, 2023

The value of variables is calculated while Mindustry runs the program. You cannot get it from the compiler, because the value may come from a sensor (such as reading how many items a container has).

The only way is to do the calculations inside Mindustry too.

Constant folding, which is in a way what you did here, is definitely useful and could be applied thorough the compiler (at the cost of increased complexity). I'm not sure we should start doing that until we figure out a clean design, but this is a whole difḟerent topic entirely.

@Leo-MathGuy Leo-MathGuy closed this Aug 8, 2023
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.

Vectorize coordinates in draw commands?
3 participants