Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Vel on Fri 30/05/2003 15:40:44

Title: Character shadow
Post by: Vel on Fri 30/05/2003 15:40:44
OK, I want there to be a shadow when a character stands on the castle wall. I make a new character(upside down), use the SetCharacterTransparecy command...and it doesn't work. Here's the script:
Repeatedly execute:

while(character[ABBAT].walking!=0){
 MoveCharacter(SHADOW, character[ABBAT].x, 221);
 }


Interaction:

character[SHADOW].room=character[GHERKIN].room;
SetCharacterTransparency(SHADOW, 50);
SetGlobalInt(43, 1);
character[SHADOW].x=character[ABBAT].x;
character[SHADOW].y=221;
SetCharacterView(SHADOW, 35);
MoveCharacter(ABBAT, 11, 42);
Wait(300);

The shadow shows up, but doesn't move. Any suggestions?
Title: Re:Character shadow
Post by: Pumaman on Fri 30/05/2003 17:07:07
Replace this:

Quote from: Vel on Fri 30/05/2003 15:40:44
while(character[ABBAT].walking!=0){
MoveCharacter(SHADOW, character[ABBAT].x, 221);
}

With this:

character[SHADOW].x=character[ABBAT].x;


Title: Re:Character shadow
Post by: Vel on Fri 30/05/2003 18:53:26
Sorry Chris but it doesn't work. The shadow doesn't move, it just changes its place after the interaction cutscene. Any other ideas?
Title: Re:Character shadow
Post by: Scorpiorus on Fri 30/05/2003 19:19:44
A laggy shadow, Vel ;D

So it's a cutscene. That changes the things...

a bit of modifications:

Interaction:

character[SHADOW].room=character[GHERKIN].room;
SetCharacterTransparency(SHADOW, 50);
SetGlobalInt(43, 1);
character[SHADOW].x=character[ABBAT].x;
character[SHADOW].y=221;
SetCharacterView(SHADOW, 35);
MoveCharacter(ABBAT, 11, 42);
//instead of the code in the repeatedly execute:
while (character[ABBAT].walking) {
 character[SHADOW].x=character[ABBAT].x;
 Wait(1);
}


as about the code inside the repreatedly execute you do not need it anymore.

how is it turn out?

-Cheers
Title: Re:Character shadow
Post by: Vel on Fri 30/05/2003 19:53:58
Yes! It is working!I've got a couple of questions about changing the shadow view, but I'll post the tomorrow. Im just too sleepy. Anyway, that was just the start.
Title: Re:Character shadow
Post by: Vel on Sun 01/06/2003 10:09:29
Here's the illustration:
(http://www.2dadventure.com/ags/catledoorsinsidegif.gif)
Title: Re:Character shadow
Post by: Vel on Sun 01/06/2003 10:12:29
Legend:
Yellow-
(http://www.2dadventure.com/ags/obzzshadow1.gif)
Red -
(http://www.2dadventure.com/ags/obzzshadow1a.gif)
Purple/Blue - (http://www.2dadventure.com/ags/obzzshadow3a.gif)(Flipped)
Green -
(http://www.2dadventure.com/ags/obzzshadow3.gif)
Any Ideas how can I make this?
Title: Re:Character shadow
Post by: Scorpiorus on Mon 02/06/2003 17:00:54
Do you mean the player have to walk ontop of the wall casting the shadow onto the ground?

Is it just for a cutscene or you want it during the gameplay too?
Title: Re:Character shadow
Post by: Vel on Mon 02/06/2003 17:39:17
Yes, thats what I need. There are three hard parts though.
1)The shadow does not belong to the player character, so the player stands on region event doesn't work
2)movement on the wall:shadow movement on the ground=1:2
3)changing shadow views while the character is behind the stone slabs.
Title: Re:Character shadow
Post by: SSH on Mon 02/06/2003 17:56:11
Quote from: Vel on Mon 02/06/2003 17:39:17
Yes, thats what I need. There are three hard parts though.
1)The shadow does not belong to the player character, so the player stands on region event doesn't work
You need to modify the code inside the while loop to have:
if (character[ABBAT].x<FIRSTAREAx) {
  view=whatever;
} else if (character[ABBAT].x<SECONDAREAx) {
  view=whatever2;
} etc. etc. etc.

this is easyush because you're only moving in 1 dimension

Quote
2)movement on the wall:shadow movement on the ground=1:2

Use the multiplication operator?

Quote
3)changing shadow views while the character is behind the stone slabs.
see answer to number 1


EDIT: By the way, shouldn't the existing shadow of the wall have a gap corressponding to the archway?
Title: Re:Character shadow
Post by: Vel on Mon 02/06/2003 18:21:12
I have a door as an object. Your second answer is not very clear to me.
Title: Re:Character shadow
Post by: Scorpiorus on Mon 02/06/2003 22:30:24
Vel:
Here is a template I made (shadow_template (http://invis.free.anonymizer.com/http://geocities.com/scorpiorus82/shadow_template.zip)). It's not a cutscene but you can easily make one by integrating the room's repeatedly execute code into:
while (character[ABBAT].walking) {
<..........>
<..here..>
<..........>
Wait(1);
}

Pay attention on how I used walk-behind mask (N1)  to hide the shadow (I think it's the most smoother way :P) The walkbehind baseline is set to the top of the screen so it shouldn't affect any other characters walking near the wall.

let me know what do you think

-Cheers
Title: Re:Character shadow
Post by: Vel on Tue 03/06/2003 13:25:11
Thanks a lot!
Title: Re:Character shadow
Post by: Synthetique on Tue 03/06/2003 13:56:38
heheh... if it's only a cutscene then why don't you just animate the whole thing?
Title: Re:Character shadow
Post by: Vel on Tue 03/06/2003 14:51:45
Oh. Yeah. SURELY an avi of a minute or so wont make the file size big.
Title: Re:Character shadow
Post by: Privateer Puddin' on Tue 03/06/2003 14:56:30
compression is your friend
Title: Re:Character shadow
Post by: Synthetique on Tue 03/06/2003 15:11:07
no need for avi... pcx is your friend..
just make a character being the ground and draw the shadows and put them in the view loops (like you put walkcycle pics in the views) and then manipulate from there..
Title: Re:Character shadow
Post by: Vel on Tue 03/06/2003 16:08:44
Nah. This script works fine.
Title: Re:Character shadow
Post by: Scorpiorus on Tue 03/06/2003 16:14:40
Quoteno need for avi... pcx is your friend..
just make a character being the ground and draw the shadows and put them in the view loops (like you put walkcycle pics in the views) and then manipulate from there..
Synth, it is actually how it's done. :) We have a character representing a shadow. But why we need to draw all possible positions of the shadow character? It's more simplier to have a formula to calculate it's location. As SuperScottishHero said, he have a particular situation when the character walks in 1-dimention. Of course the formula parameters may need to be adjusted to get more precision movement. Also having a bit more shadow sprites would make it more realistic. Finally such implementation still give the opportunity to use the shadow not just while the cutscene is running. ;)

-Cheers
Title: Re:Character shadow
Post by: Vel on Tue 03/06/2003 17:38:02
Question: HOw can I create a walkbehind just for the shadow? There are two other characters on this screen and three other walkbehinds.
Title: Re:Character shadow
Post by: Scorpiorus on Tue 03/06/2003 18:50:41
QuoteQuestion: HOw can I create a walkbehind just for the shadow? There are two other characters on this screen
Actually the walkbehind area doesn't affect any other characters. Look in the template game: the baseline of the walkbehind is set to 4 (or something about) so it's top of the screen. The shadow's baseline is set to 1. Therefore althought the walkbehind hides the shadow it doesn't hide any other character walking at the area near the wall.


Quoteand three other walkbehinds.
You mean they cross that walkbehind? Looking at the background I can't see any other possible walkbehinds could cross the one for the shadow.

-Cheers
Title: Re:Character shadow
Post by: SSH on Wed 04/06/2003 14:37:37
Quote from: Scorpiorus on Tue 03/06/2003 18:50:41
Quoteand three other walkbehinds.
You mean they cross that walkbehind? Looking at the background I can't see any other possible walkbehinds could cross the one for the shadow.

Even if there were, you could maybe work-around it by making the thing that you were walking behind an object rather than part of the background.

On the other hand, in theory it might be useful to have overlapping walk-behinds, given that they can have different baselines. Maybe it's one to add to the list of enhacement requests...
Title: Re:Character shadow
Post by: Vel on Wed 04/06/2003 15:52:10
Nevermind, I figured it out.
Title: Re:Character shadow
Post by: SLaMgRInDeR on Wed 04/06/2003 17:08:02
why not just make it into new views for the character rather than having a new character, and tell it to change the characters view?
(   (   ( <( -_-)> )   )   )
Title: Re:Character shadow
Post by: Scorpiorus on Wed 04/06/2003 18:01:45
QuoteEven if there were, you could maybe work-around it by making the thing that you were walking behind an object rather than part of the background.
yep, having a character or an object instead of walkbehind helps so that's actually not a problem.

QuoteOn the other hand, in theory it might be useful to have overlapping walk-behinds, given that they can have different baselines. Maybe it's one to add to the list of enhacement requests...
I think it's not so easy meaning technical side as at present AGS uses one mask for all walkbehind areas by means of drawing it with different colors.
Ability to change (load) masks for one room was suggested recently. But it still would use one bitmap. EDIT: if it's not it would be cool... ;D

Quotewhy not just make it into new views for the character rather than having a new character, and tell it to change the characters view?
There are at least two reasons why not:
1) The baseline of the character needs to be adjusted then. Well for cutscene it's not a big problem but we may want to use the same technique later on in the game maybe. :P
2) We need to draw tall sprites and in any case will be unable to change the distance between the character and the shadow.


EDIT: btw, it just occured to me that in fact it maybe even isn't needed to have overlapping walk-behinds. :P just can't imagine the situation in which it could be used.


-Cheers
Title: Re:Character shadow
Post by: Snake on Thu 05/06/2003 05:01:13
Quote...just make a character being the ground and draw the shadows and put them in the view loops (like you put walkcycle pics in the views) and then manipulate from there...
lol, Vel. That's actually someting like I would have done before I would have been arsed to figure out the code ;) I would have made the screen a big object or character and just animated it ...heh.


--Snake