PixelChipCode

GameMaker : Creates a rainbow, floating text effect with triple shadow

Oct 31st, 2024
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.67 KB | Source Code | 0 0
  1. /// @function draw_ethereal_text(x, y, text)
  2. /// @param {real} x X position to start drawing
  3. /// @param {real} y Y position to start drawing
  4. /// @param {string} text Text to animate
  5. /// @description Creates a rainbow, floating text effect with triple shadow
  6. function draw_ethereal_text(xx, yy, text) {
  7.     var t = current_time/500;  // Time variable for animation
  8.     var len = string_length(text);  // Get actual text length
  9.    
  10.     // Save previous blend mode and alpha
  11.     var prev_blend = gpu_get_blendmode();
  12.     var prev_alpha = draw_get_alpha();
  13.    
  14.     // Setup additive blending for glow effect
  15.     gpu_set_blendmode(bm_add);
  16.    
  17.     // Draw three layers of floating text
  18.     for(var p = 3; p--; ) {
  19.         // Draw each character
  20.         for(var i = len; i--; ) {
  21.             // Create rainbow color cycling
  22.             draw_set_color(make_color_hsv(
  23.                 (t*100 + i*20 + p*85) % 256,  // Hue cycles over time
  24.                 255,  // Full saturation
  25.                 255   // Full value
  26.             ));
  27.            
  28.             // Set transparency for glow effect
  29.             draw_set_alpha(0.3);
  30.            
  31.             // Draw character with wave motion
  32.             draw_text(
  33.                 xx + i*20 + sin(t + i/2)*15 + p*2,  // X with wave
  34.                 yy + cos(t*2 + i/3)*10 + p*2,        // Y with wave
  35.                 string_char_at(text, i+1)
  36.             );
  37.         }
  38.     }
  39.    
  40.     // Restore previous state
  41.     gpu_set_blendmode(prev_blend);
  42.     draw_set_alpha(prev_alpha);
  43. }
  44.  
  45. // Example usage:
  46. // draw_ethereal_text(room_width/2, room_height/2, "Lost and found");
  47. // draw_ethereal_text(mouse_x, mouse_y, "Within without");
Tags: gameMaker
Advertisement
Add Comment
Please, Sign In to add comment