Issue: Unusual Room_Load behavior.

Started by KodiakBehr, Sat 06/07/2013 14:53:40

Previous topic - Next topic

KodiakBehr

I could use some creativity in solving a bug that has stumped me for the past week.

I have a room that uses Parallax Scrolling.  When I enter that room from another room, the scrolling does not work.  When I start the game with the character in the room, the scrolling works (more or less) correctly.

Here's the catch.  There is nothing special about how the character changes rooms, and in both cases the character is being sent to the same location.  There are no FirstLoad commands, and nothing that I can think of that would explain why the two cases would be handed differently. 

Any bright ideas as to how this is possible?


Khris

Maybe there's code in on_event / eEventBeforeFadein?

KodiakBehr

Well the Parallax Scrolling script certainly uses eEventBeforeFadein actions.

I'm a little alarmed at how difficult this has been to figure out.  When a character in a room walks onto a region, the code that transfers him is:

Code: ags

function region5_WalksOnto()
{
player.ChangeRoom(37, 30, 1390, 2);
}


(I'm using AGS Draconian edition, hence the extra variable...)

When he arrives at his destination, the code that plays is:

Code: ags

function room_Load()
{

{
ambchannel = aAMB37mountain_wind.Play(); if (ambchannel != null){ambchannel.Volume = 100;}
musicchannel = aMountain_Ascent.Play(0, eRepeat); if (musicchannel != null){musicchannel.Volume = 100;}
  } 

SmoothScroll_ScrollingOn();

player.ChangeView(1);
player.SpeechView=3;
player.SetWalkSpeed(4, 4);
player.AnimationSpeed=3;  
mouse.Mode = eModeWalkto;

}


The relevant on_event parallax scrolling code is:

Code: ags


	if (event==eEventEnterRoomBeforeFadein){ //When the player enters a room
  
      ScreenWidth = System.ViewportWidth; //Store the width of the screen
      ScreenHeight = System.ViewportHeight; //Store the height of the screen  
  
      HalfScreenWidth = System.ViewportWidth/2; //Store half the width of the screen
      HalfScreenHeight = System.ViewportHeight/2; //Store half the height of the screen
      
      ScrollOffsetX=0.0;
      ScrollOffsetY=0.0;
      ScrollSpeedX=0.0;
      ScrollSpeedY=0.0;
            
      TargetPosX = targetCharacter.x;
      TargetPosY = targetCharacter.y;
      
      SmoothScroll_Centre();
      SetOrigins();

            
      if (SmoothScroll_PxStatus) SmoothScroll_PxOn();
      
      else SmoothScroll_PxOff();
      
      if (SmoothScroll_ScrollStatus) SmoothScroll_ScrollingOn();
      
      else {
        SmoothScroll_PxOff();
        ReleaseViewport();
      }

  }
  
  if (event==eEventLeaveRoom){//When the player exits a room
   int objectpass=0;
   
   while (objectpass<NumberObj){ //Reset the parallax objects to their original positions
     PxObj[objectpass].X=PxObjStartX[objectpass];
     PxObj[objectpass].Y=PxObjStartY[objectpass];
     objectpass++;
   }
   
  NumberObj=0; // Reset the total number of parallax objects to zero
  
  }
}


I don't see how parallax scrolling works correctly when I start the game with my character in Room 37 at location 30, 1390, and yet does not when my character walks onto region 5 in the previous room.

monkey0506

Quote from: KodiakBehr on Sat 06/07/2013 18:25:45
Code: ags

function room_Load()
{

{
ambchannel = aAMB37mountain_wind.Play(); if (ambchannel != null){ambchannel.Volume = 100;}
musicchannel = aMountain_Ascent.Play(0, eRepeat); if (musicchannel != null){musicchannel.Volume = 100;}
  } 

Oh come on. What the hell is this crap? I stopped reading right here.

The most help I can give you is to tell you to stop raping the indentation which is automatically handled by AGS for a reason. Quit forcibly making your code completely unreadable.

KodiakBehr

#4
I'm new to this discipline, I'm learning as I go, and it wasn't my intention to offend you.  Thank you for your guidance.

SMF spam blocked by CleanTalk