I was a bit bored so I made my 1st tutorial 4ever!
HOW TO MAKE A SIMPLE MOTION BLUR EFFECT IN GAME MAKERBad example:
I used an old abandoned project of mine to test this thing
PART 1: How it is doneSTEP 1: Add these to your project: object oBlur and script draw_blur (You can rename them ofc)
Necessary information about object oBlur
Sprite: <no sprite> (Of course as it is controller object)
Or if you want i recongizable in level editor then why not. Just turn visibility off. Oh wait, drawing event makes it invisible.Depth: 1000 (To make the blur stay under most objects)
Persistent: false (Or true if you don't want to initialize it in every room. It's your choice)
Create Event:
screenWidth = view_wview[view_current]
screenHeight = view_hview[view_current]
global.mblur = surface_create(screenWidth,screenHeight)
temp = surface_create(screenWidth,screenHeight)
surface_set_target(global.mblur)
draw_clear_alpha(c_white,0) //Actually any color would do
surface_set_target(temp)
draw_clear_alpha(c_white,0)
surface_reset_target()
camLastX = view_xview[view_current]
camLastY = view_yview[view_current]
Step Event:
difX = camLastX-view_xview[0]
difY = camLastY-view_yview[0]
//Copyroutine
surface_set_target(temp) //This part moves the trail in camera
draw_surface_ext(global.mblur,difX,difY,1,1,0,c_white,0.94)
surface_reset_target()
surface_copy(global.mblur,0,0,temp)
surface_set_target(temp)//We clear the temp-surface
draw_clear_alpha(c_white,0)
surface_reset_target()
//End of copyroutine
camLastY = view_yview[0]
camLastX = view_xview[0]
Draw Event:
draw_surface_ext(global.mblur,view_xview[0],view_yview[0],1,1,0,c_white,0.8)
Script draw_blur:
surface_set_target(global.mblur)
draw_sprite_ext(sprite_index,image_index,x-view_xview[0],y-view_yview[0],image_xscale,image_yscale,image_angle,image_blend,image_alpha)
surface_reset_target()
STEP 2:Remember to modify surface sizes appropriate to your game
Call draw_blur in endstep event for every object you want to have motion blur
Tweak anything you have to. Re-factor if needed.
That's it
Coming Part 2: Explanation and variations?
Changelog:
1.9.2011
- Created 1st part
2.9.2011
- Corrected some stuff and made it screensize independent.
- Added draw_clear_alpha's to code. Thanks Desert dog