walk behind hill

Started by Da_Elf, Fri 24/11/2006 02:29:28

Previous topic - Next topic

Da_Elf

How do i go about getting a character to walk down a hill and be obscured. this is the BG I'm working on right now and before i go into really making it i want to know if I'm wasting my time.



should i have it so what when you click on the lower beach the game does an animation where i switch the view of my character to a sequence of cropped images of the character as he is walking down the hill then when he is down i give back control to the player and when the top of the hill is clicked it does the same thing but with a front view? this will be a pain in the butt especially when i have more than one player in the game and will have to do a view of this with all the characters. maybe I'm just wasting my time.

monkey0506

Check the manual entry on Walk-behind areas. ;)

Khris

I don't think it's that easy because some parts of the foreground and background are overlapping each other, walkable area-wise.
You'll need a good amount of scripting for this, but it isn't necessary to use cropped views. It's possible with the clever use of walk-behinds and baselines.

Da_Elf

its as khrismuc says, there are certain overlapping parts to this. its way more comlicated than simply reading about the walk behind area which i already know about monkey

Ali

#4
A solution is to create a second view for the character with their up and down animations swapped, and a walk-behind baseline that would alter at the point that the character walks over the hill. Then you need to change the character view while he's walking down hill.

That's described better in this thread where Strazer solves the problem:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25457.0

And there's a demo I made here:

http://www.2dadventure.com/ags/Walk_Behind_Hil.zip

If you're careful with the walkable areas it works quite well, and you don't need to remove player control while they're walking down the hill.

Da_Elf

wow. thats the most beautiful thing ive ever seen. whocares about detailing and colors and composition. IT WORKS!! and thats whats important isnt it.

Ali

Quote from: Da_Elf on Fri 24/11/2006 15:15:20
wow. thats the most beautiful thing ive ever seen. whocares about detailing and colors and composition.

Are you inferring something about my detailing, colours and composition...?

I'm glad that seems to have helped. Bear in mind that more than one character moving down the hill will make the walkbehind business more complicated. I'm sure it's workable though.

Da_Elf

#7
actually I'm having a problem though. walkable area 3 technically should have for tha continuous zooming a zoom level of 100-30 in my case. since the highest point is usually the smallest number on background in this particular case we need to invert that and have the highest number being the highest part of walkable area three. so in my case i need to have it as 30% to 100% however AGS wants to auto correct it when i save the room.
EDIT

is it possible to set character scale manually by scripting? and if so could i setup a script that states something like this (not written in real scripting language)
[based on a room for example thats 200 pixels high for easy calculation sake]

if character is on region 3
set character scale to ((getcharacter y possition / 200)*100)
forgive the equation but i would need to do the calculation properly to basically make that area between lets says y=100 pixels high and y=150 pixels high to be in ratio to the character being at 100% scale at 150 pixels from the bottom to a scale of 30% at 100 pixels from the bottom (of the screen)

EDIT EDIT
hehe finally found the stuff
Display("The player is at %d,%d.", player.x, player.y);
...to show me his possition...and...

cEgo.ManualScaling = true;
cEgo.Scaling = 50;

for the scaling
now to research to find out how to put this in a loop or something that will state that it always needs to find the y possition and it always needs to set the scale to the ratio of the y possition and all this needs to be dependant on the character standing on region 3

EDIT EDIT EDIT

sorry about all the editing but maybe my musing can be of help to others.
ive set that when player walks onto region to use "cN.ManualScaling = true;" and when walking off to use "cN.ManualScaling = false;" then in the while player stands on region I'm setting the scale with .. (still working on it will replace this sentance with the equation i get)
i need to inverse the hight in proportion to the scale which means in the example file since the background is between 1 and 199 if i subtract the character possition from the room hight i get the inverse i need so that region 3 is between 59pixels from the bottom and 87 pixels from the bottom with the 87 pixel location = 60%scale and the 59 pixel location = 50% however even though the ration of the location and the scale difference is 28:10 or 2.8:1 ratio, the equation to apply it into the equation of (199-player.y) still boggles me. still working on it

Ashen

It's better that you edit repeatedly than double or triple post.

Perhaps the AreaScaling Module would be of use here?
Quote
This module allows the characters to have continuous scaling, but in any direction. Currently AGS only supports the vertical direction and this module adds this functionality to any direction.

I'm not sure about the version compatability, but it should be OK.
I know what you're thinking ... Don't think that.

Da_Elf

#9
oh sure. make all the work and calculations ive been working on useless hehehe kidding this looks good

I'm using 2.71 of AGS. this script sounds like something i would love to use in multiple places however i guess I'm too new to AGS to know how to use this in my game. I'm now getting used to using functions and headers whats forum policy on private messages? could i message the writer of this module to ask for help so i dont clog up the forum?

Da_Elf

#10
sorry for bumping this but the code might come in handy. i couldnt figure out how to use those modules so i continued to figure out my equation.
basically in my screen at the top of the hill i want my character to = 100% scale and at the bottom = 30%. using the mouse possition in my room editor i knew that the highest point = 230 and the lowest was 265 since in ags it measures the lowest point as the largest scale i wanted to inverse this to make the lowest point the smallest scale (30% scale) so i put the mouse pointer at the bottom and found out that the lowest pixel was at 299.Ã,  to inverse i had to take 299-player.y
now I'm more or less working from the bottom of the screen rather than the top and the figures i got were 30% scale was at 34 from the bottom and 100% at 69 from the bottom. I worked out that there was a difference between the two of 35. Next i had to figure out the ratio between difference in scale and difference in y possition. to do this i used the equation of (R(ratio) x 0)+30=30. This being the case then i know that (R x 35)+30=100. i can now work it out that R=2 in my scene. (basically that 34 i decided to zero off so that i had a zero in my equation to help out. its just a matter of moving the y possition bracket of 35 difference by 34 pixels. So now i can come up with my final equation..remember we need to move that bracket back to its proper location. my equation is now....

cEgo.Scaling = ((((299-player.y)-34)*2)+30);

TADA!!! wheee. I'm sorry but I'm pretty happy with myself right now. I set this in the "while player stands on region" and i put the manual scaling true and false on both the "when player walks in..." and "..walks out..." in that same region (region 3)

EDIT(grrr)

damn. I'm no longer prowd of myself :( there is a glitch where the scale for that walkable area need to have continuous scaling turned off for the manual scaling to work. however when i put the manual scaling to be turned on by "if player walks onto region" there is a split second where the player uses the rooms scale before manual scaling turns on. therefore if i set the character to be 100% then at the top when he walks down the path everythings fine but at the bottom where he should be 30% when he is walking up the hill there is a moment where the rooms 100% is visable before manual scaling takes place.

EDIT EDIT (WHEE)

fixed it. all i needed to do was use SetAreaScaling(3, 100, 100); on region 2 which is at the top of the hill and will set that tricky region/walkable area 3 part to be what i need. then used the same but with 30,30 when someone walks onto region 4

Da_Elf

I know this should be in the technical section however i didnt want to start another post about the same scene ive already got a post going for.

basically the walking works perfectly when i do it manually. however i made the ocean a hotspot so that you can click on it to look and touch and i set a walkto point for the ocean. when you use the hand on the ocean it does the walkthrough yet ignores my script to alter the walkbehind line then it crashes and tells me that character.scaling should be between 5 and 200. which it is.

Ashen

Is it blocking movement, and is the line that changes the Walkbehind Baseline in repeatedly_execute?
If so, try moving that line to repeatedly_execute_always (may have to make the function first) - rep_ex isn't run during blocking commands, so it wouldn't update the baseline.

Quote
it crashes and tells me that character.scaling should be between 5 and 200. which it is.
Without seeing the entire code, and the actual layout of the room, it's hard to say but it sounds like there's SOME point the player can be on screen and be scaled outside the bounds. What if you add a check to make sure there're never less than 5% and never nmore than 200%, e.g. (untested):

Code: ags

int Temp = ((((299-player.y)-34)*2)+30);
if (Temp <= 200 && Temp >= 5) cEgo.Scaling = Temp;
else if (Temp < 5) cEgo.Scaling = 5;
else cEgo.Scaling = 200;
I know what you're thinking ... Don't think that.

Da_Elf

#13
this is my room code and the room with walkable areas and regions being the same. Sorry about image size, this is my audio computer I'm doing this game on right now and there isnt photoshop on it and the graphics card n my work system fried. Ill try to crop it somehow in paint....


Code: ags
// room script file

#sectionstart region3_a  // DO NOT EDIT OR REMOVE THIS LINE
function region3_a() {
  // script for Region 3: Player walks onto region
SetWalkBehindBase (1,400);   
if (player.ID == 0) {
cEgo.ManualScaling = true;
}
else {
  cGeta.ManualScaling = true;
  }
}
#sectionend region3_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region2_a  // DO NOT EDIT OR REMOVE THIS LINE
function region2_a() {
  // script for Region 2: Player walks onto region
SetWalkBehindBase (1,0);  
SetAreaScaling(3, 100, 100);
}
#sectionend region2_a  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart region3_b  // DO NOT EDIT OR REMOVE THIS LINE
function region3_b() {
  // script for Region 3: While player stands on region
if (player.ID == 0) {
cEgo.Scaling = ((((299-player.y)-34)*2)+30);
}
else {
  cGeta.Scaling = ((((299-player.y)-34)*2)+30);
  }
}
#sectionend region3_b  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region3_c  // DO NOT EDIT OR REMOVE THIS LINE
function region3_c() {
  // script for Region 3: Player walks off region
if (player.ID == 0) {
cEgo.ManualScaling = false;
}
else {
  cGeta.ManualScaling = false;
  }
}
#sectionend region3_c  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region7_a  // DO NOT EDIT OR REMOVE THIS LINE
function region7_a() {
  // script for Region 7: Player walks onto region
Leave(12, 13, 683, 102);  
}
#sectionend region7_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart region4_a  // DO NOT EDIT OR REMOVE THIS LINE
function region4_a() {
  // script for Region 4: Player walks onto region
SetAreaScaling(3, 30, 30);  
}


EDIT BY ASHEN:
You can use the width and height properties in the [ img ] tags to shrink it down, until you can ul a smaller image.

Ashen

#14
I'd guess that 'Player walks onto region' interactions also don't run during blocking movement, so still try it using rep_ex_always:
Code: ags

function repeatedly_execute_always() {
if (Region.GetAtScreenXY(player.x-GetViewportX(), player.y-GetViewportY()) == region[3]) SetWalkBehindBase (1,400);
else if (player.x-GetViewportX(), player.y-GetViewportY()) == region[2]) SetWalkBehindBase (1,0);
}


EDIT: Added GetViewportX/Y compensation, for scolling rooms.

It's hard to tell much from that image (it shows the Walkable areas and not the Regions that affect scaling), but have you tried the limiting code I suggested, to make sure it doesn't go beyond 5 or 200? If the player can walk to a y position of 278 or greater, I think the scale will go below 5%:
299-278 = 21
21 - 34 = -13
-13 * 2 = -26
-26 + 30 = 4
And if y is less than 180 (unlikely), it'll go over 200.

Also, you don't need to keep doing:
Code: ags

if (player.ID == 0) {
  cEgo.Stuff();
}
else {
  cGeta.Stuff();
}


To turn ManualScaling on/off and to set the Scale. You can just do player.Stuff() and it'll work on either of them (like player.y works for both).
I know what you're thinking ... Don't think that.

Da_Elf

#15
the regions are exactly the same as the walkable area. and the equation i use only happens when on region 3. otherwise it used ADS's normal continuous scaling. Region 3 (or walkable area 3) only goes between 230 and 265. the error doesnt happen when its there though. it happens when the character gets to the hotspot. according to my mouse possition over the hotspots walkto point the character is within a walkable area and it says the character should be 12%.

hmmm. ive never heard of the .Stuff comand. what does it do exactly? or do you mean that i should replace stuff with the needed commands like player.manualscaling = false

EDIT
forget using the hotspots walkto function, i just inserted a simple ...player.Walk(x,y); into the code which works just fine with the code i already have.

Ashen

That sounds like it's to do with blocking movement (the Hotspot Walk-to points use blocking automatically). If so, perhaps checking what Region the player is on and adjusting scaling if necessary in rep_ex_always would work around it. If you're happy with the way it works now, though, just ignore this.
I know what you're thinking ... Don't think that.

Da_Elf

yeah. basically the hotspot walk to feature is the exact same thing as typing player.Walk(x,y) the only difference is that one is automatic and screws up the code i already wrote hehehe and the other one is a mear couple of letters and a few numbers and doesnt screw up my code.

SSH

You could also try my new Downhill module which does the following things:

* Works for all characters
* Multiple downhill sections in one room
* Does the scaling too

One thing I found while writing it was that sometimes a character can step off the walkable area he is supposed to be on into a non-walkable area by one pixel, which can give a glitch in his scaling. I put a solution to workaround this in my module.
12

Da_Elf

#19
problem is i dont know much about the use of modules. there was another module for scaling in any direction which sounded cool but unfortunately i didnt know how to use it....oh i see now how you have documentation. time to start reading.

hmmm. I'm curious how your able to have a different baseline for each character on those walkbehinds.

oh. i didnt realise walkable areas could have Z coordinates. basically your setting a walk behind area as being closer than the walkable area thats on the other side of the hill. this means you dont need to change the baseline for the hill once your on the downward path AGS will know your behind the hill because its Z possition is behind the hills z-possition?

SMF spam blocked by CleanTalk