Perfect Screen Shake made easy!
Author: | Rycon
|
Submitted: | 4th August, 2003
|
Views: | 4832
| Rated: |
|
|
Want to know how to make a screen shake like in Yeah Guys! 3? I will now show you how easy and flexible it is.
First create a small box, that will be invisable all the time, for this article I will name it "Screen Shake"
Always set screen position to 0.0 of Screen Shake.
Now you will need to set your levels playfield a bit larger, I made myn 864x600. So that the screen can go 32 pixels one way, and 32 the other way.
Now set Screen Shake in the middle of the level, so as not to be able to see the extra 32 pixel sides of the level when not shaking. (Might have to place barriers there so they cannot go off screen)
Now first, let me define all 3 values of Screen Shake.
A of Screen Shake = Right (If you set this to 32, it will go 32 pixels to the right)
B of Shake = Left (Same as A)
C of Shake = -> Going = 0, -> Back = 1, <- Going = 2, <- Back = 3
C is a bit hard to understand, but 0 means that the screen shake is on the right side going RIGHT, 1 means that screen shake is on the right but going LEFT.
So now, we put in the 5 events that makes it go.
1
Condition:
Alterable Value C "Screen Shake" = 0
Alterable Value A "Screen Shake" > 0
Every 04 miliseconds
Action:
Set X position of X "Screen Shake" + Alterable Value A of "Screen Shake"
Set Alterable Value C of "Screen Shake" to 1
2
Condition:
Alterable Value C "Screen Shake" = 1
Alterable Value A "Screen Shake" > 0
Every 04 miliseconds
Action:
Set X position of X "Screen Shake" - Alterable Value A of "Screen Shake"
Set Alterable Value C of "Screen Shake" to 2
Subtact 1 from Alterable Value A of "Screen Shake"
3
Condition:
Alterable Value C "Screen Shake" = 2
Alterable Value B "Screen Shake" > 0
Every 04 miliseconds
Action:
Set X position of X "Screen Shake" - Alterable Value B of "Screen Shake"
Set Alterable Value C of "Screen Shake" to 3
4
Condition:
Alterable Value C "Screen Shake" = 3
Alterable Value B "Screen Shake" > 0
Every 04 miliseconds
Action:
Set X position of X "Screen Shake" + Alterable Value B of "Screen Shake"
Set Alterable Value C of "Screen Shake" to 0
Subtact 1 from Alterable Value B of "Screen Shake"
Now all you need to do, is set values A and B when you want the screen to shake. So when an explosion happens, simply set value A and B to 10. You want to keep A and B the same value, or your explosion will be pretty wonky..
What all this does, the direction starts at 0 (right side going right) and adds the X cord of value A. So if its 32, it will go 32 pixels right, and THEN it sets the direction to 1 (Right side going LEFT) it then SUBTRACTS value A, so it goes back to where it came from. And it also subtracts 1 from value A, so that it will stop and not keep shaking. It then does the same thing for the left side, looping around to direction 0 again, untill both value A and B reach 0.
The final event, is just to keep the engine from screwing up from setting the values A and B at the same time. First track your X and Y cords of Screen Shake, when the screen is NOT shaking. If you are doing it on a 864x600 screen, the cords are 432x82.
5
Condition:
Alterable Value A of "Screen Shake" = 0
Alterable Value B of "Screen Shake" = 0
Action:
Set position of "Screen Shake" to (Cords here)
You now have a rather small, flexable, advanced shake engine. I hope this is helpfull to everyone, as this is my first article.
|
|
Rycon
Registered 20/09/2002
Points 996
|