help with hint system code

Started by Mantra of Doom, Fri 19/12/2008 03:38:06

Previous topic - Next topic

Mantra of Doom

Hello everyone. I've been working on a little hint system code, so that if a player chooses, they can get in-game help if they get stuck. I always liked the hint guide that came with Sam & Max Hit the Road... the first line gives you a clue, then it goes more specific.

Here's my code so far. I'm using the score to keep track of the progress of the player's action. I know that I'm going about this the hard way. As of right now, the gui has text boxes that the strings populate. If the text is too long though, it will not wrap into the box and if the text is wider than the gui, it'll just not populate at all.

Any ideas how I can clean this up or at least add text wrapping?

Code: ags

//First Hint
function btnHint1_OnClick(GUIControl *control, MouseButton button)
{
  if (game.score==0) //vague hint
  {
    if (button != eMouseLeft) return;  // only react to left-clicks
  String hint1aString = txtHint1.Text;
  txtHint1.Text = String.Format("Vague Hint");
  }
 //other points follow with similar code for the first line of hints.
}
  
 //Second Hint
function btnHint2_OnClick(GUIControl *control, MouseButton button)
{
   if (game.score==0) //more specific
  {
    if (button != eMouseLeft) return;  // only react to left-clicks
  String hint2aString = txtHint2.Text;
  txtHint1.Text = String.Format("More specific");
  }
}
  
  //Third Hint
function btnHint3_OnClick(GUIControl *control, MouseButton button)
{
  if (game.score==0) //give the answer away
  {
    if (button != eMouseLeft) return;  // only react to left-clicks
  String hint3aString = txtHint3.Text;
  txtHint1.Text = String.Format("I'm just giving you the answer.");
  }
}
"Imitation is the sincerest form of imitation."

Trent R

Well, you can use GetText Width and Height to figure the size, then change it dynamically.

Is this gonna be UHS style?


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

I gotta go in a few minutes, so just a few pointers:

This line:
Code: ags
if (button != eMouseLeft) return;  // only react to left-clicks

should go at the very top of the function.

Using the score won't work at all, unless the puzzles are completely linear (which I doubt, and if they are, it's bad design).

You don't need to use String.Format unless you actually format the string.
It's fine to do:
Code: ags
  txtHint1.Text = "Vague Hint";

SMF spam blocked by CleanTalk