Walkable areas

Started by Fee, Tue 27/03/2007 10:40:13

Previous topic - Next topic

Fee

Having a minor problem in some of the rooms.

I have some rooms at 2800x2800. The walkable ares seem to be pretty much spot on, they are SLIGHTLY off, but its barely noticable.

However. with some rooms at 640x480 my character is able to walk above the walkable areas. I do CTRL-A to check out the area and I am standing outside where it is set.

I redraw the rooms and i still get the same problem :/

I could draw the walkable areas off center. But it took me 3 hrs on 1 of the maps to actually draw it out in the first place  :'(

Before you ask.. i checked the forums, the manual, the FAQ and the Wiki.. I cant find what im after....

Fee

Khris

First of all: don't redraw the walkable areas.

If your character appears to be standing outside an area, you need to crop the character's sprites.
AGS uses the bottom center of the sprite as pivot, so if there are a few empty rows of pixels beneath the feet, the char will appear "above" the walkable area.

If the char's actual pivot is supposed to be further above (because the sprite is a top-down view or something similar), put
player.Z=-10;
in game_start and try different numbers until it looks right.
(Lowering the char's Z-coordinate will always put him that many pixels below its actual position.)

Drawing complex areas using AGS's tools can be a pain, so you should check out this manual page.

Fee

Thanks dude.. tho it took me a while to figure it out.. theres a mistake in that line.

When i check the manual for player.z its not listed. Its listed under character.z and as usual the example is not as simple as am example a manual should provide.


Ashen

player is a Character Pointer (to the current Player Character, obviously enough), so it uses all the properties and functions the Character type can (player.Walk, player.Animate, etc). So, if your Player Characetr was cEgo, you could just as easily use:
Code: ags

cEgo.z = 10;


(Khris got the capitalisation wrong, though - it needs to be Lower case.)

It's mentioned in the manual, although admittedly not in great detail:
Quote
player.[x,y,name,...]
Alias to the current player character.
I know what you're thinking ... Don't think that.

ciborium

I am having a little trouble with the player.z control.

My sprite has a shadow as part of the sprite image with the shadow going below his feet.

I put in my repeatedly execute:
Code: ags

player.z = -(3 * (player.Scaling / 10));


Now while this works.  It puts Ego's feet exactly where I click the curser, as intended.

The problem is that every time I go into a new room, the sprite is loaded as player.z = 0, and then jumps down the appropriate amount.  Is there a way to get the player.z position to load before the screen fade-in? 

Or, do I have to program every room to the appropriate player.z value in the before fade-in, based on which room I came from?

P.S.  Before anyone asks, there is some dead space under the shadow (hence the reason for such a large number,) but the shadow does go far enough below his feet to prevent simply cropping the images.

Khris

In the global script, add this
Code: ags
function on_event (EventType event, int data) {
  if (event==eEventEnterRoomBeforeFadein) player.z = -(3 * (player.Scaling / 10));
}


Another solution might be to put the line into repeatedly_execute_always. Not sure if isn't also paused during a room's fade-in, though.

ciborium

Neither suggestion corrected the problem. 
I even tried putting it directly in one of the room's Enter Room Before Screen Fade-in script.
Maybe AGS isn't loading the scaleable areas in time...

I might just have to put concrete values into each room's Enter Room Before Screen Fade-in.

Khris

I found the solution:
Code: ags
function on_event(EventType event, int data) {
    if (event==eEventEnterRoomBeforeFadein) {
      player.z=-(3*(GetScalingAt(player.x, player.y)/10));
    }
}


It seems that player.Scaling isn't set until after the fade-in; however, GetScalingAt does return the proper value.


SMF spam blocked by CleanTalk