Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ethan D on Tue 10/08/2010 18:25:06

Title: Checking order of images
Post by: Ethan D on Tue 10/08/2010 18:25:06
The program I am working on involves the user seeing a set of random letters and numbers of random color for about a 10th of a second and then trying to remember what they saw.  The goal of the program is to improve visual memory by increasing the difficulty of the task progressively.

In order to do this I have to have a check for whether the user can actually remember what they saw and I'm at a loss for how to do this.

I want the user to be able to just type in order what they saw and then pick the order of the colors from a set of 8 colors.  For instance if they saw "8bDIJHpH7vw"  and all but the last was white the last being yellow they would just type in "8bDIJHpH7vw" and click a button that is just white for the first letters and the yellow button for the last one.

I really have no clue how to do this that doesn't take in the 10s of thousands of lines to set up a check for each of the possible values for each of the images and then string together the values so it can be checked.

Including all numbers and letters in each color there are 496 possible sprites for each image drawn on the screen with a maximum of 50 on the screen. 

Sorry for the long-winded description but I don't have much of a direction for solving this problem.

Thanks for any help in advance everybody!

Title: Re: Checking order of images
Post by: Khris on Wed 11/08/2010 00:17:05
Could you clarify how exactly the user is supposed to pick the colors?

How do you get to 496? Is he typing the characters, then choosing a color for each? Why is the sprite limit of 50 a problem?

Disregarding everything but the first paragraph, I'd

- either allow coloring the typed characters by picking a color from a palette, then clicking them

- or display the typed string many times, all over the screen, with one having the correct sequence, the others random ones

All this can be done without using a single (imported) sprite or GUI button.
Title: Re: Checking order of images
Post by: Ethan D on Wed 11/08/2010 03:48:00
Quote from: Khris on Wed 11/08/2010 00:17:05
Could you clarify how exactly the user is supposed to pick the colors?

After the user types in the letters and numbers as they remember them they will be presented with 8 buttons each of which is a certain color they then have to click on the colors from left to right, right to left or of specific letters depending on which task the program chooses. 

I got 496 because 26 lower case 26 capital letters 10 numbers

26+26+10 = 62 * 8 (colors) = 496 unique sprites chosen from

50 sprites is not a problem I was just giving further information. 

I don't understand what you mean by your first suggestion.

As far as your second suggestion, I don't think it would work.  The idea is to increase visual memory skills, although I do think it would be great for speed reading skills.

How would I display the random string? 

Title: Re: Checking order of images
Post by: Khris on Wed 11/08/2010 14:25:22
Regardless of the specifics, you can use an array to store the chosen colors.
Displaying the string is as easy as:

void UpdateDisplay() {
  DrawingSurface*ds = Room.GetDrawingSurfaceFor Background();

  int i;
  while (i < combo.Length) {   // go through characters one by one
    ds.DrawingColor = combo_color[i];     // int array holding chosen colors
    ds.DrawString(100 + i*8, 100, eFontFont0, combo.Substring(i, 1));  // draw character
    i++;
  }
  ds.Release();
}


My first suggestion was allowing the user to color a letter by clicking it.

// in on_mouse_click

  int x = mouse.x;
  int y = mouse.y;

  // translate pixel coordinates to letter coordinates
  x = (x-100)/8;
  y = (y-100)/10;

  if (button == eMouseLeft) {
    if (y == 0 && x >= 0 && x < combo.Length) {   // click on one of the letters
      combo_color[x] = current_color;   // current_color holds selected palette color
      UpdateDisplay();   // redraw string
    }
  }


(Obviously, none of this will work as-is. Just meant to give you an idea.)

My second suggestions wasn't meant to test speed; the user has all the time he wants to type and choose, but instead of showing the typed string once, make it get displayed in 4 columns of 8 or similar.
Title: Re: Checking order of images
Post by: Ethan D on Thu 12/08/2010 23:25:27
Is there any way to use the Drawstring command and change the size of the font? 

Would it maybe be best to create a new font and then I can use the DrawingColor command to change the color?

How can it choose from random letters if it's from a font rather than by using sprites?

Title: Re: Checking order of images
Post by: Khris on Thu 12/08/2010 23:49:37
1) You could draw the text to a sprite, then resize the sprite. This will most certainly look ugly though (depending on the factor).

2) If you want bigger characters, yes, create a new font.

3)

alphanumeric ASCII codes:

0-9: 48-57
A-Z: 65-90
a-z: 97-122

String RndString(int length) {
  String s = "";
  int i, ra;
  while (i < length) {
    // generate random number using above range
    ra = Random(61) + 48;  // 48-109
    if (ra > 57) ra += 7;  // 48-57, 65-116
    if (ra > 90) ra += 6;  // 48-57, 65-90, 97-122
    s = s.AppendChar(ra);
    i++;
  }
  return s;
}


Usage:
  String password = RndString(10);
Title: Re: Checking order of images
Post by: Ethan D on Fri 13/08/2010 00:09:17
Cool, thanks! 

I should be able to figure it out from here.  (Though it seems every time I say that i run into another problem.)

Thanks again!