Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// CREATE
- image_speed = 0
- image_index = floor(random(sprite_get_number(sprite_index)))
- // image_blend = make_colour_rgb(98, 123, 61)
- #region Wind effects
- SWAY_INTENSITY = random_range(0.04, 0.07)
- SWAY_DURATION = random_range(1.4, 1.7 ) * room_speed
- SWAY_DELTA = 180 / SWAY_DURATION
- SWAY = true
- SWAY_OFFSET = sprite_get_width(sprite_index) * SWAY_INTENSITY
- STEP = 0
- ULX = x - sprite_get_xoffset(sprite_index)
- ULY = y - sprite_get_yoffset(sprite_index)
- URX = x + sprite_get_width (sprite_index) - sprite_get_xoffset(sprite_index)
- URY = ULY
- LRX = URX
- LRY = y + sprite_get_height (sprite_index) - sprite_get_yoffset(sprite_index)
- LLX = ULX
- LLY = LRY
- TOPY = URY
- #endregion
- /// STEP
- /// @description Wind effects
- if SWAY {
- STEP ++
- var deg = STEP * SWAY_DELTA;
- ULY = TOPY - sin(degtorad(deg)) * SWAY_INTENSITY * sprite_get_height(sprite_index)
- URY = TOPY + sin(degtorad(deg)) * SWAY_INTENSITY * sprite_get_height(sprite_index)
- ULX = LLX + sin(degtorad(deg)) * SWAY_OFFSET
- URX = LRX + sin(degtorad(deg)) * SWAY_OFFSET
- if STEP > SWAY_DURATION {
- // SWAY = false
- ULY = lerp(ULY, TOPY, 0.15)
- URY = lerp(URY, ULY , 0.15)
- ULX = lerp(ULX, LLX , 0.15)
- URX = lerp(URX, LRX , 0.15)
- }
- }
- /// DRAW / script: draw_flora()
- draw_sprite_pos(sprite_index, image_index, ULX, ULY, URX, URY, LRX, LRY, LLX, LLY, image_alpha)
- /// script: wind_collision()
- /// @desc This is called any time you want the grass to move. I use a collision with a wind object that passes over the entire room,
- /// but you could just as easily put this script in a timer or alarm as well.
- /// @func wind_collision(intensity)
- /// @arg0 int intensity (between 0 and 10)
- if not SWAY {
- var SWAY_DEGREE = 0;
- STEP = 0
- SWAY = true
- SWAY_INTENSITY = random_range(0.01, 0.02)
- SWAY_OFFSET = sprite_get_width(sprite_index) * SWAY_INTENSITY
- SWAY_DURATION = random_range(1.4, 1.7) * room_speed
- SWAY_DEGREE = wave(argument0, -0.5, SWAY_DURATION, SWAY_OFFSET)
- SWAY_DELTA = 180 / SWAY_DURATION * SWAY_DEGREE
- }
Add Comment
Please, Sign In to add comment