Display shadows with moving lightsources

Started by pabloppp, Mon 12/03/2012 12:27:50

Previous topic - Next topic

pabloppp

I've recently posted a Demo of a game in wich I'm working, you can see it here:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=45547.0

In the game I want shadows to be displayed, If you play the demo you can see a poor attempt to do so. It's indeed a poor solution for the effect I wanted.

I wanted the light sources to be able to move (for example, the main character carrying a lantern)
I visited this post http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37906.0 but I don't want the background to change, I want the characters to be shown only in light areas (As i did in my demo using Walkbehinds)

I don't know if it's possible but if it's not, maybe there could be a similar way to find the effect I want.

I found another problem, I'm not sure if I should create a different topic but, the problem is when I try to play my game in my android powered phone with the andoid AGS port.

The game runs well without music but when I turn the music On, it starts to go really slow and laggy, I'm using MP3, maybe that's the problem.

Khris

I took a shot at this:

http://db.tt/gDR7yb5r (just a demo!)

WASD to move lamp, Space to turn flickering lantern on/off.

Video:
http://www.youtube.com/watch?v=tH-pPFi-WUM

If you are interested I'll send you the module via PM, I don't want to release it to the public in its current state.

pabloppp

Wow, really impressive, In fact, I was not very worried about modifying the shadow as in my game the main character can only move horizontally (I only need to flip the shadow when the light is coming from the other side). I'd love to try the module but I have a few questions:
Would I be able to set the shadow as a character or an object so I'll be able to interact directly with it?
Can I make the shadow ONLY show in the zone that is directly lighted? (The yellow circle in your Demo)
Thank you very much!

Khris

In that case my module won't be of much use.

What you need should be a lot easier to achieve; use a character for the shadow and cover it with another character set to not clickable (to cut off the parts of the shadow character outside illuminated areas).
Since you want moving light sources, the latter character's sprite has to be redrawn every loop.
That way you can emulate changing a walkbehind during the game.

Draw the room background with all of the floor being illuminated, then draw a second, shadow version and import it as a sprite.

In repeatedly_execute, start out by grabbing the dark background sprite, then draw holes on it using the coordinates of the light sources. Just set Game.GetColorFromRGB(255, 0, 255) ("magic pink") as the DrawingColor.

Assign this DynamicSprite to the shadow character using Game.GetViewFrame.

I'd also reposition the shadow character in repeatedly execute by directly changing its coordinates (as opposed to using the FollowCharacter command).

pabloppp

I'm not sure I understand what you are proposing (English is not my native language and I'm quite new to AGS)
In my demo, i don't use the followCharacter, I directly change de coordinates of the shadow, and I want the light to have a different shape (not round, more like a cone).
I'll try to guess what are you proposing and see if it works, thank you very much :D

SMF spam blocked by CleanTalk