A question about creating a game where the player can switch between two worlds

Started by Penguin Smith, Sat 08/08/2009 19:29:51

Previous topic - Next topic

Penguin Smith

Hi there,

I've started work on a small prototype where the player is able to switch between two worlds; the real world and a dream world. The idea is that they can do this whenever they please.

In the real world, the player's character is represented by their mouse cursor; a small fairy who can interact with objects much like in an 'Escape the Room' style of game. This means there is no actual character walking around on screen.

In the game, this Fairy must enter a girl's dream to help her get out of it. When the player does this, they enter the dream world. Here, the player's cursor remains as the Fairy, but the girl is also present, much like any other adventure game.

In short, I need the player to be able to switch between locations instantly and also switch between the 'escape the room' style of game system (without a protagonist onscreen) and the traditional Adventure game system (with an oncreen protagonist).

I appreciate that all this may be a little much, but it would be incredibly helpful if anyone could suggest a simple way of pulling this off. Unfortunately, I only have a limited amount of time to make this protoype, which means I'm going to need all the help I can get in terms of learning AGS.

Many thanks in advance. 

monkey0506

This wouldn't be complicated at all to pull off. All you need to do is make separate rooms for the "real" world and the "dream" world. In the real world room you're going to make sure that "ShowPlayerCharacter" is set to false. In the dream world rooms it will be set to true.

Other than that just use player.ChangeRoom to switch between the worlds.

If you want to have the dream world be a mirror of the real world just with different items, characters, etc. then instead of using separate rooms you could track a variable and then use a custom function to switch but it would be more complicated if you're changing a lot of graphics or other items.

But for example you could make it easy on yourself (if you wanted to have the dream world mirror the real world) by having your real world rooms numbered say 0-100 and your dream world rooms 100-200. Then to switch you would just do player.ChangeRoom(player.Room + 100) (or player.ChangeRoom(player.Room - 100).

Penguin Smith

Thanks loads for the help! It's really been invaluable and I've managed to get really far into the making of this thing based on your suggestions so I can't thank you enough. I'm nearing the end of my prototype and have unfortunately hit a snag; one of the main mechanics in my game is that the items the player picks up (once in the inventory) will change depending on what world they are in e.g. a Computer mouse might be picked up in the real world and turn into an actual mouse in the dream world. Is there any way to track what room the player is in and replace the objects in the inventory accordingly?

Thanks again in advance

Vince Twelve

There are several ways to do this.

One would be to use two inventories, then when you pick something up, you would add the computer mouse to one inventory and the real mouse to another.  Then, when you're in one world, opening the inventory would show you the first inventory, and in the other world, it would show the other.

Another way would be, when you switch worlds, call a function that goes through and changes the name and graphic of each inventory item.  So, for example, inside the function it would say:

Code: ags

if(changing to real world){
  iMouse.Name="Computer Mouse";
  iMouse.Graphic=25;
  //other inventory items here
}
else{ //going to the zany world
  iMouse.Name="Live Mouse";
  iMouse.Graphic=26;
  //other inventory items here
}


Then just call that function each time you change between worlds.

There are probably more ways to do it as well, just throwing out the first ways that came to mind.

Penguin Smith

Thanks loads for your help, but I'm still kind of stuck: I tried the first method as it seemed the simplest, but nothing seems to happen.My first character is called Maya so I created a second character (called Willow) and assigned alternate versions of each item to that character as they were picked up.

At the beggining of each of the script for each of the real world rooms, I used this code:

function room_Load()
{
  cWillow.SetAsPlayer ();
}

and then just changed the character for the script in the Dream World rooms.

Is there something obvious I'm missing? Thanks again for your help.

Vince Twelve

When you change to the room, it's going to set Willow as the playable char, but you need to make sure that willow is in that room first.

So, if you're in the real world as Maya, and then she changes to one of the bizzaro world rooms using the code:

cMaya.ChangeRoom(10);

then in Room 10's script, you need to make sure willow's in the room, then switch to her, then move maya out of the room.  (unless she's supposed to be there)

function room_Load()
{
  cWillow.ChangeRoom(10);
  cWillow.SetAsPlayer ();
  cMaya.ChangeRoom(-1);
}

Penguin Smith

I've done exactly as you've said, but it still refuses to work. The character is simply not changing room and I've no idea why as my code is exactly as you wrote it.

Is there any other reason you could think of why this simple function is refusing to work?

Vince Twelve

Take all the code out of room_Load() and just try to change maya to the new room using ChangeRoom.  Does it work?  Make sure ChangeRoom is actually getting called.  Is the character that you're calling ChangeRoom on the player?  If not, no visible room changing will take place, it'll just be moving an NPC between two rooms under the hood.


Alternatively, you could move the NPC to the new room and then call switch character and not have anything in the room_load function.  For example, if the player is currently Maya and you're in Room 9, and you want to change to Willow in Room 10, you could just call the code

cWillow.ChangeRoom(10);
cWillow.SetAsPlayer();

(This code would go somewhere in room 9's script or maybe in the global script, depending on what's causing the room change)

Penguin Smith

Thanks loads for all your help; I've finally managed to finish off my prototype and I will be sending it off to my lecturers not long from now. Thakns again and keep up the good work

SMF spam blocked by CleanTalk