00:00
00:00
Newgrounds Background Image Theme

Mekatov just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Spiral Generator

4,189 Views | 6 Replies
New Topic Respond to this Topic

Spiral Generator 2005-06-23 09:09:15


Here's another taste on my next game. This is a toy you can unlock.
http://img92.echo.cx/my.php?image=spiral7ro.swf

Here's the code.

deg = 10;
spd = 50;
alp = 70;
wid = 1;
this.createEmptyMovieClip("clip", 1);
clip._x = 275;
clip._y = 200;
function frame() {
deg = Number(deg);
spd = Number(spd);
alp = Number(alp);
wid = Number(wid);
if (isNaN(deg)) {
deg = 10;
}
if (isNaN(spd)) {
spd = 10;
}
if (isNaN(alp)) {
alp = 100;
}
if (isNaN(wid)) {
wid = 1;
}
}
function generate() {
clip.clear();
angle = 0;
dist = 200;
speed = (spd/1000)+.9;
x = dist*Math.sin(angle*(Math.PI/180));
y = dist*Math.cos(angle*(Math.PI/180));
clip.moveTo(x, y);
clip.lineStyle(wid, 0x000000, alp);
while (dist>3) {
dist *= speed;
angle += deg;
x = dist*Math.sin(angle*(Math.PI/180));
y = dist*Math.cos(angle*(Math.PI/180));
clip.lineTo(x, y);
}
}

Put that in your frame. No need to edit the code.
Now all you need are 3 input text boxes. 1 for "deg", 1 for "spd" and 1 for "wid".
And 2 buttons. On one button, put
on(release){
generate()
}

And on the other put
on(release){
clip.clear()
}

POST YOUR BEST SPIRAL COMBONATIONS!

Response to Spiral Generator 2005-06-23 09:14:29


My best: Degrees: 91
Speed: 98

Response to Spiral Generator 2005-06-23 09:16:33


I ALMOST FORGOT!
You need one movie clip in the gray area with the code:

onClipEvent(enterFrame){
_parent.frame()
}

Response to Spiral Generator 2005-06-25 10:52:05


Anyone have comments?

Response to Spiral Generator 2005-06-25 10:59:33


it's pretty nice, it also makes stars when set to 910 degrees and 99 speed ;)

Response to Spiral Generator 2005-06-25 11:01:27


speed 30 degrees 999 is also nice ;)

Response to Spiral Generator 2005-07-01 17:05:41


Any degree over 180 is just a repeat of some degree from 1-180. Also, numbers that are the same distance from 90 (eg 45 and 135) have the same shape, but rotate in opposite directions.