Differentiating footsteps.

Started by Ethan D, Sun 05/04/2009 21:51:19

Previous topic - Next topic

Ethan D

I know how to make footsteps have sounds using the sound on frame option, however I have no idea how I can change the sound depending on the room.  I think theres a way to change it and I would just have to put it in the on room load section of events but im not sure how to even change the sound file used for each frame.

Trent R

You're looking for the ViewFrame functions. You'll also have to know how to use pointers...


But luckily, Joe Carl recently posted this code in another thread. Hopefully it'll give you what you want. (put in region/load code)

~Trent

Quote from: Joe Carl on Wed 04/03/2009 13:44:30
I like this and I'd like to share this with you, I'm not thinking of doing any module by now... so you can copy, modify or discard it.
Code: ags


//-------------------HEADER--------------------------

import void SetWalkingSound(this Character*, int Sound, int Frame, int Frame2=-1);

import void RemoveAllWalkingSounds(this Character*);

//-------------------SCRIPT---------------------------

ViewFrame *frame;

void SetWalkingSound(this Character*, int Sound, int Frame, int Frame2){
  int i=0, max=0;
  
  if(Game.GetLoopCountForView(this.NormalView)<8)
    max = Game.GetLoopCountForView(this.NormalView);
  else
    max = 8;
    
  while(i<max){ 
  
    frame = Game.GetViewFrame(this.NormalView, i, Frame);
    frame.Sound=Sound;

    if(Frame2!=-1){  
      
      frame = Game.GetViewFrame(this.NormalView, i, Frame2);
      frame.Sound=Sound;  
  
    }
      
    i++;
  }
  
}

void RemoveAllWalkingSounds(this Character*){
  int i=0, j=0, max;
  
  if(Game.GetLoopCountForView(this.NormalView)<8)
    max = Game.GetLoopCountForView(this.NormalView);
  else
    max = 8;
    
  while(i<max){ 
    while(j<Game.GetFrameCountForLoop(this.NormalView, i)){
      
      frame = Game.GetViewFrame(this.NormalView, i, j);
      frame.Sound=0;
   
      j++;
    }
    j=0;
    i++;
  }
  
}


To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk