Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FlyRider on Tue 01/11/2005 22:24:36

Title: Problem with z property (Character)
Post by: FlyRider on Tue 01/11/2005 22:24:36
I've made a walking loop for my character. Now I realise that I need to higher the point where the character should meet the ground. Right now it's kind of floating above the ground and that's not whwt I want. Is it the "z property (player)" I should change then? And if that's the case, why do I get an error when I write?:

EGO.z= -20
Title: Re: Problem with z property (Character)
Post by: Ashen on Tue 01/11/2005 22:32:22
I think you've got the right property, but try:

cEgo.z = -20;

Or (works, but isn't the usual way):

character[EGO].z = -20;
Title: Re: Problem with z property (Character)
Post by: RickJ on Tue 01/11/2005 22:43:21
I think you want to crop the bottom of your character sprites.  The Z property allows flying charatcers such as birds to be scaled properly as the fly into the background.   
Title: Re: Problem with z property (Character)
Post by: FlyRider on Tue 01/11/2005 22:46:37
I put "cEgo.z= -20;" in the gamestart section but all I get is Unexpected 'cEgo'

When I tried "character[EGO].z= -20" I got something like '[' already defined.

What is wrong?


RickJ: Even if I crop it, it ends up a little to high because of the animation.
Title: Re: Problem with z property (Character)
Post by: monkey0506 on Tue 01/11/2005 23:12:28
When you say you put it in the "gamestart section" do you mean between the #define-s?  Because it needs to be after the line "function game_start() {" (the bracket may appear on the next line).  So it should look something like:

#define sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  cEgo.z = -20;
  /* stuff */
  }
#define sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


And as for "character[EGO].z = -20" producing a "'[' already defined" error, you probably put "Character[EGO].z = -20", which is inappropriate because AGS is case-sensative, and Character is a struct which you can only define pointers to, where the character array is an array of pointers to objects of the Character type.

[EDIT:]

If you're confused by that last bit, just realize that "character" and "Character" are different (capitalization matters!).
Title: Re: Problem with z property (Character)
Post by: FlyRider on Tue 01/11/2005 23:27:29
Thanks,  monkey_05_06, for reminding me about the brackets! Somehow, I'd managed to put the command between the last bracket and #define sectionend game_start. But now it works fine! I shure will recheck the bracket thing in the future...
Title: Re: Problem with z property (Character)
Post by: monkey0506 on Wed 02/11/2005 00:15:31
Glad I could be of help! ;)
Title: Re: Problem with z property (Character)
Post by: Elliott Hird on Wed 02/11/2005 12:57:23
May I announce that that should not work. It should be cEgo.z = cEgo.z - 20.
Title: Re: Problem with z property (Character)
Post by: DoorKnobHandle on Wed 02/11/2005 13:01:43
Elliott:


i = -20;


This will set the variable "i" (or in this case "cEgo.z" - same thing) to -20.


i = i - 20;
// ... is the same as ...
i -= 20;


This will take 20 away from i.

Thus there's a difference, imagine i to be 100. In the first case, i would turn up to be -20. In the second it would become 80.

I think he wanted to make the cEgo.z variable equal -20 in this case, but if he wanted to just position him 20 pixels higher than whereever he was, than your suggestion is right.
Title: Re: Problem with z property (Character)
Post by: Elliott Hird on Wed 02/11/2005 13:02:10
Doh, I missed the point, sorry.