If I find some objects, the room background can change?

Started by marypotter3, Wed 21/09/2011 00:53:22

Previous topic - Next topic

marypotter3

Hey, first of all, sorry for my awful english. Well, I'm creating a game that, after you find 3 symbols, it needs to change the background of a room. But I have no idea of how I can do it. I've started creating with AGS today, so I'm completely lost.

Thanks!

pcj

You can set up multiple background frames (see "Animating background scenes" in the help file) and then use SetBackgroundFrame as needed to switch between them.
Space Quest: Vohaul Strikes Back is now available to download!

marypotter3

#2
Where do I find this help file? Sry for noob questions, I'm new at this...

pcj

Press F1 in AGS.  You can call SetBackgroundFrame at any time in script.
Space Quest: Vohaul Strikes Back is now available to download!

marypotter3

But how can I put this background only AFTER finding those symbols?

So, it needs a code? I'm not good with that, what code can I use?

pcj

You put SetBackgroundFrame in the function that processes "finding the symbols" - if that means "Look at object" then put SetBackgroundFrame in the associated function for that event.
Space Quest: Vohaul Strikes Back is now available to download!

marypotter3



pcj

It depends on what you mean by "finding those symbols".  If you mean "the character walks up to the object", you can put a region under it and map a function to it, then put SetBackgroundFrame in the function.

It's a mixture of setting up regions/objects and code, so it's hard to provide code that works out of the box unless you give me an idea of what you have so far.
Space Quest: Vohaul Strikes Back is now available to download!

marypotter3

Ok. Is a point-and-click game. First symbol is on the inicial room, the other symbol is in the stairs, and the third is upstairs. The symbols are in the background, they are not objects (because i dunno how to use objects...), and I don't know what are regions either.

The symbols are hotspots, and when you click on them, my code is like:

// room script file

function hSymbol1_Look()
{
Display("It sounds like you've found a strange symbol.");
}

Please help me x_x

pcj

So, once you've got the background frames set up it will be like:

Code: ags
function hSymbol1_Look()
{
Display("It sounds like you've found a strange symbol.");
SetBackgroundFrame(1);
}


And you'll need to bind "enters room before fade-in" and specify:
Code: ags
function room_Load() 
{
SetBackgroundFrame(0);
}
Space Quest: Vohaul Strikes Back is now available to download!

marypotter3


pcj

You need to set up the background frames first in the room editor.  Look for the Display Background setting to specify a new background.

Space Quest: Vohaul Strikes Back is now available to download!

Khris

The issue here is that the background should only change after all three have been found.

Here's what you do:
Open the Global variables pane, add an int with name symbols_found and initial value 0.
Now add another one, type bool, name change_bg, initial value false.

Then use this for the hotspots:
Code: ags
function hSymbol1_Look()
{
  if (Game.DoOnceOnly("finding symbol 1")) {      // first time the player looks at hotspot
    Display("It sounds like you've found a strange symbol.");
    symbols_found++;
  }
  else Display("There's nothing else there to be found.");   // every subsequent look at action

  if (symbols_found == 3) change_bg = true;
  if (change_bg) SetBackgroundFrame(1);   // if the current room isn't the one supposed to change its background, remove this line
}


Same for the other two hotspots/symbols, it's important that you use a different string for Game.DoOnceOnly though. Just replace the '1' with a '2' and '3'.

Once you click for the first time on one of the hotspots, the usual message is displayed and symbols_found is incremented by one. If the hotspot was the third and final one, it will be 3 now, so change_bg is set to true.

For the hotspot in the room that's supposed to change its background, we add another line that'll immediately cause that.
Add the "enters room before fade-in" to that room and put this inside the function:

Code: ags
  if (change_bg) SetBackgroundFrame(1);

marypotter3

But, if I click on the symbol that is the third, before the other symbols, the bg still changes! can the player just find the symbols and, when reach 3, then the new area open?

marypotter3

Oh, my mistake, sorry. I didn't put the "if (change_bg) SetBackgroundFrame(1);" on the code. Sorry!

And thank you! You guys helped me a-lot! (:

Khris


SMF spam blocked by CleanTalk