Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2d shadowing functions

Author
Message
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 15th Oct 2007 23:44 Edited at: 15th Nov 2007 20:47
Greetings.
There was a thread awhile back that had some good 2d shadows. I just found it, and made it neater, and put it into some functions for multiple sprites.
So far, ive just made 3 functions, so here they are.



Im working on aving the sprites move, ive done it, but i havnt put it into function form yet.

EDIT: mm, this only works with circles...

EDIT: oh, this code was orig by BiggAdd


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 16th Oct 2007 02:31
a la question? Im a geek with 2d and could find this really useful. One question, which variables are for what? shadowedsprite and shadowimage are not very informative.

Your signature has been erased by a mod ... again!
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 19th Oct 2007 00:33
sorry.


for the SHADOWSPRITE function
light x-----x position of the light
light y-----y position of the light
shadowimage-the image you want to use for the shadow
shadownum---the sprite number you want for the shadowsprite
spritenum---the sprite number of the sprite your giving a shaodw to

for the MAKE LIGHT fuction
light x-----x position of the light
light y-----y position of the light
spritenum---the sprite number of the light
imagenum----the image number you want for the light sprite

for the MAKESHADOW function
shadowedsprite--the sprite number that you want to give shadow to
shadowspritenum-the sprite number for the shadow sprite
shadowimage-----the image number for the shadow


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 19th Oct 2007 00:37
I see. Can I see an exact picture of how this works?

Hi. I am sorry for being a random n00b. I got carried away and started posting to much. Then again I am a little kid.
This has been a public announcement by John- who wants a taco.
aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 19th Oct 2007 00:48
i used this then thought... eerie.

Hi. I am sorry for being a random n00b. I got carried away and started posting to much. Then again I am a little kid.
This has been a public announcement by John- who wants a taco.
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 21st Oct 2007 02:37
hehe, i wish it would support more complex images. i mean, you could probably get it so every shadow was the same image, but it wouldnt look that great.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 24th Oct 2007 01:10
Was this code from my "2D shadow" thing? with the pool balls?


Its finally here!
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 24th Oct 2007 04:24
uhhh. i dont hink so. the cide this game from had nothing to do will poll balls, but i guess it could have been a pool ball.
if it is, i wasnt tryin to steel, just notify and put them in a little easier to use format.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 10th Nov 2007 00:11
No don't worry about it, I wasn't accusing you of stealing, just I could make some improvements if you wanted. It was actually quite unfinished.

Here is a newer version I made.

Improvements :
1. Added code to allow adjustment of Light Height (up and down arrow keys)
2. Shadows now fade out when light is so far away
3. Added second shadow to bottom of spheres to give more depth

(See exe attatched)

I want to restart the coding so I can add multiple lights. Hopefully my plan should work.

cheers for re-igniting the coding spark!


Its finally here!

Attachments

Login to view attachments
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 10th Nov 2007 03:05
i used my function to have multiple lights, and to have the light fade away, but i might not have posted that version.

thanks for teh codes, if you could only figure out to make shadrws for other shapes.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 10th Nov 2007 12:25 Edited at: 10th Nov 2007 12:29
I'm trying to figure that one out.

(Was this the thread you were talking about? http://forum.thegamecreators.com/?m=forum_view&t=88802&b=1)


Its finally here!
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 10th Nov 2007 17:17
nooo. something very similar... but not with that much flare.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 10th Nov 2007 21:08
Are you sure? The code looks very similar.

My Code:
REM Distances and Angle Calculations
x1#=((X#-LightX#)*(X#-LightX#))+((Y#-LightY#)*(Y#-LightY#))
x1#=ABS(x1#)
x1#=sqrt(x1#)
y1#=Atanfull((LightX#-X#),(LightY#-Y#))

Code in your post:
X#=sprite x(shadownum)
Y#=sprite y(shadownum)
x1#=((X#-lightx)*(X#-lightx))+((Y#-lighty)*(Y#-lighty))
x1#=ABS(x1#)
x1#=sqrt(x1#)
y1#=Atanfull((lightx-X#),(lighty-Y#))


Its finally here!
aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 15th Nov 2007 01:12
maybe he got it from someone who got it from you?

alus.portbb.com go there.
[quote]A book. I hate books. book is stupid. I know that I need codes but I dont know the codes.[/quote} -zenicanin14 the stupidest user in the world.
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 15th Nov 2007 18:55
He said it was from a thread. I searched for other threads but mine is the only one.

I don't mean to sound like a ba***rd but in his first post he writes:
Quote: "There was a thread awhile back that had some good 2d shadows. I just found it, and made it neater"


Surely if he had just found that thread he would have posted who's thread it was.
But now he doesn't know where he got the code from???


Its finally here!
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 15th Nov 2007 20:44 Edited at: 15th Nov 2007 20:46
yea, your right, i should have, but i didnt. it wasnt YOUR thread, it might have been the same code, i really dont know. what do you want me to do?

EDIT:

ahhhh, ur right bid add, it wasnt the thread you posted a link to, but it was yours.
http://forum.thegamecreators.com/?m=forum_view&t=58715&b=4
sorry for that. really am. nice work. thank you. alot.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 17th Nov 2007 12:57 Edited at: 17th Nov 2007 12:58
Ah! Sorry about that. I didn't realize i made two threads about it.
I was wondering why you were putting it into a function when it was already in one, but now i see. Sorry.

My Bad.


Its finally here!
BiggAdd
Retired Moderator
19
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 17th Nov 2007 13:05 Edited at: 17th Nov 2007 13:06
This is the new code. (See attached)

Mouse controls light position
Up and Down arrows controls Light Height


Its finally here!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-20 01:56:33
Your offset time is: 2024-05-20 01:56:33