I'm currently making a "solarsystem" for fun and to get a better understanding of how Löve2D works.
I've just hit a roadblock in where I try to make my planets rotate around a point that's supposed to be in the middle of the screen and for some reason the rotation is set in the upper left corner of the window.
Is there anyway for my to change the rotations "origin point" to the middle of the screen.
I'm also open for suggestions on how to make the code more efficient
Thanks!
That it's rotating around the upper left corner is good because it's the origin(x=0 and y=0). Just translate the origin to the desired position the way you're doing it.
Or if you wanna have rotation and translation in the same line:
planetX = math.cos(angle) * rotation_radius + rotation_center_offsetX
planetY = math.sin(angle) * rotation_radius + rotation_center_offsetY
Where rotation_center_offsetX would be how you initiated planetX in the load function. You can also do this outside the load function.
Next thing you should implement are loops and a table for your planets. So you don't have to have like 2-5 variables per planet floating as upvalues around.
Also I think it's the wrong forum to ask for help here.
SirRanjid wrote: ↑Fri Jan 12, 2018 3:55 pm
That it's rotating around the upper left corner is good because it's the origin(x=0 and y=0). Just translate the origin to the desired position the way you're doing it.
Or if you wanna have rotation and translation in the same line:
planetX = math.cos(angle) * rotation_radius + rotation_center_offsetX
planetY = math.sin(angle) * rotation_radius + rotation_center_offsetY
Where rotation_center_offsetX would be how you initiated planetX in the load function. You can also do this outside the load function.
Next thing you should implement are loops and a table for your planets. So you don't have to have like 2-5 variables per planet floating as upvalues around.
Also I think it's the wrong forum to ask for help here.
I was actually think of using a table for the planets but I wanted to test doing the "dirty" way first and see what happens and I have been looking at the "parametric equation" for a circle but math ain't my strong suit
But I'll take a stab at it tomorrow and see if I can get it to work