Script Classes for Adventure Games/Room Class

From SCI Wiki
Jump to: navigation, search

Official SCI Documentation

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Index

The Room Class

Author: Jeff Stephenson

Date: 5 April 1988


The Room Class

The Room class is the most specific Region. It is the point at which a picture, or 'scene' is defined for the player to walk around in.

In file:
Inherits from: Region
Inherited by: none



The number of the picture corresponding to the room. Usually, this will just be the room number.


If style is specified, it overrides the global showStyle when picture is drawn during the Room's init:. Any other picture drawn once the Room is running must have its show style explicitly specified.


The y coordinate which is considered to be the room's horizon. Actors which have not had an ignoreHorizon: done on them cannot be positioned above this coordinate. Also, an Ego which hits this coordinate will have its edgeHit property set to northEdge.


A Set of software blocks (Blocks), rectangles which Actors are not allowed to enter.


The number of the room to which you wish to automatically change when ego hits the specified edge of the room. If you wish to control the room change yourself when ego hits a certain edge, do not specify the room for that edge in the Room instance and check (ego edgeHit?) yourself. The edgeHit property will have the value northEdge, southEdge, eastEdge, or westEdge if ego hit one of the edges.


A set of dialog items (DItems) which are push-buttons for this


This property is the angle above level that you are viewing the picture. It is used to set the global perspective upon room entry.


These are set according to where the vanishing point is in the picture to be shown. They determine the angle that the arrow keys will move ego in a room. The Up key will always move ego towards the vanishing point and the down arrow away. The default give a straight up and down in response to these keys.



The default init: for a Room is to create an empty Set of Blocks, draw the picture specified by picture, and set ego's position based on its position in the previous room. You will want to supplement this with the following:
Load all views, sounds, pictures, etc. which will be required by the room so as to get all disk access done at Room initialization time.

Initialize all Actors and Actors which are to be in the Room initially.
Set a script for the Room.

Add any required Blocks to the Room.


Send the doit: message to this Room's script, if it has one, then check to see if ego has hit the edge of the Room. If ego has hit an edge and there is a room number specified for the edge, invoke the newRoom: method to change to that room.


This is called by the game when changing from this Room to a new Room. The game handles disposing of the current cast, then does a (curRoom dispose:). The default dispose: simply disposes of the Room's script, blocks, and controls. You will want to supplement this to dispose: of anything else which you have created which is specific to the Room, and any modules which the Room has loaded.

setRegions: region [region ...]

Sets the Regions which contain this room. This should be invoked in the init: method of the room. The parameters region are the script numbers of the regions. They should be listed from most specific to most general, since the order in which they are listed is the order in which they will be invoked. Thus, for a room in Ulence Flats in Space Quest, we might write
(self setRegions: ULENCE_FLATS KERONA)

to say that we are in the town of Ulence Flats on the planet Kerona.

The global variable regions contains the ID of a List of regions which are sent the doit: and handleEvent: messages in order when appropriate. The newRoom: method of Game puts the current room at the head of this list, and setRegions: adds Regions to the end of the list in the order in which they are listed in the parameter list. If the Region was used in the previous Room, it will be neither reloaded nor reinitialized. At the end of the newRoom: method, all Regions in the list which do not refer to the current Room are deleted.

handleEvent: event

The default Room method passes the event along to the Room script (if there is one) and then to any controls in the room.

newRoom: n

This method is the one to use when changing Rooms. It is invoked when the Room automatically changes to a new Room when ego hits the edge. Reimplement this method if you need to do some processing (such as dispose:ing a Region) before changing rooms.

overlay: picture

This method overlay a picture over the current picture.




Table of Contents


< Previous: The Locale Class Next: The Timer Class >