How to scroll in room on command?

Started by wackojacko, Sat 04/09/2004 12:27:59

Previous topic - Next topic

wackojacko

I'd like to make a room like in MI 1 in the voodoo house. You walk in the house and the screen scrolls to the voodoo lady when you walk to the edge of the room. I'm now using this command:

if (character[EGO].x == 310){
ReleaseViewport();
MoveCharacterBlocking(EGO, 429,111, 0);
while (character[EGO].walking!=0) Wait(1);
RunDialog(0);
}

So, when the EGO reaches the edge of the screen the screen just flips to the next area! I want to have it smooth. You walk to the edge of the screen, the game pauses and the screen scrolls to the "voodoo lady". Is this possible to do?
http://tim.vd.hoeven.free.fr
Check my new comic! Dutch people only...

Scorpiorus

#1
Yeah, you can try fiddling with the SetViewport()/GetViewport*() commands to achieve what you are after.

But to simplify scripting I would create a dummy character (don't forget to tick Can be walked through just in case) and a totally transparent normal view (so we can't see that character).

Next write a function in the global script:

// main global script file

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

   int dummy = DUMMY_CHARACTER'S_SCRIPTNAME_HERE;

   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(1);
   
   SetPlayerCharacter(pc);
   SetViewport(GetViewportX(), GetViewportY());
   SetGameOption (OPT_ANTIGLIDE, antiglide);
}


// script header

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




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

Moves viewport to x, y at a speed. Pass antiglide equal to 0 to smooth scrolling.
The function doesn't release the viewport so it's on your own.
This is a blocking function...

Example:


room's repeatedly execute:

if (character[EGO].x >= 310) {

   MoveCharacter(EGO, 429, 111);
   MoveViewportBlocking(450, GetViewportY());
}

wackojacko

tank you very muchh it works great!  ;D
http://tim.vd.hoeven.free.fr
Check my new comic! Dutch people only...

SMF spam blocked by CleanTalk