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

Smile! Here, take some happy pills! ✨💊 #Blender #3DModelling #3DArt Buy me a Ko-fi: https://ko-fi.com/barbarafb_

Protege el conocimiento, salva la historia. Guardian of Lore es un platformer 2D en el que debes luchar para mantener viva la memoria de la mitología latinoamericana. El juego llegará a Steam el 18 de mayo: https://steam.pm/app/1211740 #ScreenshotSaturday

Quantum precognition is one of the most powerful cards. End game cards & equipment. Demo/alpha build boss is no match for this deck.

Strange Umbrella

We're glad to announce that Baby Dino Adventures 🦖 is now available in Early Access here on GameJolt! Link: https://gamejolt.com/games/babydinoadventures/508121 Walk, run, and jump as a baby t-rex in this cute platformer Free demo available #IndieGame | #GameDev | #PixelArt

My D&D art for my family so far (WIP if you couldn't tell)

brung back my old oc plus a new one

...they don`t have names yet tho

Alone Together....

Our menu, gathered a huge feedback and positive comments among foreign audience, what you say? Game Steam: https://store.steampowered.com/app/1543090/LiBER/