Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- By oliver
- @pixelchipcode
- Some random GML snippets for mini animations
- = = = = = = = = = = Mini pixel typewriter effect
- /// Create Event
- words = [];
- max_width = 35; // Adjusted for a 50px wide window with margins
- x_start = 10; // Starting X position for the "text"
- y_start = 15; // Starting Y position
- line_height = 3; // Adjusted for tighter lines as in the image
- word_gap = 1; // Space between blocks (1px gap)
- block_height = 1; // Height of each block
- // Generating random word lengths between 2 to 5
- for (var i = 0; i < 60; i++) { // Increased number of words for more content
- var word_length = irandom_range(2, 5);
- array_push(words, word_length);
- }
- word_index = 0;
- char_timer = 0;
- char_delay = 5; // Speed of typing effect
- pause_timer = 0;
- pause_duration = room_speed * 3; // Pause for 3 seconds (adjust as needed)
- is_paused = false;
- current_x = x_start;
- current_y = y_start;
- /// Step Event
- if (!is_paused) {
- if (char_timer >= char_delay) {
- char_timer = 0;
- if (word_index < array_length(words)) {
- word_index++;
- } else {
- // Start pause when all words are typed
- is_paused = true;
- pause_timer = 0;
- }
- }
- char_timer++;
- } else {
- // Handle pause
- pause_timer++;
- if (pause_timer >= pause_duration) {
- // Reset after pause
- is_paused = false;
- word_index = 0;
- current_x = x_start;
- current_y = y_start;
- }
- }
- // Draw Event
- draw_clear(c_black);
- draw_set_color(c_ltgray);
- current_x = x_start;
- current_y = y_start;
- for (var i = 0; i < word_index; i++) {
- var word_width = words[i];
- // Check if it exceeds the max width for a new line
- if (current_x + word_width > x_start + max_width) {
- current_x = x_start;
- current_y += line_height;
- }
- // Draw the block (representing a word)
- draw_rectangle(current_x, current_y, current_x + word_width - 1, current_y + block_height - 1, false);
- // Move to the next block position, including the gap
- current_x += word_width + word_gap;
- }
- = = = = = = = = = = Mini pixel soundwave erractic
- /// Create Event
- width = 50;
- height = 50;
- bar_width = 1; // Width of each bar
- bar_gap = 1; // Gap between bars
- num_bars = floor(width / (bar_width + bar_gap));
- amplitudes = array_create(num_bars, 0);
- max_height = height / 4; // Maximum height of bars (from center)
- min_height = 2; // Minimum height of bars (from center)
- update_speed = 0.2;
- variance_factor = 0.7; // Controls the amount of height variance
- /// Draw Event
- draw_clear(c_black);
- draw_set_color(c_white);
- // Update amplitudes
- for (var i = 0; i < num_bars; i++) {
- var base_height = random_range(min_height, max_height);
- var variance = (max_height - min_height) * variance_factor;
- var target = base_height + random_range(-variance, variance);
- target = clamp(target, min_height, max_height);
- amplitudes[i] = lerp(amplitudes[i], target, update_speed);
- }
- // Draw bars
- for (var i = 0; i < num_bars; i++) {
- var x1 = i * (bar_width + bar_gap);
- var y1 = height / 2 - amplitudes[i];
- var x2 = x1 + bar_width - 1;
- var y2 = height / 2 + amplitudes[i];
- draw_rectangle(x1, y1, x2, y2, false);
- }
- // Draw center line
- draw_set_color(c_gray);
- draw_line(0, height / 2, width, height / 2);
- // Reset drawing color
- draw_set_color(c_white);
- = = = = = = = = = = Mini pixel soundwave smooth
- width = 50;
- height = 50;
- bar_width = 1; // Width of each bar
- bar_gap = 1; // Gap between bars
- num_bars = floor(width / (bar_width + bar_gap));
- amplitudes = array_create(num_bars, 0);
- max_height = height / 4; // Maximum height of bars (from center)
- min_height = 2; // Minimum height of bars (from center)
- update_speed = 0.1;
- time = 0;
- frequency = 0.2;
- wave_speed = 0.1;
- /// Draw Event
- draw_clear(c_black);
- draw_set_color(c_white);
- time += wave_speed;
- // Update amplitudes
- for (var i = 0; i < num_bars; i++) {
- var wave = sin(time + i * frequency);
- var range = max_height - min_height;
- var target = min_height + (wave + 1) / 2 * range;
- amplitudes[i] = lerp(amplitudes[i], target, update_speed);
- }
- // Draw bars
- for (var i = 0; i < num_bars; i++) {
- var x1 = i * (bar_width + bar_gap);
- var y1 = height / 2 - amplitudes[i];
- var x2 = x1 + bar_width - 1;
- var y2 = height / 2 + amplitudes[i];
- draw_rectangle(x1, y1, x2, y2, false);
- }
- // Draw center line
- draw_set_color(c_gray);
- draw_line(0, height / 2, width, height / 2);
- // Reset drawing color
- draw_set_color(c_white);
- = = = = = = = = = = Mini pixel radar
- radius = 15;
- center_x = room_width / 2;
- center_y = room_height / 2;
- angle = 0;
- radar_speed = -2; // Clockwise movement
- // Create blips (random locations within radar range)
- blips = [];
- for (var i = 0; i < 3; i++) { // Create 3 random blips
- var blip_angle = irandom_range(0, 360); // Random angle for each blip
- var blip_distance = irandom_range(5, 15); // Random distance from the center
- blips[i] = {
- x: center_x + lengthdir_x(blip_distance, blip_angle),
- y: center_y + lengthdir_y(blip_distance, blip_angle),
- alpha: 0 // Start with alpha at 0 (invisible)
- };
- }
- // Clear the screen to black
- draw_clear(c_black);
- // Draw the circle outline (the radar's range)
- draw_set_color(c_white);
- draw_circle(center_x, center_y, radius, true); // Outline, not filled
- // Draw the rotating radar line
- angle += radar_speed; // Increment the angle to make the line rotate
- if (angle <= -360) angle = 0; // Reset the angle after a full rotation
- var line_x = center_x + lengthdir_x(radius, angle); // End X position of the radar line
- var line_y = center_y + lengthdir_y(radius, angle); // End Y position of the radar line
- draw_line(center_x, center_y, line_x, line_y); // Draw the radar sweeping line
- // Draw the blips (make them appear when the radar line passes over)
- for (var i = 0; i < array_length(blips); i++) {
- var blip = blips[i];
- var blip_angle = point_direction(center_x, center_y, blip.x, blip.y);
- var angle_diff = abs(angle_difference(angle, blip_angle));
- // Check if the radar line is close to the blip
- if (angle_diff < 5) {
- blip.alpha = 1; // Make the blip fully visible when the radar arm passes over it
- }
- // Gradually fade out the blip
- if (blip.alpha > 0) {
- blip.alpha -= 0.02; // Slowly fade out over time
- draw_set_alpha(blip.alpha);
- draw_circle(blip.x, blip.y, 1, false); // Draw the fading blip
- draw_set_alpha(1); // Reset alpha after drawing the blip
- }
- blips[i] = blip; // Update the blip in the array
- }
- draw_point(room_width/2,room_height/2);
- = = = = = = = = = = Static
- ///Draw event
- var scale=random(10);
- for (var i=0;i<128;i++){for(var j=0;j<128;j++){var n=(i* scale+j*scale*57)<<13^(i*scale+j*scale*57);var b=(1- ((n*(n*n*15731+789221)+ 1376312589)&0x7fffffff)/1073741824)*127.5+127.5; draw_point_color(i,j,make_color_rgb(b,b,b));}}
Advertisement
Add Comment
Please, Sign In to add comment