Character Baselines and more.

Started by Wonkyth, Sat 02/05/2009 06:04:28

Previous topic - Next topic

Wonkyth

#1. Recently, while using the Keyboard Movement module(in Ver. 3.1.0), I noticed that when you move diagonally it doesn't use the respective loop(5-8), it just uses either the first direction you pressed or sometimes it just uses the horizontal loops. Is there an easy way I can modify this so as to use the right loops?

#2. I know that a characters position is based on the bottom-centre pixel, but what if your sprites base is something like, say, six pixels wide? What happens then? For the purposes of precision, I would really like to know.

#3. What would be the best way to have (at least the equivalent of) the the baseline of a character in the sprites centre? Is there any way to set the baseline like that, or would I have to put something through RepeatedlyExecute, setting a variable to x above the characters position?

#4. How does movement offscreen work? I'm planning on making a game that has a lot of characters moving in other rooms, but I'm not sure if it would work if I cant make room script activate while your not in the said room. Can you still have things like IsCollidingWithChar and such?

I hope these questions aren't too cryptic, and if they are complex enough for the Technical Forums tell me and I'll delete this and ask in that Forum instead.
Thanks in advance for any help.
Wonkyth.
"But with a ninja on your face, you live longer!"

Joe


Quote from: wonkyth on Sat 02/05/2009 06:04:28
#2. I know that a characters position is based on the bottom-centre pixel, but what if your sprites base is something like, say, six pixels wide? What happens then? For the purposes of precision, I would really like to know.
AFAIK there is no way to solve this in a simple way. I suggest you to set the character[].Baseline property to the further pixel of its base.

Quote from: wonkyth on Sat 02/05/2009 06:04:28
#4. How does movement offscreen work? I'm planning on making a game that has a lot of characters moving in other rooms, but I'm not sure if it would work if I cant make room script activate while your not in the said room. Can you still have things like IsCollidingWithChar and such?

I think so. Because characters are global varibles, not like object that are local for each room.

About your other questions I really don't know what to say. I haven't looked at the keyboard movement module too much, you should ask their authors (Strazer & Rui)

Joe.
Copinstar © Oficial Site

Wonkyth

"But with a ninja on your face, you live longer!"

Khris

#2 Not sure what you're meaning here, AGS doesn't check the sprite for transparent pixels. If you want the character not to walk on something, make the walkable areas more narrow.

#3 You can achieve that easily by changing the character's .z coordinate. Just set it to something like -40 for an 80 pixels tall sprite and it'll get display further down with the rest of the behavior intact.

#4 Make the characters invisible and let them walk the current room.
I'm not sure if collision detection works while characters are invisible though. You could try to set their transparency to 100, then the sprite is technically visible and collision detection should work as usual.

To have characters move off-room i.e. outside the room's coordinates, you need to include the eAnywhere parameter in the .Walk command so they don't have to stick to walkable areas.

RickJ

1.  The diagonal loops don't seem to work the I expect.  It's tricky to get the character to walk at the right range of angles to activate the diagonal.   I believe there was some discussion about this at one time but can't remember what if anything came of it.    I would suggest that you experiment to determine in which range of angles diagnoal loops are used and modify the Movement module accordingly.  Be certain to update the module's revision history, clearly document your changes, notify the author, and send him/her a copy.

2.  I don't know the answer to this but one would expect that it would be centered on either pixel 3 or 4, which I guess is your question.   The sprite could be made 1 pixel wider and filling the new space with transparent pixels to control the result.

3.  Characters have a Z position property that can be set.   This effectively positions the character above or below the baseline.   I am not certain if there is a baseline property or not; just look in the manual for character properties and functions.

4.  Only one room is loaded at any given time so it's only possible to interact with the currently loaded room.   NPC characters can be moved other rooms and they can also be repositioned.  They can't however be made to walk or do other things which requires interaction with room entities.  Walking for example requires interaction with walkable areas and room objects.  There is an module called "OtherRoom" or something similar that you may find useful.  

Wonkyth

Quote from: KhrisMUC on Sat 02/05/2009 15:02:30
#2 Not sure what you're meaning here, AGS doesn't check the sprite for transparent pixels. If you want the character not to walk on something, make the walkable areas more narrow.

What I mean is:

XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXABXX

say the above grid is the character sprite, is the character at A or B?
My problem isn't to do with walkable areas, it's to do with the positioning of objects and characters that have to appear in certain positions relating to where the player character is.
"But with a ninja on your face, you live longer!"

Wonkyth

Quote from: RickJ on Sat 02/05/2009 15:18:02
 I would suggest that you experiment to determine in which range of angles diagnoal loops are used and modify the Movement module accordingly.
I'll give that a try.

Quote
2.  I don't know the answer to this but one would expect that it would be centered on either pixel 3 or 4, which I guess is your question.   The sprite could be made 1 pixel wider and filling the new space with transparent pixels to control the result.
I could do that, but it would make things a bit more difficult in other areas, as I also require accurate collision detection.

Quote
4.  Only one room is loaded at any given time so it's only possible to interact with the currently loaded room.   NPC characters can be moved other rooms and they can also be repositioned.  They can't however be made to walk or do other things which requires interaction with room entities.  Walking for example requires interaction with walkable areas and room objects.
Would it be possible to put something through repeatedly_execute that constantly repositions characters, could you simulate normal movement like that?

QuoteThere is an module called "OtherRoom" or something similar that you may find useful.  
I'll have to look into this.

thanks Rick
"But with a ninja on your face, you live longer!"

Khris

I'd say the character is at B because AGS probably uses Character.x - sprite_width/2.
So a 5 pixel wide character will be displayed 2 pixels to the left (2.5 as int -> 2), resulting its third and center pixel being at the actual position, and thus with an even sprite width, e.g. 6, the sprite is moved 3 pixels to the left, which makes its fourth pixel being displayed at the actual position.

RickJ

#8
Quote
Quote
4.  Only one room is loaded at any given time so it's only possible to interact with the currently loaded room.   NPC characters can be moved other rooms and they can also be repositioned.  They can't however be made to walk or do other things which requires interaction with room entities.  Walking for example requires interaction with walkable areas and room objects.
Would it be possible to put something through repeatedly_execute that constantly repositions characters, could you simulate normal movement like that?

Yes, I believe so.  I would probably make a module that provided extended walk functions that could be used instead of the standard character.walk() function. The extended function could then either call character.walk() if the character is in the current room or do a simulation otherwise. 

You could even define "extender" functions so that in the game script you would just do something like cEgo.ExWalk(...) instead of cEgo.Walk(...).

If you look in the other room module I believe it does some of this so perhaps you can get some ideas/examples.

Wonkyth

#9
Thanks!
That's probably what I'll have to do, but I haven't had a look at the OtherRoom module yet. I'll do that now...

Also, is there an easy way get/set the direction a character is facing?
There is a page in the wiki called "Facing", but its empty, and I couldn't find it using a search.

(EDIT) wait, I found the faceright module, I should be able to modify that to suit my needs.
"But with a ninja on your face, you live longer!"

Trent R

Or use character.FaceLocation commands. (which I think that module uses)

~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

Wonkyth

Yeah, pretty much. ;D
It does make things a little easier, even though the module is only like ten lines or something.
Anyway, having it in a module helps me organize my mind a little easier, not to mention making it easier to make gradual changes.
"But with a ninja on your face, you live longer!"

RickJ

Just a reminder to read the Module Programming Guide in the technical archive  and to have a look at the module templates and other docs that come with  DemoQuest before starting your module.

http://demo.agspace.ws/project/documents/ModuleHeaderTemplate-V0101.txt
http://demo.agspace.ws/project/documents/ModuleScriptTemplate-V0100.txt

SSH also has similar module templates somewhere or other, perhaps his website and/or the Wiki, that may be more up to date?     

 
Anyway review the guidelines and use a template to create your module to you started on the right path  and to avoid future problems.  If you need any module writing help, just ask.

SMF spam blocked by CleanTalk