Camera Shake? / Collisions / Enemies...

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Camera Shake? / Collisions / Enemies...

Post by Ryne » Sat Nov 06, 2010 8:13 pm

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!

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

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

Re: Camera Shake?

Post by bartbes » Sat Nov 06, 2010 8:20 pm

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

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

Re: Camera Shake?

Post by nevon » Sat Nov 06, 2010 8:23 pm

That looks so very, very good.

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

Re: Camera Shake?

Post by Robin » Sat Nov 06, 2010 8:55 pm

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
Help us help you: attach a .love.

User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Camera Shake?

Post by zac352 » Sat Nov 06, 2010 9:00 pm

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.
Hello, I am not dead.

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

Re: Camera Shake?

Post by Robin » Sat Nov 06, 2010 9:03 pm

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.)
Help us help you: attach a .love.

User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Camera Shake?

Post by zac352 » Sat Nov 06, 2010 9:10 pm

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?
Hello, I am not dead.

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

Re: Camera Shake?

Post by Robin » Sat Nov 06, 2010 9:12 pm

Can has LÖVE. I somehow doubt that a screencast of camera shaking effects will be very interesting.
Help us help you: attach a .love.

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

Re: Camera Shake?

Post by Ryne » Sat Nov 06, 2010 10:32 pm

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

User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Camera Shake?

Post by zac352 » Sat Nov 06, 2010 10:59 pm

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. ;)
Looks fun. *waits for download*
Hello, I am not dead.

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests