Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Orbit Trails :: By oliver @pixelchipcode
- This script creates a mesmerizing visual of orbits, each with a sphere moving along its path
- and leaving behind a fading trail. The orbits have varying radii and speeds, creating a dynamic
- effect as they circle around the center of the room.
- Key Features:
- - **Varying Orbit Sizes**: The radius of each orbit increases incrementally, creating a spread-out effect.
- - **Varying Speeds**: Each orbit moves at a different speed, adding a variety of motion to the visual.
- - **Fading Trail**: Each sphere leaves a fading trail behind it as it moves, simulating the effect of motion over time.
- - **Distance Check**: Prevents visual glitches by skipping overly long lines between trail points.
- The result is a beautiful pattern of rotating spheres with smooth, fading trails, perfect for creating
- a hypnotic and engaging animation.
- Created in GML for GameMaker Studio, this minimal implementation leverages arrays and simple trigonometric
- functions to achieve a striking visual effect with just a few lines of code.
- */
- // Create Event
- orbits = [];
- repeat(200) {
- array_push(orbits, {
- radius: 50 + array_length(orbits) * 3,
- speed: random_range(0.001, 0.006),
- angle: random(360),
- trail: []
- });
- }
- // Step Event
- var i = 0;
- repeat(array_length(orbits)) {
- var orbit = orbits[i];
- orbit.angle += orbit.speed;
- if (orbit.angle >= 360) orbit.angle -= 360;
- array_insert(orbit.trail, 0, [
- room_width/2 + orbit.radius * cos(orbit.angle),
- room_height/2 + orbit.radius * sin(orbit.angle)
- ]);
- if (array_length(orbit.trail) > 200) array_pop(orbit.trail);
- i++;
- }
- // Draw Event
- var i = 0;
- repeat(array_length(orbits)) {
- var orbit = orbits[i];
- var j = 0;
- repeat(array_length(orbit.trail) - 1) {
- var pos1 = orbit.trail[j];
- var pos2 = orbit.trail[j + 1];
- if (point_distance(pos1[0], pos1[1], pos2[0], pos2[1]) <= 5) {
- draw_set_alpha(1 - j/array_length(orbit.trail));
- draw_line(pos1[0], pos1[1], pos2[0], pos2[1]);
- }
- j++;
- }
- draw_set_alpha(1);
- draw_circle(orbit.trail[0][0], orbit.trail[0][1], 3, false);
- i++;
- }
- draw_set_alpha(1);
Advertisement
Add Comment
Please, Sign In to add comment