shaking the screen

Talk about making games.

shaking the screen

Postby raminjoon » Fri Jul 15, 2011 9:41 pm

hi I was wondering to know if you know how I can shake the scene after a event. I mean I want make some kind of earthquake for example in my game do you have any idea?
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: shaking the screen

Postby skydereign » Fri Jul 15, 2011 9:47 pm

What this is one way to do it. You should have some way of telling where the view should be, and something tell the view to shake. So, for this I I'm going to use the variables xview, yview, and quake.
view -> Draw Actor -> Script Editor
Code: Select all
x=xview;
y=yview;

if(quake==1)
{
    x=xview-10+rand(20);
    y=yview-10+rand(20);
}


This way you set quake to 1, and it will start shaking by a max of 10 pixels in either direction.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: shaking the screen

Postby raminjoon » Fri Jul 15, 2011 9:55 pm

thanks friend but can I do that by have this code activated for example after a certain event has occured?
raminjoon
 
Posts: 40
Joined: Tue Jul 05, 2011 5:34 am
Location: Denver, Co.
Score: 3 Give a positive score

Re: shaking the screen

Postby skydereign » Fri Jul 15, 2011 9:59 pm

Well to activate that code you can use any event, and just set quake to 1. If you want it to stop set it to 0. The thing is unless the shaking only happens while you are pressing a key, you'll have to use a draw actor event.

So, this will activate it.
player -> Key Down x -> Script Editor
Code: Select all
quake=1;

And if you want it to stop after a while you can use a timer event that sets it back to 0.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest