## Camera Shake? / Collisions / Enemies...

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

### Camera Shake? / Collisions / Enemies...

Hi guys. Here is a screenshot of what Ive been working on for the last few days. I'm wondering if I could create a "Camera Shake" effect for explosions such as grenades or mines. I was thinking that I would actually have to create a "camera" somehow that I could actually "shake" unless there is an easier way to achieve the desired effect?

Thanks guys!

Last edited by Ryne on Mon Nov 08, 2010 3:17 am, edited 2 times in total.
@rynesaur

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Camera Shake?

You probably want to play with love.graphics.translate and love.graphics.rotate.

nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

### Re: Camera Shake?

That looks so very, very good.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Camera Shake?

Looks great!

And such an effect is easily done with translate, as bartbes said. I use it in Space as a sign you're too close to a black hole. I think I used something like:

Code: Select all

love.graphics.translate(math.random(horiz_amplitude*2)-horiz_amplitude, math.random(vert_amplitude*2)-vert_amplitude)
If you don't want the UI to shake as well, use something like:

Code: Select all

love.graphics.push()
love.graphics.translate(math.random(horiz_amplitude*2)-horiz_amplitude, math.random(vert_amplitude*2)-vert_amplitude)
-- draw game stuff here
love.graphics.pop()
-- draw UI things here

zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Contact:

### Re: Camera Shake?

Robin wrote:Looks great!

And such an effect is easily done with translate, as bartbes said. I use it in Space as a sign you're too close to a black hole. I think I used something like:

Code: Select all

love.graphics.translate(math.random(horiz_amplitude*2)-horiz_amplitude, math.random(vert_amplitude*2)-vert_amplitude)
If you don't want the UI to shake as well, use something like:

Code: Select all

love.graphics.push()
love.graphics.translate(math.random(horiz_amplitude*2)-horiz_amplitude, math.random(vert_amplitude*2)-vert_amplitude)
-- draw game stuff here
love.graphics.pop()
-- draw UI things here
Doing something like that would look really bad if you were doing several pixels. Every single frame. It'd look like a big blur.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Camera Shake?

zac352 wrote:Doing something like that would look really bad if you were doing several pixels. Every single frame. It'd look like a big blur.
Actually, not really. It works pretty well in Space, check it out. (Or fork me, whatever.)

zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Contact:

### Re: Camera Shake?

Robin wrote:
zac352 wrote:Doing something like that would look really bad if you were doing several pixels. Every single frame. It'd look like a big blur.
Actually, not really. It works pretty well in Space, check it out. (Or fork me, whatever.)
Can has video?

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Camera Shake?

Can has LÖVE. I somehow doubt that a screencast of camera shaking effects will be very interesting.

Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

### Re: Camera Shake?

Thanks for the comments guys! I'll try this code when I get home and try to get a demo up sometime this week.

Also, for those who were curious of the random white circle, it's the cursor for the game.
@rynesaur

zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Contact:

### Re: Camera Shake?

Ryne wrote:Thanks for the comments guys! I'll try this code when I get home and try to get a demo up sometime this week.

Also, for those who were curious of the random white circle, it's the cursor for the game.

### Who is online

Users browsing this forum: No registered users and 33 guests