PDA

View Full Version : sunrise


vulcanpimp
09-06-2003, 07:40 AM
I saw someone mention sunrize a short time ago and decided to have a crack at it. My ry involves the use of the radial gradient fill. Its actually very slow even on fast computers but it shows some of the effects that can be created. I made the radial fill very small to make it look like a sun. I put a simple cosine on the sun to create a glowing effect. Notice the x and y have to be recalculated when the size of the sun is changed.

the colors are a bit crumby but ...

http://www.geocities.com/hairybobby2000/fxsunrise.html

the codes on my site to make it easier to copy - just ctrl+a and ctrl+c.

vulcanpimp
09-10-2003, 10:41 AM
hello, I'm kinda feeling all alone in here.

so I know its not that good but I thought the idea was quite cute! at least a "that looks interesting would be nice".

or even a better luck next time.

I'm all alone......

vulcanpimp
09-12-2003, 08:29 AM
hello is anybody there


oh baaaaaaaaby baby...

how was I supposed to know..

how can you live without me ...da da dee


HIT me baby one more time

Hiiiiit me baby one more time


G I guess if I can't interest anyone with my code I could interest you with some of my singing.

Grifter
09-14-2003, 03:46 PM
um yeah, nearly 190 views and no replies is a bit harsh.

it is actually quite a good idea (i think), and i'll try and get round to having a shot at it if i can come up with some ideas. i'll try and put it up by wednesday (but i make no promises ;) ).

i think the reason no one has replied is because it's the weekend, and challenges usually get more attention midweek.

cheers
Grifter

McGiver
09-14-2003, 05:19 PM
hmm, I think I'll do something too, but at the moment I am (and was) kind of busy because of the new mx04 :D

vulcanpimp
09-15-2003, 06:08 AM
haven't really turned my attention to mx4 yet - still haven't got my head round version 6 yet. first impressions are though that its not all that an improvement AS wise.

McGiver
09-15-2003, 09:52 AM
I've also only the trial, but as I see it classes are a new aspect of flash. I wasn't very happy trying classes the first time, because i didn't really know what to do with them. I still think there are few thing you can do with classes, you couldn't do with as1, but they can make things easier! (I think I'll write a utorial when I'm more into that)
hope I'll find some time to do a surise too (not uninteresting at all, maybe a sunriseclass :D )

Grifter
09-18-2003, 02:42 PM
well, i said i would do something, and here it is:

/*
coded by: Grifter, recommended:30fps (or 60fps) with a black background
*/

//create a green box to represent the landscape
//highest depth of the 3 elements because it is on top
_root.createEmptyMovieClip("landscape", 3);
with(_root.landscape){
moveTo(0, 300);
lineStyle(1, 0x009900, 100);
lineTo(400, 300);
beginFill(0x009900,100);
lineTo(400,400);
lineTo(0,400);
lineTo(0,300);
endFill();
}
//create a blue box to represent the sky
//lowest depth so that the sun appears over it
_root.createEmptyMovieClip("sky", 1);
with(_root.sky){
moveTo(0, 300);
lineStyle(1, 0xff6600, 50);
lineTo(400, 300);
beginFill(0x4060ff,100);
lineTo(400,0);
lineTo(0,0);
lineTo(0,0);
endFill();
}
//create a yellow circle for the sun
_root.createEmptyMovieClip("sun", 2);
with(_root.sun){
//rather dubious method i came up with for drawing a circle - could be better, but i thought it'd do
moveTo(30*Math.sin(0), 30*Math.cos(0));
lineStyle(3, 0xffff33, 100);
for(i=0; i<48; i++){
lineTo(30*Math.sin(i), 30*Math.cos(i));
}
}
//function used to give the sun it's circular motion
//the same function could be used to move a moon about behind the sun (add 180 to the moon's theta)
//r is the radius of the circle
circularPath = function(mc, r, theta, cx, cy){
mc._x = cx - (r*Math.sin((theta*(Math.PI/180))));
mc._y = cy - (r*Math.cos((theta*(Math.PI/180))));
}
//define what happens every frame
//the sun moves every frame, and the skies alpha is adjusted to represent day & night
_root.onEnterFrame = function(){
sun.j++;
circularPath(sun, 150, -sun.j+90, 200, 300);
sky._alpha = (Math.sin(sun.j*(Math.PI/180))+0.5)*100;
}

wasn't sure if there was a line limit, it's around 40 without the comments (and i'm sure there's ways of reducing it as well).
if someone wants to add a moon to it, you're welcome (it shouldn't be too difficult because you can apply the circularPath function to that as well).
enjoy!
Grifter

dzy2566
09-18-2003, 03:01 PM
Very toon-town. I like it.

McGiver
09-18-2003, 05:17 PM
Nothing too impressive, I just saw Grifter's (which looks cool, by the way) and remembered that I wanted to do one over the weekend too (sorry I didn't) and recognized, I got time at the moment. prehaps I will do something better (or at least add some shadow throwing trees to this one later)

_root.onEnterFrame = function() {
i += 5;
_root.skyx = Math.cos(i/200)*700+300;
_root.skyy = Math.sin(i/100)*200+200;
_root.flooralpha = 100-Math.sin(i/100+Math.PI*3/2)*50;
mycolor = Math.sin(i/100+Math.PI*3/2)*154+102;
_root.colorbright = parseInt("0x00"+mycolor.toString(16)+"00");
_root.colorheight = Math.sin(i/50+Math.PI*3/2)*500;
_root.colorx = Math.cos(i/200)*700+300;
myplanet = _root.createEmptyMovieClip("myplanet", 123);
myplanet.beginGradientFill("radial", [_root.colorbright, 0x006600], [_root.flooralpha, _root.flooralpha], [0, 250], {matrixType:"box", x:(_root.colorx-(200-_root.colorheight/5)/2), y:(200-_root.colorheight/1.6), w:(200-_root.colorheight/5), h:_root.colorheight, r:(45/180)*Math.PI});
myplanet.moveTo(0, 250);
myplanet.lineTo(550, 250);
myplanet.lineTo(650, 400);
myplanet.lineTo(-100, 400);
myplanet.lineTo(0, 250);
myplanet.endFill();
mysky = _root.createEmptyMovieClip("mysky", 124);
mysky.beginGradientFill("radial", [0xffff00, 0xB5E3FF, 0x00ccFF, 0x0099FF, 0x003366], [100, 100, 100, 100, 100], [10, 30, 90, 160, 250], {matrixType:"box", x:(_root.skyx-350), y:(_root.skyy-350), w:700, h:700, r:(45/180)*Math.PI});
mysky.lineTo(550, 0);
mysky.lineTo(550, 250);
mysky.lineTo(0, 250);
mysky.lineTo(0, 0);
mysky.endFill();
}; (the 2 sunrises are intended!)

vulcanpimp
09-19-2003, 08:10 AM
say mcgiver

and whats wrong with two sunrises. Some planets actually have two suns. They sort of revolve around both. (sounds like a good idea for a maths challenge)

McGiver
09-19-2003, 09:22 AM
Lol :p well i don't think there are planets with two suns ( the gravity would make both circle around each other and the energy would burn any planet), I just wasn't sure on which side the sun goes up (I think left side on the northern half and right on the australian side)
+ this looks better than my try to make it go a circle (i like the loop)

McGiver
09-19-2003, 10:05 AM
just a little change, i fell in love with those little people!

_root.onEnterFrame = function() {
i += 5;
_root.skyx = Math.cos(i/200)*700+300;
_root.skyy = Math.sin(i/100)*200+200;
_root.flooralpha = 100-Math.sin(i/100+Math.PI*3/2)*50;
mycolor = Math.sin(i/100+Math.PI*3/2)*154+102;
_root.colorbright = parseInt("0x00"+mycolor.toString(16)+"00");
_root.colorheight = Math.sin(i/50+Math.PI*3/2)*500;
_root.colorx = Math.cos(i/200)*700+300;
myplanet = _root.createEmptyMovieClip("myplanet", 123);
myplanet.beginGradientFill("radial", [_root.colorbright, 0x006600], [_root.flooralpha, _root.flooralpha], [0, 250], {matrixType:"box", x:(_root.colorx-(200-_root.colorheight/5)/2), y:(200-_root.colorheight/1.6), w:(200-_root.colorheight/5), h:_root.colorheight, r:(45/180)*Math.PI});
myplanet.moveTo(0, 250);
myplanet.lineTo(550, 250);
myplanet.lineTo(650, 400);
myplanet.lineTo(-100, 400);
myplanet.lineTo(0, 250);
myplanet.endFill();
mysky = _root.createEmptyMovieClip("mysky", 124);
mysky.beginGradientFill("radial", [0xffff00, 0xB5E3FF, 0x00ccFF, 0x0099FF, 0x003366], [100, 100, 100, 100, 100], [10, 30, 90, 160, 250], {matrixType:"box", x:(_root.skyx-350), y:(_root.skyy-350), w:700, h:700, r:(45/180)*Math.PI});
mysky.lineTo(550, 0);
mysky.lineTo(550, 250);
mysky.lineTo(0, 250);
mysky.lineTo(0, 0);
mysky.endFill();
mypeople = _root.createEmptyMovieClip("people", 456);
mypeople._x = 470;
mypeople._y = 340;
mypeople.beginFill(0x000000, 90);
mypeople.lineStyle(2, 0x333333, 80);
mypeople.lineTo(0, -6);
mypeople.curveTo(-4, -9, 0, -14);
mypeople.curveTo(-2, -16, 3, -18);
mypeople.curveTo(6, -16, 5, -14);
mypeople.lineTo(9, -8);
mypeople.lineTo(13, -13);
mypeople.curveTo(12, -15, 15, -17);
mypeople.curveTo(18, -15, 17, -13);
mypeople.curveTo(19, -10, 17, -6);
mypeople.lineTo(17, 0);
mypeople.lineTo(13, 0);
mypeople.lineTo(13, -8);
mypeople.lineTo(9, -4);
mypeople.lineTo(5, -9);
mypeople.lineTo(4, -6);
mypeople.lineTo(4, 0);
mypeople.lineTo(0, 0);
mypeople.endFill();
mypeople.lineStyle(10, 0x000000, 70-_root.flooralpha);
mypeople.moveTo(2, 1);
mypeople.lineTo((mypeople._x+2*5-_root.skyx)*(mypeople._y-250)/(400-mypeople._y+250), 400-mypeople._y);
mypeople.moveTo(16, 1);
mypeople.lineTo((mypeople._x+16*5-_root.skyx)*(mypeople._y-250)/(400-mypeople._y+250), 400-mypeople._y);
mypeople.lineStyle(2, 0xff0000, _root.flooralpha/2-50);
mypeople.moveTo(9, -22);
mypeople.curveTo(-2, -40, 9, -33);
mypeople.curveTo(22, -40, 9, -22);
};

vulcanpimp
09-20-2003, 06:19 AM
well I've got to say you are wrong mcGiver, there are planets with two suns - it was on Startrek(or something like that) , so it must be true(mmm).

say mcGiver, People are good but birdies are good too

_root.createEmptyMovieClip("grad", 211);
with (_root.grad) {
lineStyle(5, 0xffffff, 100);
p1x = [26, -7];
p1y = [103, 97];
p2x = [11, -20];
p2y = [73, 78];
p3x = [-5, -45];
p3y = [95, 97];
MoveTo(26, 103);
curveTo(11, 73, -5, 95);
curveTo(-20, 78, -45, 97);
_x = 44;
_y = 12;
}
_root.onEnterFrame = function() {
i += 5;
_root.skyx = Math.cos(i/200)*700+300;
_root.skyy = Math.sin(i/100)*200+200;
_root.flooralpha = 100-Math.sin(i/100+Math.PI*3/2)*50;
mycolor = Math.sin(i/100+Math.PI*3/2)*154+102;
_root.colorbright = parseInt("0x00"+mycolor.toString(16)+"00");
_root.colorheight = Math.sin(i/50+Math.PI*3/2)*500;
_root.colorx = Math.cos(i/200)*700+300;
myplanet = _root.createEmptyMovieClip("myplanet", 123);
myplanet.beginGradientFill("radial", [_root.colorbright, 0x006600], [_root.flooralpha, _root.flooralpha], [0, 250], {matrixType:"box", x:(_root.colorx-(200-_root.colorheight/5)/2), y:(200-_root.colorheight/1.6), w:(200-_root.colorheight/5), h:_root.colorheight, r:(45/180)*Math.PI});
myplanet.moveTo(0, 250);
myplanet.lineTo(550, 250);
myplanet.lineTo(650, 400);
myplanet.lineTo(-100, 400);
myplanet.lineTo(0, 250);
myplanet.endFill();
mysky = _root.createEmptyMovieClip("mysky", 124);
mysky.beginGradientFill("radial", [0xffff00, 0xB5E3FF, 0x00ccFF, 0x0099FF, 0x003366], [100, 100, 100, 100, 100], [10, 30, 90, 160, 250], {matrixType:"box", x:(_root.skyx-350), y:(_root.skyy-350), w:700, h:700, r:(45/180)*Math.PI});
mysky.lineTo(550, 0);
mysky.lineTo(550, 250);
mysky.lineTo(0, 250);
mysky.lineTo(0, 0);
mysky.endFill();
grad._yscale = 27+(12*Math.cos(0.01754*(i*3)));
grad._xscale = 25+(5*Math.cos(0.01754*(i)));
grad._x += 1;
};

Jon B
09-21-2003, 05:22 PM
Hi guys,

Looking kinda cool, some clever scripting going on there (not flashpalayer 7 or AS2 compliant tho - try publishing it with mx 2004 and you'll see)

I'm a very poor coder and can't add anything to this, but I have a few suggestions:

1. you could make more of the shadows of items on the stage (a cool shadow engine would be good)

2. you could make the sun look slightly less like a flashlight and more even spread across the screen.

3. you could incorporate alpha clouds and adjust the colour of teh sun to orangey as it gets near the horizon.

4. you could tie the position of the sun in with the system time on the client computer.

5. you could tie the whole system into a weather web service and dynamically control the position of the sun and weather effects like snow / rain / hail / wind / even the seasons!.

6. you could build a whole little world that evolves and has real day's and night's and characters with AI - it could run off the server time and people could come and check up on how the flash village was evolving.

7. you could create an omnipotent controller script that acts as ultimate god over the little flash world.

8. you could expand your god script into a standalone superior force and use it take over the world!

Well, there is just a few ideas to keep you going over the next day or so.

McGiver
09-21-2003, 06:08 PM
@ Jon B: well I'll give it a try....

...15 minutes later...
damn it! Ok, I did it, but the script was bigger than 25 lines (28 lines+credits) plus the god engine had some errors, for example it started to behave like my ex-girlfriend (always traced something like "you have to choose between me and this win xp. That was one bug too much..."), so I abandoned the script :D

well you don't have to be a good scripter or to impress someone! just give it a try (-->the best way to improve your as
(ahhmm...as=Actionscript, and not the other thing) is to write scripts and listen to what others think about them.

Jesse
09-23-2003, 05:16 AM
Fantastic base engine for some amazing entries McGiver. Great work to all!

Jojodi
04-11-2004, 10:15 AM
OMG!!! lmfao that little schpeil with the god script and such was f**ckin jilarious.. i nearly fell out of the chair! thanks for the good laugh. ("15 minutes later..." lol)

JerryScript
05-02-2004, 03:56 AM
Lol :p well i don't think there are planets with two suns ( the gravity would make both circle around each other and the energy would burn any planet), I just wasn't sure on which side the sun goes up (I think left side on the northern half and right on the australian side)
+ this looks better than my try to make it go a circle (i like the loop)

Actually, they have discovered an actual planet in a binary star system: :D

http://www.cnn.com/2002/TECH/space/10/09/binary.planet/

pom
05-02-2004, 07:55 AM
Just discovered this, and I have to say I'm impressed by McGiver's entry :cool: Nice job!

CyanBlue
05-02-2004, 11:13 AM
Can somebody do the editing on the posts to disable the smilies in the code??? :(

McGiver
05-02-2004, 01:06 PM
I edited the smilies out, but and took a look what I did there, and I have to say, it was quite bad :(
even the math isn't accurate

CyanBlue
05-02-2004, 06:27 PM
Huh, 'quite bad'??? You are kidding, right??? I don't even try to understand what you have in there... The math stuff is trying to break my brain piece by piece... I don't know how you guys manage all that... :)

sneeuwitje
05-03-2004, 10:24 PM
like to contribute, but having a hard time to reference ... how come i see nothing but still-[pretty]-pictures (or worse) when running all code in this thread ??? ... on Mac ...