Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Mon 30/04/2007 10:26:11

Title: Scroll function too fast
Post by: on Mon 30/04/2007 10:26:11
Searching the forum I found this very interesting function. (Here's a link (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=16497.0) to the post).

Basically it scrolls the screen using an invisible character (DUMMY here)


function MoveViewportBlocking(int x, int y, int speed, int antiglide) {

   int dummy = DUMMY;

   int pc = GetPlayerCharacter();

   character[dummy].room = character[pc].room;
   character[dummy].x = GetViewportX() + system.viewport_width/2;
   character[dummy].y = GetViewportY() + system.viewport_height/2;
   
   SetPlayerCharacter(dummy);
   SetCharacterSpeed(dummy, speed);
   
   antiglide = SetGameOption(OPT_ANTIGLIDE, !!antiglide);

   MoveCharacterDirect(dummy, x+system.viewport_width/2, y+system.viewport_height/2);
   while (character[dummy].walking) Wait(40);
   
   SetPlayerCharacter(pc);
   SetViewport(GetViewportX(), GetViewportY());
   SetGameOption (OPT_ANTIGLIDE, antiglide);
}


I set the parameter "speed" to the minimum but I feel it is still too fast and I don't know if there's a way to slow down the scroll.

Any help?
Title: Re: Scroll function too fast
Post by: Lt. Smash on Mon 30/04/2007 11:10:39
Have you tried using numbers under 0 like -4 for speed.

I think it should be slower then.
Title: Re: Scroll function too fast
Post by: on Mon 30/04/2007 12:14:36
 := It rocks
Title: Re: Scroll function too fast
Post by: Khris on Mon 30/04/2007 13:22:07
I've updated the code to current script:

function MoveViewportBlocking(int x, int y, int speed, int antiglide) {
  cDummy.ChangeRoom(player.Room, GetViewportX()+System.ViewportWidth/2, GetViewportY()+System.ViewportHeight/2);

  Character*pc=player;
   
  cDummy.SetAsPlayer();
  cDummy.SetWalkSpeed(speed, speed);
   
  antiglide = SetGameOption(OPT_ANTIGLIDE, !!antiglide);

  cDummy.Walk(x+system.viewport_width/2, y+system.viewport_height/2, eAnywhere, eBlock);
   
  pc.SetAsPlayer();
  SetViewport(GetViewportX(), GetViewportY());
  SetGameOption (OPT_ANTIGLIDE, antiglide);
}