F
FadedSketch
Guest
I've been working on this little prototype this past week, and I've been quite stumped at the start of it. Looks like I have much to learn, lol.
I followed the code from this post:https://forum.yoyogames.com/index.p...ovement-around-a-given-point.8030/#post-56644 for the general circular movement, but have been having a difficult time getting it to follow the mouse. (Like the player will follow the mouse, but is snapped to a circle path around the planet/center.) And the sprite (which right now is an Asteroid-esque triangle) needs to always be pointing to the mouse.
Here's my code:
The step event is a bit messy, I've just been trying all sorts of things that I can think of to get it to work.
So, any help? I'd much prefer you guys could point me in the right direction, vs. just showing the answer. I really want to learn as much as I can. But of course anything would be appreciated. ^^
I followed the code from this post:https://forum.yoyogames.com/index.p...ovement-around-a-given-point.8030/#post-56644 for the general circular movement, but have been having a difficult time getting it to follow the mouse. (Like the player will follow the mouse, but is snapped to a circle path around the planet/center.) And the sprite (which right now is an Asteroid-esque triangle) needs to always be pointing to the mouse.
Here's my code:
Code:
CREATE EVENT:
Orbit = 64; // Orbit distance
Angle = 0; // Current orbital angle
Speed = 1; // Orbital speed
Center_X = room_width / 2; // x of orbital center
Center_Y = room_height / 2; // y of orbital center
---
STEP EVENT:
Speed = sign(mouse_x);
// Orbital motion
Angle += Speed;
image_xscale = -1;
image_angle += Speed;
if(Angle >= 360) Angle -= 360;
if (image_angle >= 360) image_angle -= 360;
// Update position
x = lengthdir_x(64, Angle) + Planet.x;
y = lengthdir_y(64, Angle) + Planet.y;
---
So, any help? I'd much prefer you guys could point me in the right direction, vs. just showing the answer. I really want to learn as much as I can. But of course anything would be appreciated. ^^