Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: subspark on Tue 25/09/2007 06:25:49

Title: Room Wrap Module
Post by: subspark on Tue 25/09/2007 06:25:49
Is anybody able to design a module for wrapping scrolling rooms like this? Think the Nexus in the LucasArts classic 'The Dig'.
In case anyone hasn't ever seen the room or played the game:
http://www.shuugouteki.net/paul/Images/nexus.gif (http://www.shuugouteki.net/paul/Images/nexus.gif)

In the Dig resource files the room background graphic had a reasonably short repeat buffer however I chopped that off as I don't believe it would be necessary in AGS. It may have been a workaround in the old SCUMM system back when the game was being made.

Cheers,
Paul.
Title: Re: Room Wrap Module
Post by: Gilbert on Tue 25/09/2007 08:09:25
There's a room in the demo game which demonstrate this effect (which was developed from the scrolling room demo by Kairus I think).

Note that to archieve this you must have some "overlapping area on both sides of the background.

Your pic is too long, which would mess up foum display, I'll change it to a link. :P
Title: Re: Room Wrap Module
Post by: Radiant on Tue 25/09/2007 09:21:33
It's actually not that hard to code.

1) make sure the left end of the room matches the right end. I don't mean they mesh together, I mean that they have a full screen width of overlap. If your room is 500 pixels wide, make it 820 by copying the left 320 pixels to the right.
2) create a Region in AGS at the leftmost 160 pixels, and another Region at the rightmost 160 pixels.
3) code it so that whenever the player steps on the left region, you add 500 to his X coordinate, and you use the Viewport functions to set the viewport to the right, then release it (for scrolling) again.
4) ditto for the right region.

This assumes a 320x200 game resolution, just multiply for bigger resolutions.

Title: Re: Room Wrap Module
Post by: subspark on Tue 25/09/2007 09:49:08
I see. I knew there was an overlapping region for a reason. I just didn't think it would apply to AGS. Considering the nature of this effect, it appears to be a vital part of the technique.

Cheers for this and thanks for modifying the pic link Gilbot.
Awesome!

EDIT: I found this old thread about looping/wrapping rooms.
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20269.0 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20269.0)

Paul.
Title: Re: Room Wrap Module
Post by: subspark on Tue 25/09/2007 13:57:46
What would I have to do to get Strazer's code to work with my background?
My buffer width is the same as the nexus in The Dig. Buffer Width = 335.
Here is my background:
http://www.shuugouteki.net/paul/Images/ballroom_example.gif (http://www.shuugouteki.net/paul/Images/ballroom_example.gif)

Ego is meant to be able to travel left until he walks down the second set of stairs and comes to a new room at the door beneath the starting point.
I can't seem to get the number's right. I've tried all sorts of values in #define BUFFERAREA_LENGTH XXX.

Any ideas what's going wrong? I'm using 2.8 b10 by the way.

Cheers,
Paul.
Title: Re: Room Wrap Module
Post by: Khris on Tue 25/09/2007 20:11:07
Not sure about the numbers, but you don't even need the module for that background.
Make the player start at the same place, but it's far right version, and you're set.
Title: Re: Room Wrap Module
Post by: subspark on Tue 25/09/2007 22:06:53
I was thinking that. But I wanted to code in support for looping background for my game to A. To conserve resources and B. To be able to apply the same technique in other rooms.
I've actually done it your way for now but code support for looping/wrapping rooms would be nice.

Cheers,
Paul.