12 years ago

GMK: Studio Code Snippet - Orbit


Code Snippet: Orbiting
Engine: Game Maker: Studio
https://www.yoyogames.com/studio

In your rotating object’s CREATE event, drag over an, “Execute Code” block and type:

// Setup the orbiting object’s variables
pDir = 0; // Where the orbiting object starts (0-360)
pDistance = 100; // The distance from the main object this orbits
pSpeed = 1; // Speed of the orbit

In your rotating object’s STEP event, drag over an, “Execute Code” block and type:

// Set the movement of your orbiting object
x = [yourObject].x + lengthdir_x(pDistance, pDir)
y = [yourObject].y + lengthdir_y(pDistance, pDir)

// Based on which direction you want, you can use +/- when adding the speed
pDir += pSpeed;

I hope that this helped anyone looking for some orbiting planets, buffs, or tornadoes in the future!

Cheers,
Joshua Long



0 comments

Loading...

Next up

Been working lately on lots of 'behind-the-scenes' boring stuff that no one really cares about, so here’s a guy playing the sax for some reason.

#screenshotsaturday

Enemies can also suddenly spawn through Realm Rifts. These Rift Spawns are going to be stronger than the ones wandering around. TBD on the enemies... #screenshotsaturday #godstear #madewithunity

Runestones: from concept to in-game model🗿

Just a Pico sprite

Family band complete!

So here's the first of the zodiac signs i will make for the next weeks.

A house I've built a while ago. :)

It nicely separates the snowy biome from the grassy one.

It's built with painted Ebonstone.

Terraria

Showing off player 2 😎

What do you think?