00:00
00:00
Newgrounds Background Image Theme

lewdinitiative 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!

FOSS: string from mouse

1,652 Views | 12 Replies
New Topic Respond to this Topic

FOSS: string from mouse 2006-03-17 12:16:51


FOSS: main

i was bored so i decided to make an AS topic about somthing, but then i couldnt be bothered to explain the code so i decided to make a foss XD.
this is a toally api string that will follow the mouse its pretty cool try it out =P

var hyp:Number = 20;
// change this number to change the length of the string
var speed:Number = 15;
/* change this number to set the "gravity" put it to 0 and you can make somthing like string avoider!*/
_root.createEmptyMovieClip("point1", _root.getNextHighestDepth());
point1.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point2", _root.getNextHighestDepth());
point2.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point3", _root.getNextHighestDepth());
point3.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point4", _root.getNextHighestDepth());
point4.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point5", _root.getNextHighestDepth());
point5.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point6", _root.getNextHighestDepth());
point6.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point7", _root.getNextHighestDepth());
point7.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point8", _root.getNextHighestDepth());
point8.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point9", _root.getNextHighestDepth());
point9.moveTo(_root._xmouse, _root._ymouse);
_root.createEmptyMovieClip("point10", _root.getNextHighestDepth());
point10.moveTo(_root._xmouse, _root._ymouse);
_root.onEnterFrame = function() {
_root.clear();
point1._x = _root._xmouse;
point1._y = _root._ymouse;
Mouse.hide();
point2._y += speed;
point3._y += speed;
point4._y += speed;
point5._y += speed;
point6._y += speed;
point7._y += speed;
point8._y += speed;
point9._y += speed;
point10._y += speed;
_root.createEmptyMovieClip("line", 1);
lineStyle(5, 0x009900, 100);
angle = Math.atan2(point2._y-point1._y, point2._x-point1._x);
point2._x = point1._x+(Math.cos(angle)*hyp);
point2._y = point1._y+(Math.sin(angle)*hyp);
angle1 = Math.atan2(point3._y-point2._y, point3._x-point2._x);
point3._x = point2._x+(Math.cos(angle1)*hyp);
point3._y = point2._y+(Math.sin(angle1)*hyp);
angle2 = Math.atan2(point4._y-point3._y, point4._x-point3._x);
point4._x = point3._x+(Math.cos(angle2)*hyp);
point4._y = point3._y+(Math.sin(angle2)*hyp);
angle3 = Math.atan2(point5._y-point4._y, point5._x-point4._x);
point5._x = point4._x+(Math.cos(angle3)*hyp);
point5._y = point4._y+(Math.sin(angle3)*hyp);
angle4 = Math.atan2(point6._y-point5._y, point6._x-point5._x);
point6._x = point5._x+(Math.cos(angle4)*hyp);
point6._y = point5._y+(Math.sin(angle4)*hyp);
angle5 = Math.atan2(point7._y-point6._y, point7._x-point6._x);
point7._x = point6._x+(Math.cos(angle5)*hyp);
point7._y = point6._y+(Math.sin(angle5)*hyp);
angle6 = Math.atan2(point8._y-point7._y, point8._x-point7._x);
point8._x = point7._x+(Math.cos(angle6)*hyp);
point8._y = point7._y+(Math.sin(angle6)*hyp);
angle7 = Math.atan2(point9._y-point8._y, point9._x-point8._x);
point9._x = point8._x+(Math.cos(angle7)*hyp);
point9._y = point8._y+(Math.sin(angle7)*hyp);
angle8 = Math.atan2(point10._y-point9._y, point10._x-point9._x);
point10._x = point9._x+(Math.cos(angle8)*hyp);
point10._y = point9._y+(Math.sin(angle8)*hyp);
moveTo(point1._x, point1._y);
lineTo(point2._x, point2._y);
lineTo(point3._x, point3._y);
lineTo(point4._x, point4._y);
lineTo(point4._x, point4._y);
lineTo(point5._x, point5._y);
lineTo(point6._x, point6._y);
lineTo(point7._x, point7._y);
lineTo(point8._x, point8._y);
lineTo(point9._x, point9._y);
lineTo(point10._x, point10._y);
};

you can find a sample on the experiments page of my site its called "kinematics examle" (click my sig)

=O

Response to FOSS: string from mouse 2006-03-17 12:18:58


doesn't work, and it isn't very optimized

Response to FOSS: string from mouse 2006-03-17 12:19:43


i forgot to mention this, put the whole code on the frame

Response to FOSS: string from mouse 2006-03-17 12:21:02


At 3/17/06 12:18 PM, Inglor wrote: doesn't work, and it isn't very optimized

it does work ?! i just copy and pasted the code from here into a new document and it worked fine. try again.

Response to FOSS: string from mouse 2006-03-17 12:25:03


At 3/17/06 12:16 PM, -reelbigcheese- wrote: this is a toally api string that will follow the mouse its pretty cool try it out =P

you really should have done that with point objects, not movieclips.
it works, which is a plus, but not very well. nice try though...


BBS Signature

Response to FOSS: string from mouse 2006-03-17 12:27:09


At 3/17/06 12:25 PM, authorblues wrote:
At 3/17/06 12:16 PM, -reelbigcheese- wrote: this is a toally api string that will follow the mouse its pretty cool try it out =P
you really should have done that with point objects, not movieclips.

i dont know how to do point objects lol, i only started learning kinematics like 3 days ago

it works, which is a plus

yep !

but not very well.

no commment

nice try though...

thanks XD

Response to FOSS: string from mouse 2006-03-17 12:50:35


USE A FOR LOOP FFS >: (

Seriously, didn't I teach you for loops?

And AB, I think objects for this would be a waste of time =\


Sup, bitches :)

BBS Signature

Response to FOSS: string from mouse 2006-03-17 12:55:17


At 3/17/06 12:50 PM, -liam- wrote: USE A FOR LOOP FFS >: (
Seriously, didn't I teach you for loops?

lol yeah i thought about doing it that way, but its too late now meh!

Response to FOSS: string from mouse 2006-03-17 13:00:17


At 3/17/06 12:50 PM, -liam- wrote: And AB, I think objects for this would be a waste of time =\

i misworded that. a multidimensional array would be best.
you arent going to sit here and tell me that a bunch of MCs is the way to go...


BBS Signature

Response to FOSS: string from mouse 2006-03-17 13:19:47


At 3/17/06 01:00 PM, authorblues wrote:
At 3/17/06 12:50 PM, -liam- wrote: And AB, I think objects for this would be a waste of time =\
i misworded that. a multidimensional array would be best.

an array is an object

Response to FOSS: string from mouse 2006-03-17 13:44:11


AS2

var hyp:Number = 5;
var speed:Number = 15;
_root.createEmptyMovieClip("line", 0);
var points:Array = [];
for (var a = 0; a<50; a++) {
points.push([_xmouse, _ymouse]);
}
_root.onEnterFrame = function() {
points[0][0]=_root._xmouse, points[0][1]=_root._ymouse;
line.clear();
line.lineStyle(3, 0, 100);
line.moveTo(points[0][0], points[0][1]);
for (var a = 1; a<50; a++) {
points[a][1] += speed;
angle = Math.atan2(points[a][1]-points[a-1][1], points[a][0]-points[a-1][0]);
points[a][0] = points[a-1][0]+(Math.cos(angle)*hyp);
points[a][1] = points[a-1][1]+(Math.sin(angle)*hyp);
line.lineTo(points[a][0], points[a][1]);
}
};

AS3

package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Graphics;
import flash.events.*;
public class Kinematic extends Sprite {
public var hyp:int = 5;
public var speed:int = 15;
public var line:Shape = new Shape();
public var points:Array = [];
public function Kinematic() {
for (var a:int = 0; a<50; a++) {
points.push([mouseX, mouseY]);
}
addChild(line);
addEventListener(Event.ENTER_FRAME, enterFrame);
}
public function enterFrame(event:Event):void {
points[0][0]=mouseX, points[0][1]=mouseY;
line.graphics.clear();
line.graphics.lineStyle(3, 0x000000, 100);
line.graphics.moveTo(points[0][0], points[0][1]);
for (var a:int = 1; a<50; a++) {
points[a][1] += speed;
var angle:int = Math.atan2(points[a][1]-points[a-1][1], points[a][0]-points[a-1][0]);
points[a][0] = points[a-1][0]+(Math.cos(angle)*hyp);
points[a][1] = points[a-1][1]+(Math.sin(angle)*hyp);
line.graphics.lineTo(points[a][0], points[a][1]);
}
}
}
}

The AS3 one has a bug but I can't figure it out, anyone care to help an idiot out?


Sup, bitches :)

BBS Signature

Response to FOSS: string from mouse 2006-03-17 14:28:36


At 3/17/06 01:00 PM, authorblues wrote: i misworded that. a multidimensional array would be best.

A single dimensional array would be even better speed-wise but not structure-wise, seeing as an array is a complex data type.

Btw, that level 9 icon looks very sexy on you, almost makes me want one too. I barely have time for voting/depositing these days anyway.


BBS Signature

Response to FOSS: string from mouse 2006-03-17 16:59:21


At 3/17/06 01:44 PM, -liam- wrote: AS2

Very nice!


- - Flash - Music - Images - -

BBS Signature