I have a puzzle in my game[S]

Started by Icey, Thu 10/02/2011 05:29:50

Previous topic - Next topic

Icey

 and it i kindda hard to code.

There are to regions on the floor & 4 player characters.

2 of the characters are keys to activating the switches(Dave, chris)

When dave stands on the region for a sec he will activate the region1 function.

Dave will then walk to 214, 306

Then ags will check to see if Chris has been placed on region 2 >> If not then you must place chris on region2

Both regions work the same way jut were there is a Dave there is a Chris.


Code: ags

function region2_Standing()
{
if(player.ID == chris.ID){
beam2.TweenTransparency(0.5, 0, eEaseInTween, eBlockTween);
Dave.Walk(214, 306, eBlock, eWalkableAreas);
if(Dave.x == 128){
  if(Dave.y == 305){

if(region[1].RunInteraction(0)){
chris.SayAt(8, 167, 320,"Dave:What the hell was that!?!");
ShakeScreen(1);
tifa.SayAt(8, 167, 320,"Tifa:Look!");
tifa.FaceObject(Void, eBlock);
muffy.FaceObject(Void, eBlock);
chris.FaceObject(Void, eBlock);
Dave.FaceObject(Void, eBlock);

Void.TweenTransparency(1.0, 0);

muffy.SayAt(8, 167, 320,"Muffy:It's a void. We can travel to a area not visible to man's eye.");
  region[1].Enabled = false;
  region[2].Enabled = false;
}
}

}
}
else if(?){

}
}

Khris

Not sure what you're asking here.

I've noticed this though:

Code: ags
  if(region[1].RunInteraction(0)){


First of all, the mouse.Mode which has a value of 0 is eModeWalkto. There's no interaction event for that mode though.
Secondly, you are again putting a command in the place of a condition. region[1].RunInteraction(0) gets executed, resulting in probably nothing. Some arbitrary value is then returned, and as long as it is not zero, the condition will be true.
This code is faulty, it does NOT test if region[1] was walked on or something like that.

You need to get that straight in your code, the difference between functions that DO something and functions that RETURN a value. Only the latter ones are suitable to put inside conditions.

Classic DO:
  Character.Walk(..);  // note the verbs in the commands
  GUI.SetPosition(..);  // manual explanation mentions no return type
Classic RETURN something:
  mouse.IsButtonDown(...);  // starts with is, returns bool
  Character.GetAtScreenXY(...);  // starts this get, returns Character*
  Label.Text;            // manual explanation has return type in front of command

Now, to test which region a character is standing on:

Code: ags
Region*GetRegion(this Character*) {
  Region*rr = Region.GetAtRoomXY(this.x, this.y);
  if (rr = region[0]) return null;
  return rr;
}


Usage:

Code: ags
  if (player.GetRegion() == region[1]) {

monkey0506

Studio3, I just wanted to say I think it is a good idea that you have a puzzle in your game(s). I am thinking of including a puzzle in my game too. Puzzles can be good in any game I think!

Good luck with your game and congratulations!! :=

Icey

Thanks.

Also Khris I think I found away around this to get it to work.

SMF spam blocked by CleanTalk