Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Sound fading along the Y axis + direct control for 2d characters?  (Read 4138 times)

0 Members and 1 Guest are viewing this topic.

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile

Okay, alright...

Is there an easy way to have the sound fade in and out as you get farther away from things, also in the vertical direction. I know it works left and right...
but not up and down, it seems.

Edit: i tried with
this.SetSoundVolume(100-(0.15*(position_Y-this.Y)));
where position_Y is the actor's Y position. But it didn't work. What am I doing wrong?

Edit again:
Code: [Select]
var ent = this.entity;
ent.SetSoundVolume(0);
this.SetSoundVolume(0);
...doesn't appear to work either. What am I missing?


And now for the second question...

What's the best way to implement direct control for 2d charcters. I mean:
up - he walks up.
left - he walks left.
Right - hw walks right.
Down - he walks down.

Like regular action movement.

Or is direct control out of control for the 2d characters altogether?

What's the best way to do a "simple action movement" for the actor?
« Last Edit: October 26, 2005, 09:54:55 AM by organican »
Logged

Columbo

  • Supporter
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 33
  • Just one more thing...
    • View Profile
Re: Sound fading along the Y axis + direct control for 2d characters?
« Reply #1 on: October 26, 2005, 10:06:52 AM »

i tried with
this.SetSoundVolume(100-(0.15*(position_Y-this.Y)));
where position_Y is the actor's Y position. But it didn't work. What am I doing wrong?

Ok, this looks to me like a mathematical error to me, but please feel free to correct me if I'm mistaken.

If you want a formula for sound to be quietest at the top of the screen and loudest at the bottom, try something like :

this.SetSoundVolume ((position_Y / this.Y) * 100)

Or, if you want the opposite effect (sound softest at the bottom of the screen, loudest at the top) :

this.setSoundVolume (100-((position_ Y / this.Y) * 100))

I hope that helps, good luck!
Logged

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: Sound fading along the Y axis + direct control for 2d characters?
« Reply #2 on: October 26, 2005, 03:18:08 PM »

Much better now. Thanks.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sound fading along the Y axis + direct control for 2d characters?
« Reply #3 on: October 26, 2005, 04:57:51 PM »

As for the direct control for 2D characters, Igorrr's Spank the Hero minigame uses it.

There's also some further discussion in this thread: http://forum.dead-code.org/index.php?topic=615.0

I hope that helps.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: Sound fading along the Y axis + direct control for 2d characters?
« Reply #4 on: October 27, 2005, 01:00:02 AM »

Thanx Mnemonic.

While offline, I tried with

Code: [Select]
global position_X;
global position_Y;

while(true)
{

if(Game.Interactive)
{
if(Keyboard.IsKeyDown(VK_LEFT))
{      position_X=this.X-130;
position_Y=this.Y;
                      actor.GoTo(position_X, position_Y);

}
if(Keyboard.IsKeyDown(VK_RIGHT))
{   position_Y=this.Y;
                    position_X=this.X+130;
                      actor.GoTo(position_X, position_Y);

}
if(Keyboard.IsKeyDown(VK_UP))
{
position_X=this.X;
position_Y=this.Y-130;
                      actor.GoTo(position_X, position_Y);
}
if(Keyboard.IsKeyDown(VK_DOWN))
{
position_X=this.X;
position_Y=this.Y+130;
                      actor.GoTo(position_X, position_Y);

}
}
Sleep(20);
}

I worked so so... in a bad sorta way.

Igorrr's script is way better. ;D

Just one thing. It's wierd that the "direct control" script doesn't work by itself in my game (it did in Ogorrr's).
I had to instert it into the actor's script file. And I couldn't find what files are referencing it, either.

Oh well...
At least it works all right. So who am I to complain? :)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sound fading along the Y axis + direct control for 2d characters?
« Reply #5 on: October 27, 2005, 11:40:13 AM »

I believe the script is supposed to be attached to game, either in ProjectMan or by calling Game.AttachScript().
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.035 seconds with 20 queries.