Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Matti on Tue 12/04/2011 16:46:20

Title: baseline question
Post by: Matti on Tue 12/04/2011 16:46:20
I'm working on a swordfight with several enemy characters and I want the player (well, the sword) to be drawn in front or behind the enemy, depending on the kind of attack.

I have this line to change the baseline accordingly. It's supposed to be the enemy's baseline + 1 or - 1 (basel).


 if (player.Baseline != character[baseChar].Baseline + basel) player.Baseline = character[baseChar].Baseline + basel;


It didn't work at all and I was going to post this here. Then I changed
 character[baseChar].Baseline
to
 character[baseChar].y

and it worked! Shouldn't the default baseline be the same as character.y ?
Title: Re: baseline question
Post by: Khris on Tue 12/04/2011 17:42:41
As far as I understand the manual, you can use the .Baseline property to keep the baseline at a certain fixed position while setting it to 0 will make AGS go back to use the character's feet.
In other words, by default Character.Baseline is always 0 and in that case the engine will use Character.y to determine the drawing order.
Title: Re: baseline question
Post by: Matti on Tue 12/04/2011 20:42:14
Yeah, but isn't it a bit strange that


if (player.Baseline != x) ...


works, while


player.Baseline = character[baseChar].Baseline + x


doesn't work? I mean, both character's baselines are set to 0 (or Character.y), so where's the difference? It seems like I can get the player's baseline, but not the other character's baseline - or I can get both baselines, but not set one baseline depending on another baseline (if both are set to 0)..
Title: Re: baseline question
Post by: Khris on Tue 12/04/2011 23:26:53
The first part will always work; assuming that player.Baseline is 0, you're essentially doing
  if (basel)

The second part tries to set the player's Baseline to either -1 or 1, the former will be ignored I guess and the second doesn't make a difference.

To illustrate it better, here's the proper way to get a Character's current baseline:
int GetBaseline(this Character*) {
  if (this.Baseline) return this.Baseline;
  return this.y;  // Baseline == 0 i.e. is at this's feet
}