MODULE: LoopRoom (proposal)

Started by RickJ, Wed 16/01/2008 00:14:05

Previous topic - Next topic

RickJ

Abstract
This module contains the script required to implement a continuously looping room such as the one in DemoQuest, which will eventually be upgraded to use this module.

Description
This module requires that a portion of the background image, beginning from the left edge and continuing for max_viewport_width pixels be mirrored on the right hand side of the image.   The following public methods and properties are provided buy this module

LoopRoom.Init(int max_viewport_width)
This function initializes the looping mechanism by performing a number of calculations based on the actual viewport and background image widths.  The parameter, max_viewport_width, specifies how much of the background image is repeated on the left and right ends of the image.

LoopRoom.LeaveLeft()
This function is called when the player character attempts to exit the left end of the screen.  The viewport is switched to the equivalent position on the right hand side of the screen.  Any NPCs are also transferred to their equivalent positions on the other side of the screen.

LoopRoom.LeaveRight();
This function is called when the player character attempts to exit the left end of the screen.  The viewport is switched to the equivalent position on the right hand side of the screen.  Any NPCs are also transferred to their equivalent positions on the other side of the screen.

The following public  provided buy this module

LoopRoom.X0      - Left edge of background image
LoopRoom.X1      - TransitionRight viewport new position
LoopRoom.X2      - Begining of non-mirrored portion of background image
LoopRoom.X3      - End of non-mirrored, TransitionLeft viewport new position
LoopRoom.X4      - Right edge of TransitionLeft viewport
LoopRoom.X5      - Right edge of background image
LoopRoom.Wv     - Viewport width
LoopRoom.Wa     - width of mirrored portion of background image
LoopRoom.Wb     - width of non-mirrored portion of background image
LoopRoom.W       - width of background image

Example Usage
// *** Room Script ***

LoopRoom    Loop;

// Player enters room first time
function room_FirstLoad() {
   Loop.Init(426);
}

// Player walks off left edge of screen
function  room_LeaveLeft() {
   Loop.LeaveLeft();
}

// Player walks off right edge of screen
function  room_LeaveRight() {
   Loop.LeaveRight();
}

I have searched for "loop room", "looping room" "looping" etc and have not found a pre-existing form of this module.  I am aware of SlideRoom and Panaorama modules but this one does something slightly different.  If there is a pre-existing version of this or if you have some comments or inputs please reply to this thread.

Rui 'Trovatore' Pires

Just a coupla questions - are objects also transported as NPCs are upon calling one of the "Leave" functions? And, is the "mirrored" bit of the BG only background or should it contain also a copy of hotspots, walkables and walk-behinds?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Khris

Yeah, I was wondering about that, too.
My guess is that the active area is there:
<-320->                   <-320->
*-----*-------------------*-----*
   |     active area         |
   *-------------------------*
  160                  RoomWidth-160
The extra 160 pixels to the left and right are used to prevent AGS from stopping to scroll.
The player is transported to the other side as soon as he walks out of the active area.
All mouse clicks outside the active area have to be intercepted and processed at the corrected coords, including walking.

RickJ

Ok, first of all I haven't coded anything yet I just  have a a couple of Visio drawings and the API documentation in the initial post.  So I'm open to suggestions of what ought to be done or what people would like to see in this module.

@Rui
I don't think we can prgramatically move or create hotspots, walkbehinds, and other areas so I was thinking that they would be duplicated.   I believe objects can be moved around so if the concenus here is that they should be transported then I can implement that.  I really don't see how we can get out of actually duplicating the walkable and walkbehind areas.  If you have to do that you may as well do regions and hotspots too.   

@KhrisMUC
I had a slightly different algorithm in mind where the entire background is active.  Mouse clicks would be processed in the usual way but objects and areas would have to be duplicated.   It seems your method better eliminates the need to duplicate objects and areas.   I am rethinking my algorithm, taking into account your insight;  any suggestions or opinions are welcome. 

Here is a sequence of drawings showing the PC walking to the left and then being transported to the other end when he reaches the left screen edge.






SMF spam blocked by CleanTalk