Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Kaleidoscope Effect Code 🌈✨
- // Create Event
- // Create a surface with the dimensions of the room to draw the effect.
- surface = surface_create(room_width, room_height);
- // Step Event
- // Handle window resizing
- // If the room size changes, recreate the surface to match the new dimensions.
- if (surface_get_width(surface) != room_width || surface_get_height(surface) != room_height) {
- if (surface_exists(surface)) surface_free(surface); // Free the existing surface to avoid memory leaks.
- surface = surface_create(room_width, room_height); // Create a new surface with updated dimensions.
- }
- // Draw Event
- // Ensure the surface exists before drawing.
- if (!surface_exists(surface)) {
- surface = surface_create(room_width, room_height);
- }
- // Set the surface as the target for drawing.
- surface_set_target(surface);
- // Draw a point at the mouse position to create a dynamic effect.
- draw_point(mouse_x, mouse_y);
- // Reset the drawing target back to the application surface.
- surface_reset_target();
- // Draw the kaleidoscope effect by mirroring parts of the surface.
- // First, draw the base surface.
- draw_surface(surface, 0, 0);
- // Draw mirrored parts of the surface to create the kaleidoscope effect.
- draw_surface_part_ext(surface, 0, 0, room_width, room_height, room_width, 0, -1, 1, c_white, 1); // Mirror horizontally.
- draw_surface_part_ext(surface, 0, 0, room_width, room_height, room_width, room_height, -1, -1, c_white, 1); // Mirror both horizontally and vertically.
- draw_surface_part_ext(surface, 0, 0, room_width, room_height, 0, room_height, 1, -1, c_white, 1); // Mirror vertically.
Advertisement
Add Comment
Please, Sign In to add comment