Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Function cameraShake  (Read 2419 times)

0 Members and 1 Guest are viewing this topic.

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Function cameraShake
« on: April 24, 2012, 10:43:49 PM »

Hi

I think that I missed something. I wrote cameraShake function but it's not what I expected. There is code for it and it should go to base.inc

Code: [Select]
function cameraShake(strX, strY, speed, length, resX, resY)
{
 var shakeX, shakeY, shakeDirection;
 for(var i=0; i<length; i=i+1)
  {
Scene.SkipTo(resX/2, resY/2);
shakeDirection = Random(0,3);

if (shakeDirection == 0)
{
          //left up corner
  shakeX = Random(0,strX);
  shakeY = Random(0,strY);
}

    if (shakeDirection == 1)
{
          //right up corner
  shakeX = Random(0,strX) + resX;
  shakeY = Random(0,strY);
}
 
if (shakeDirection == 2)
{
  //left down corner
  shakeX = Random(0,strX);
  shakeY = Random(0,strY) + resY;
}
 
if (shakeDirection == 3)
{
  //right down corner
  shakeX = Random(0,strX) + resX;
  shakeY = Random(0,strY) + resY;
}
 
Scene.SkipTo(shakeX, shakeY);
Sleep(speed);
Scene.SkipTo(resX/2, resY/2);
Sleep(speed);
  }
}

strX, strY is a strenght of shake
speed its speed between shakes in milisec
resX, resY is resolution of your game
lenght is just a lenght of shake

Thanks to putting this function to base.inc you have access to this from every script just calling cameraShake(100,100,100,10,1280,720); - this parameters works for me.

If somebody has any idea how to improve this function please help :) Maybe together we will do it properly.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Function cameraShake
« Reply #1 on: April 24, 2012, 11:52:43 PM »

mmm didnt work for me  :(
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: Function cameraShake
« Reply #2 on: April 25, 2012, 12:00:24 AM »

Yep, it's not perfect. Probably it didn't work because bad strX and strY. Scene.SkipTo doesn't work if shakeX and shakeY values are within visible area on screen. I believe this method wasn't invented for camera shake :) so all function is just like a workaround. Therefore I have posted on forum. Maybe somebody will have better idea :)
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula
 

Page created in 0.036 seconds with 21 queries.