a shadow moving with characters module avail?

Started by gypsysnail, Mon 30/10/2006 13:11:39

Previous topic - Next topic

gypsysnail

Hello, I am not quite sure if there is a shadow module available for characters and objects or anything about this in the forums (yes I have searched forums for this ;) ) so for example as the character walks, or an object sits in a place that should have shadow under them to make it look a bit more realistic - if there is a module or script that can do this, please let me know. That would be really good :).
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Buckethead

Go to rooms>areas

and edit regions

Then make a region somewhere you want it be darker (shadow). Then just turn down the light level.

Taa-daa!! Your character/object will look darker while being in that place.  :)

FSi++

No, I think, she meant the character's shadow...
Well, all I could say, it's simple to implement.
1) Draw a shadow as a separate sprite
2) Make it a separate character
3) Put something like this in game script:
Code: ags

function repeatedly_execute_always()
{
  cShadow.X = cGuy.X;
  cShadow.Y = cGuy.Y - ShadowHeight;
}


I believe ShadowHeight is the height of the shadow in pixels (you could tweak it to make it look better, though).

Ashen

Depending on how advanced you want it (e.g. should the shadow adapt to the surfaces and light source in each room?), the easiest way would probably be to make the shadow part of the Character sprite, and use the Alpha channel (if your game is 32-bit colour) to make it semi-opaque (as in Darth Mandarb's pictures in this thread. Alternatively, this could be another use for Character.FollowCharacter and the 'FOLLOW_EXACTLY' parameter (which is a lot easier if you don't need the shadow to animate along with the character). That works out much the same as Fsi's suggestion, although I'm not sure about the ShadowHeight offset bit - what's the need for that?

Beyond that ... I think GarageGothic was working on a fancy, dynamic shadow system a while back (for the aptly-titled Shadowplay). Not sure what became of it, though, or even if it was ever offically released. No update in a little over a year isn't encouraging - but it does mean it CAN be done somehow.
I know what you're thinking ... Don't think that.

FSi++

Pivot for the characters is by their down side, right? So, FOLLOW_EXACTLY won't work.
Well, you could leave space beneath the character, but you'd better drew shadow there and don't bother yourself.
This would also work for 256 colors "transparent" shadows (Dink Smallwood-style)

Ashen

#5
Ah OK, I see. Good point, I guess it comes down to how exactly gypsysnail (or anyone else who's interested) wants it to work. I was thinking about a fairly basic shadow (similar to what DM illustraited in the thread I linked EDIT: or to Barbarian's post below), which FOLLOW_EXACTLY would be fine for.

Shouldn't it be cGuy.Y + ShadowHeight; though? With minus, the shadow would start ShadowHeight pixels above the character's baseline (and potentially above their head, it the shadow was 'tall' enough), and that could be achieved by leaving blank space at the bottom of the Shadow sprites.
I know what you're thinking ... Don't think that.

Barbarian

#6
Well, for my current Rise from the Abyss project, I'm doing something like Ashen suggested using the "FOLLOW_EXACTLY" command to make a fairly good looking effect of "shadows" that always are under the charaters.

I believe you'll need a high-res game setting (16 bit or above) if you want to take advantage of the transparency command.

So, first, I make a simple looking sprite like this:


Then, at some point early on before the characters appear (perhaps as a "Before Fadein" script command in one of the first rooms the character will appear in, or even before that, at say a Title Screen room, or where-ever you think appropriate) add script commands that looks something like:

Code: ags
character[SHADOW1].Transparency = 80;
cShadow1.FollowCharacter(cJack, FOLLOW_EXACTLY,1);


In this case I've made a character with the name of "SHADOW1", using that dark-oval sprite for all of it's walking views. And I tell it to "FOLLOW_EXACTLY" my "Jack" character.
The Transparency gives it a "see-through" effect, similar to a shadow. This shadow doesn't "animate", but, it serves it purpose well and I think the resulting effect still looks pretty good.

Here's a screen-shot example of a couple of "Shadows" that follow a couple of the characters in my game:



Mine is a more "simple" approach perhaps, and I know it's not perfect, but still it's okay and serves the purpose well. Of course there's various other suggestions and approaches you can use as well (as seen in some of the above posts). And if you need "fancier shadows", such as animating shadows that match the character walking directions and shape, etc... that would take more work than what I have suggested.Ã,  I also use the same ideas that "Buckethead" mentioned, to adjust light-levels for various regions to achieve even an overall greater looking effect when the character may walk through darker or lighter areas of the rooms.
Conan: "To crush your enemies, see them driven before you, and to hear the lamentation of the women!"
Mongol General: "That is good."

Blade of Rage: www.BladeOfRage.com

GarageGothic

Quote from: Ashen on Mon 30/10/2006 15:05:15Beyond that ... I think GarageGothic was working on a fancy, dynamic shadow system a while back (for the aptly-titled Shadowplay). Not sure what became of it, though, or even if it was ever offically released. No update in a little over a year isn't encouraging - but it does mean it CAN be done somehow.

No, the ShadowBox module hasn't been released, and to be honest it needs quite an overhaul before a public release. For my own purposes it's still glitchy, but right now I'm just fixing bugs on a case-by-case basis whenever it's necessary for my game. A tech demo is coming, but I've been saying that forever now.

SSH

hmmm, you could make a module that RawDraws a black shadow the same width as a character's sprite and, say, 10% of a character's height and then sets it up automatically....

* SSH feels a module coming on....
12

monkey0506

There's no way to fill a DynamicSprite's non-transparent areas with a specific color is there? :-\

GarageGothic

#10
Quote from: monkey_05_06 on Mon 30/10/2006 17:10:40There's no way to fill a DynamicSprite's non-transparent areas with a specific color is there? :-\

No, but if you just want it to be black, you can assign the sprite to a character and use Character.Tint on that character - that's what I'm doing for my module.

Quote from: SSH on Mon 30/10/2006 16:45:19hmmm, you could make a module that RawDraws a black shadow the same width as a character's sprite and, say, 10% of a character's height and then sets it up automatically....

Yeah, this is the easiest way to do good top-down shadows. I don't really see why the height should be related to the character height though (but of course it should adjust to the character scale). In fact, the width should rather be calculated from the width of the character frame 90 degrees from the current (not sure this makes sense), multiplied by a perspective modifier.

monkey0506

Ehhhh....reserving characters? And presumably you couldn't get a copy of that as a tinted sprite? i.e., DynamicSprite.CreateFromExistingSprite wouldn't pick up on the tint?

I just don't like the idea of having to have a reserved character...oh well SSH's idea is probably better anyway.

SSH

You can RawSaveScreen, rawdraw a black circle on a magenta background, grab the sprite and then rawrestore screen. And you'd only need to do it infrequently, if you cached one shadow for each view.
12

gypsysnail

Wow many replies overnight! :D Thank you guys :). The problem with putting shadow in the character sprite would be when I transparentise the whole character image before exporting it to AGS, the shadow's white through shows from what was left of the white background and looks terrible. I think I will try some of your ideas guys and see which works for me. The shadow only need be under the character and possibly in some areas that change light, and I think I will use the region tinting for the objects that stand still in one room like the wagon, etc. My game will be high res type so would be able to take advantage of the transparency command. One idea, which was Barbarian's, to draw a shadow sprite and transparentise it, I would try this. I want to ask though that as I have a bird on exactly follow the character, how can I put multiply follows in along with the bird? Ashen, the height one would be great for the darkened areas, so the characters shadow could be seen against the wall - how would I implement that for particular rooms only and not every room? Again all great ideas guys! :) Thank you heaps and this thread would be useful for newbies in the future, I agree.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

SSH

12

SMF spam blocked by CleanTalk