Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Mkt2015 on Sun 05/12/2004 06:45:09

Title: Question at start of game.
Post by: Mkt2015 on Sun 05/12/2004 06:45:09
I plan on having a battle system in my game, but I also want to give the player the ability to choose whether or not they want to have it. I have tried many different things when it comes to programming it. The question is a simple yes/no question and I want to check and see 1. if yes was selected; 2. if no was selected; and 3. if the player pressed some other button, in which case I designate the answer as yes.

I know this should be a pretty simple thing. I've taken a class on Pascal and C++ but yet I can get everything working except for one thing. If the player chooses "no" I always see "yes."

function game_start()
{
  // called when the game starts, before the first room is loaded
PlayVideo("MaxPayne_NYM_p1c1_206.avi", 1, 1);
SetNormalFont(2);

string rpg; 

DisplayAt(100,100,200, "Do you want it to be like an RPG? (Y)es/(N)o?");
While (IsKeyPressed(89)==0) || (IsKeyPressed(78)==0) Wait(1);

if (IsKeyPressed(89)==0)
{
  Display("Yes");
}
else if (IsKeyPressed(89)==1)
{
  Display("Yes");
  }
else if (IsKeyPressed(78)==1)
{
  Display("No");
  }
else if (IsKeyPressed(78)==0)
{
  Display("Yes");
  }
}
Title: Re: Question at start of game.
Post by: Mkt2015 on Sun 05/12/2004 07:16:57
Because I couldn't find a edit post feature I will say that I finally figured it out.

Because I couldn't figure out how to edit a post I will say that I finally figured it out.

int rpg; 

DisplayAt(100,100,200, "Do you want it to be like an RPG? (Y)es/(N)o?");
if ((IsKeyPressed(89)==0) && (IsKeyPressed(78)==0))
{
  Display("Yes");
  rpg=1;
}
else if ((IsKeyPressed(89)==1) && (IsKeyPressed(78)==0))
{
  Display("Yes");
  rpg=1;
  }
else if ((IsKeyPressed(89)==0) && (IsKeyPressed(78)==1))
{
  Display("No");
  rpg=0;
  }
Title: Re: Question at start of game.
Post by: Pumaman on Sun 05/12/2004 21:30:53
Yeah, prompting the user for a keypress is actually pretty messy, because AGS is event-driven and so you normally respond to keypresses in the on_key_press function.

To edit a post just click the "Modify" link in the top right of the post.