Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Albert Cuandero on Wed 22/09/2004 05:23:26

Title: [SOLVED] RawPrint layering on top of objects?
Post by: Albert Cuandero on Wed 22/09/2004 05:23:26
What I am trying to do:

when the player hits a button to view stats on something a statsheet pops up and many little numbers (61 to be exact) are displaying the state of some GlobalInts.

I tried using an Object and

funciton show_stats () {
Ã,  RawSaveScreen ();
Ã,  ObjectOn (0);Ã, 
Ã,  RawPrint...
}

However the printed numbers are hidden BEHIND the sheet rather then printed on it (I checked by not switching on the object - they were just above the bg layer)- can I make it the other way?

I also considered using a GUI for this, but I can't have that many labels, can I?

Maybe the only option is switching the bg frame to one with the stat sheet drawn on it?

Any other suggestions?

Thanks in advance
Title: Re: RawPrint layering on top of objects?
Post by: Gilbert on Wed 22/09/2004 06:10:57
No, you can not raw draw on top of something, the raw functions always operate on the bg only.
In your case, instead of using an object as the sheet, you may RawDraw() it on the bg first then print the stats.
Title: Re: RawPrint layering on top of objects?
Post by: Scorpiorus on Wed 22/09/2004 06:17:33
Yeah, RawXXX family functions draw behind all objects and characters directly onto the background.

Displaying stats on a GUI seems to be the best idea to me. And you only need two labels -- the first one is to show the descriptions of properties (stamina/health/mana/etc.) and the other one - to display their values:

label1 Text: "strength:[stamina:[mana:"
label2 Text: "" i.e. a blank


// main global script file:

int Label2 = LABEL2_NUMBER;

string label2Text;
function StatsAddProperty(int value) {

Ã,  Ã,  StrFormat(label2Text, "%s%d[", label2Text, value);
Ã,  Ã,  SetLabelText(STATSGUI, Label2 , label2Text);
}


function repeatedly_execute() {


Ã,  StrCopy(label2Text, "");Ã, 
Ã, 
Ã,  StatsAddProperty(10); // strength
Ã,  StatsAddProperty(20); // stamina
Ã,  StatsAddProperty(30); // mana
}

Stats GUI:
|---------------------|
| label1Ã,  Ã,  Ã,  Ã, label2 |
| |----------| |---|Ã,  |
| | strength:| | 10|Ã,  |
| | stamina: | | 20|Ã,  |
| | mana:Ã,  Ã,  | | 30|Ã,  |
| |Ã,  Ã,  Ã,  Ã,  Ã,  | |Ã,  Ã, |Ã,  |
| |----------| |---|Ã,  |
|Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, |
|---------------------|
Title: Re: RawPrint layering on top of objects?
Post by: Albert Cuandero on Wed 22/09/2004 20:26:56
Thanks guys! I owe you a bucket of salted herrings if I ever meet you! (harr, that's pirate's thanks :))

I went for Gilbot's solution, because a pop-up GUI would pause the game (but I learned a lot from your GUI code anyway, Scorpiorus!).

I use this now (I know my code looks verrrrry n00b, but I promise to learn more, OK?):

Ã,  Ã,  int n;
Ã,  Ã,  int x;
Ã,  Ã,  int y;
Ã,  Ã,  x = 25;
Ã,  Ã,  y = 170;
Ã,  Ã,  RawSaveScreen ();
Ã,  Ã,  RawDrawImage (0, 150, 3000); //get background
Ã,  Ã,  RawSetColor (16670);
Ã,  Ã,  SetNormalFont (2);
Ã,  Ã,  RawPrint (3, 159, "%d", GetGlobalInt (55)); //show player ID
Ã,  Ã,  while (n<60) {
Ã,  Ã,  Ã,  if (GetGlobalInt (61+n) > 0) RawPrint ( x, y, "%d", GetGlobalInt(61+n)); //print if value
Ã,  Ã,  Ã,  else if (GetGlobalInt (61+n) < 0) RawPrint( x, y, "XXX"); //cross out if negative
Ã,  Ã,  Ã,  else if (GetGlobalInt (61+n) == 0) {} //do nothing if zero
Ã,  Ã,  Ã,  if (x == 85) { //when end of line
Ã,  Ã,  Ã,  Ã,  x=10; //go to beginn of line
Ã,  Ã,  Ã,  Ã,  y = y+11; //on a new line
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  x = x+15;
Ã,  Ã,  Ã,  n++;
Ã,  Ã,  Ã,  Wait (1);

At my gamespeed this takes only 1 sec. - I even like the short pause after each turn, when stats are updated!
Title: Re: [SOLVED] RawPrint layering on top of objects?
Post by: Scorpiorus on Wed 22/09/2004 20:46:51
Glad that we could be of some help and that it works as you want. :)

By the way, if you don't want a GUI to pause a game then change its visible propery to "Normal". ;)