Discuss Scratch

spidermanLOLL
Scratcher
500+ posts

Screen Shake

SORRY IF THIS IS WRONG FORUM

Like how to do screen shake. My friend told me in a forum post but I can't find it.
The_Game_
Scratcher
1000+ posts

Screen Shake

This belongs in Help With Scripts.
-Valtren-
Scratcher
1000+ posts

Screen Shake

The_Game_ wrote:

This belongs in Help With Scripts.
Not really, it's not asking help about a specific script.
-
What do you mean by screen shake? If you're talking about something that shakes all the sprites on the screen, just make this custom block:
definePositionforscreenshakeifshake?=1thengotox:X+CamX*CamZy:Y+CamY*CamZsetsizetoZ*CamZ%whenclickedsetshake?to0foreverPositionforscreenshake
When the variable Shake? is 1, the position block will position the sprite accordingly.
So setup before the shake:
setXtoXpositionsetYtoYpositionsetZtosizesetCam Xto0 this and the two blocks below it are important- the shake won't run properly without it.setCam Yto0setCam Zto1setshake?to1
In order to actually shake the screen, there are multiple scripts, but I don't know any except this:
setfooto10repeat10setCam Xtopickrandomfoo*-1tofoosetCam Ytopickrandomfoo*-1tofoochangefooby-1
So you'd do this script in order to shake the screen:
setXtoXpositionsetYtoYpositionsetZtosizesetCam Xto0 this and the two blocks below it are important- the shake won't run properly without it.setCam Yto0setCam Zto1setshake?to1setfooto10repeat10setCam Xtopickrandomfoo*-1tofoosetCam Ytopickrandomfoo*-1tofoochangefooby-1
Note that every sprite must have the position for screenshake block in a forever loop for the entire screen to shake.

Last edited by -Valtren- (May 18, 2023 13:37:44)

Za-Chary
Scratcher
1000+ posts

Screen Shake

-Valtren- wrote:

The_Game_ wrote:

This belongs in Help With Scripts.
Not really, it's not asking help about a specific script.
-
What do you mean by screen shake? If you're talking about something that shakes all the sprites on the screen, just make this custom block:
definePositionforscreenshakeifshake?=1thengotox:X+CamX*CamZy:Y+CamY*CamZ
I like the explanation! But what is “Cam Z,” and how is it used?

Last edited by Za-Chary (May 18, 2023 12:47:56)

gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

Za-Chary wrote:

-Valtren- wrote:

The_Game_ wrote:

This belongs in Help With Scripts.
Not really, it's not asking help about a specific script.
-
What do you mean by screen shake? If you're talking about something that shakes all the sprites on the screen, just make this custom block:
definePositionforscreenshakeifshake?=1thengotox:X+CamX*CamZy:Y+CamY*CamZ
I like the explanation! But what is “Cam Z,” and how is it used?

In 2D Z position is used as rotation
-Valtren-
Scratcher
1000+ posts

Screen Shake

Za-Chary wrote:

I like the explanation! But what is “Cam Z,” and how is it used?
Cam Z is the variable used for zooming in and out. If you want your screen shake to zoom in or out, use that block.

gdfsgdfsgdfg wrote:

In 2D Z position is used as rotation

Please don't quote this image just to put your reaction to it, it's unconstructive and off topic.
gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

-Valtren- wrote:

Za-Chary wrote:

I like the explanation! But what is “Cam Z,” and how is it used?
Cam Z is the variable used for zooming in and out. If you want your screen shake to zoom in or out, use that block.

gdfsgdfsgdfg wrote:

In 2D Z position is used as rotation
Please don't quote this image just to put your reaction to it, it's unconstructive and off topic.


Then why in spaceflight sim it was rotated when I set the z

Last edited by gdfsgdfsgdfg (May 18, 2023 13:17:12)

-Valtren-
Scratcher
1000+ posts

Screen Shake

gdfsgdfsgdfg wrote:

-Valtren- wrote:

Za-Chary wrote:

I like the explanation! But what is “Cam Z,” and how is it used?
Cam Z is the variable used for zooming in and out. If you want your screen shake to zoom in or out, use that block.

gdfsgdfsgdfg wrote:

In 2D Z position is used as rotation
Please don't quote this image just to put your reaction to it, it's unconstructive and off topic.


Then why in spaceflight sim it was rotated when I set the z
No idea. The variable that controls the camera's direction was called Z.
spidermanLOLL
Scratcher
500+ posts

Screen Shake

-Valtren- wrote:

The_Game_ wrote:

This belongs in Help With Scripts.
Not really, it's not asking help about a specific script.
-
What do you mean by screen shake? If you're talking about something that shakes all the sprites on the screen, just make this custom block:
definePositionforscreenshakeifshake?=1thengotox:X+CamX*CamZy:Y+CamY*CamZwhenclickedsetshake?to0foreverPositionforscreenshake
When the variable Shake? is 1, the position block will position the sprite accordingly.
So setup before the shake:
setXtoXpositionsetYtoYpositionsetshake?to1
In order to actually shake the screen, there are multiple scripts, but I don't know any except this:
setfooto10repeat10changeCam Xbypickrandomfoo*-1tofoochangeCam Ybypickrandomfoo*-1tofoochangefooby-1
So you'd do this script in order to shake the screen:
setXtoXpositionsetYtoYpositionsetshake?to1setfooto10repeat10changeCam Xbypickrandomfoo*-1tofoochangeCam Ybypickrandomfoo*-1tofoochangefooby-1setshake?to0
Note that every sprite must have the position for screenshake block in a forever loop for the entire screen to shake.
It didn't work. I tested it here: https://scratch.mit.edu/projects/853141503
gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

spidermanLOLL wrote:

-Quote so big that I had to cut it-


Then try this:
https://scratch.mit.edu/projects/784157060
simple and it works

I use this alot
(all of the sprites need to have this block though)
(the stage has to be a sprite if you want to shake it)

Last edited by gdfsgdfsgdfg (May 18, 2023 13:28:40)

Spentine
Scratcher
1000+ posts

Screen Shake

-Valtren- wrote:

gdfsgdfsgdfg wrote:

-Valtren- wrote:

Za-Chary wrote:

I like the explanation! But what is “Cam Z,” and how is it used?
Cam Z is the variable used for zooming in and out. If you want your screen shake to zoom in or out, use that block.

gdfsgdfsgdfg wrote:

In 2D Z position is used as rotation
Please don't quote this image just to put your reaction to it, it's unconstructive and off topic.


Then why in spaceflight sim it was rotated when I set the z
No idea. The variable that controls the camera's direction was called Z.
The “Cam Z” variable appears to control the zooming. You just didn't put a (set size to (cam z)%) block.
-Valtren-
Scratcher
1000+ posts

Screen Shake

spidermanLOLL wrote:

It didn't work. I tested it here: https://scratch.mit.edu/projects/853141503
That was an error on my part, I forgot to mention that you had to reset the Cam X and Cam Y values.



gdfsgdfsgdfg wrote:

Then try this:
https://scratch.mit.edu/projects/784157060
simple and it works

I use this alot
(all of the sprites need to have this block though)
(the stage has to be a sprite if you want to shake it)
That method, while it does work, is inefficient. With my method, the sprites only need to have the position block. Only one sprite has to have the actual shake code, and when it runs all the sprites with position blocks will shake in a fashion that looks like the entire screen is shaking.
gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

-Valtren- wrote:

gdfsgdfsgdfg wrote:

I use this alot
(all of the sprites need to have this block though)
(the stage has to be a sprite if you want to shake it)
That method, while it does work, is inefficient. With my method, the sprites only need to have the position block. Only one sprite has to have the actual shake code, and when it runs all the sprites with position blocks will shake in a fashion that looks like the entire screen is shaking.

Its a simple shake code

Last edited by gdfsgdfsgdfg (May 18, 2023 13:36:28)

-Valtren-
Scratcher
1000+ posts

Screen Shake

gdfsgdfsgdfg wrote:

-Valtren- wrote:

gdfsgdfsgdfg wrote:

I use this alot
(all of the sprites need to have this block though)
(the stage has to be a sprite if you want to shake it)
That method, while it does work, is inefficient. With my method, the sprites only need to have the position block. Only one sprite has to have the actual shake code, and when it runs all the sprites with position blocks will shake in a fashion that looks like the entire screen is shaking.

Its a simple shake code
Shakes the sprite, not the screen.
gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

-Valtren- wrote:

gdfsgdfsgdfg wrote:

-Valtren- wrote:

gdfsgdfsgdfg wrote:

I use this alot
(all of the sprites need to have this block though)
(the stage has to be a sprite if you want to shake it)
That method, while it does work, is inefficient. With my method, the sprites only need to have the position block. Only one sprite has to have the actual shake code, and when it runs all the sprites with position blocks will shake in a fashion that looks like the entire screen is shaking.

Its a simple shake code
Shakes the sprite, not the screen.

The stage has to be a sprite as I mentioned earlier
gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

My method is rng based
and the proof that it can shake the background (its a sprite)
https://scratch.mit.edu/projects/853184644/

and broadcasts are used for indefinite shaking
-Valtren-
Scratcher
1000+ posts

Screen Shake

gdfsgdfsgdfg wrote:

My method is rng based
and the proof that it can shake the background (its a sprite)
https://scratch.mit.edu/projects/853184644/

and broadcasts are used for indefinite shaking


While you are correct that you can make the background shake, you have made a major mistake: You've made an earthquake, not a screen shake.
Confused? Allow me to explain.

The words “screen shake” imply that rather than everything on the screen moving, the screen itself is moving. Thus, when the screen moves in a certain direction, everything on it will move the same way:



However, your shake method has every sprite shaking independently of each other. This means that the sprites will do this:



Thus, that would not be the screen shaking. You rmethod would be California.

My screen shake method works because it accounts for similar sprite movement: you only need to input the shake code in one sprite, and all sprites with the position block will shake the same way. It'll look like the screen is shaking.

That's because, my method utilises something called Cam control, otherwise known as:


That was not as dramatic as I thought it would be

Anyway, thanks to coming to my TED talk of why you should use my method instead of the other person's. Please collect your free barrels of bhindi ki subgi at the door.
gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

-Valtren- wrote:

-Quote so big that I have to cut it-


As I said, its rng based
-Valtren-
Scratcher
1000+ posts

Screen Shake

gdfsgdfsgdfg wrote:

-Valtren- wrote:

-Quote so big that I have to cut it-


As I said, its rng based
As I said, it's not a screen shake.
gdfsgdfsgdfg
Scratcher
1000+ posts

Screen Shake

-Valtren- wrote:

gdfsgdfsgdfg wrote:

-Valtren- wrote:

-Quote so big that I have to cut it-


As I said, its rng based
As I said, it's not a screen shake.

if you read the project description
You would understand before posting

Powered by DjangoBB