#### Archived

This topic is now archived and is closed to further replies.

# Shaking Screen Question

This topic is 5405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I want to make a shaking effect on the screen.I used an array of (x,y) to record the shaking offsets.Such as (-4,0),(0,0),(4,0),(0,0),(0,-4),(0,0),(0,4).And when shaking screen,I take out the offset from this array one by one ,and apply them to the screen coordinate.What troubles me is it''s so difficult to define these shaking points to make a realistic shaking effect.Any one has good suggestion?

##### Share on other sites
Here's one way, define variables to hold the look at point for your scene camera. Now, make a function that generates random numbers between -ve and +ve of whatever maximum amount you want your screen to shake by.

Multiple this by a variable like blastFactor, which is determined by the element that causes the screen to shake - like an explosion - and varies with the intensity of the explosion between 0.0f and 1.0f. Multiply this value with the random number and add it to your camera's look at point and Voila! you have a varying explosion that doesn't look the same every time.

Something like this :-

Vector3 m_vLookAtPt = Camera->GetLookAtPt();

float fShakeAmtX = Rand( 5 );
float fShakeAmtY = Rand( 7 );

Determine you blast intensity and hold it in blastFactor.

m_vLookAtPt.x += fShakeAmt * blastFactor;
m_vLookAtPt.y += fShakeAmt * blastFactor;

Camera->SetLookAtPt( m_vLookAtPt );

Now, make a function with this and put a loop to decrease the Rand value by, say 1, every time...

and subtract the shake amount term from the LookAtPt vector.

for( int i = 5; i >= 0; --i )
float fShakeAmtX = Rand(i);

Now, the screen shake will gradually decrease to zero.

Hope that was kinda clear...

[edited by - poly-gone on September 4, 2003 8:28:32 AM]

[edited by - poly-gone on September 4, 2003 8:30:43 AM]

##### Share on other sites
mmm..,That seems a good idea.I''ll try it. Thanks.

##### Share on other sites
<< I want to make a shaking effect on the screen. >>

Here is another way to do it....

Shake Me I like it

Phil P

##### Share on other sites
you, sir, are a scumbag.

if i were a moderator you''d be banned.

if i were god, you''d be dead.

##### Share on other sites
quote:
Original post by PhilVaz
<< I want to make a shaking effect on the screen. >>

Here is another way to do it....

Shake Me I like it
Phil P

That was really unnecessary.

For anyone who is thinking of clicking that link... its a shaking window it doesn't open a new window and you cant hit the back button.

[edited by - Biomass Negative on September 5, 2003 1:47:08 AM]

##### Share on other sites
<< you, sir, are a scumbag. >>

Then absolutely, under no circumstances, do not click on this link either

BROWSER HELL

Or you could see it as a game and try to escape browser hell....just something I learned from the GameDev folks, but I made it worse.

Phil P

[edited by - PhilVaz on September 5, 2003 9:53:48 PM]

##### Share on other sites
Ok let me guess ...
It keeps popping up pages one after the other?

*yawn*

##### Share on other sites
<< It keeps popping up pages one after the other? >>

And opens your CD/DVD doors, and growls "I am no one...I am no one" from the Exorcist movie....if it works right.

##### Share on other sites
Hmm.. Howlong till he gets IP/Mail/Account banned forever?

.lick

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631434
• Total Posts
3000050
×