Age/Gender: n/a, Male
Location: New Mexico
Job: Student
Rusty Air.
Newgrounds Stats
Whistle Status: Garbage
Exp. Points: 590 / 710
Exp. Rank #: 64,306
Voting Pow.: 5.00 votes
BBS Posts: 671 (0.94 per day)
Flash Reviews: 2
Music Reviews: 0
Trophies: 0
Stickers: 0
WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.
Click - Add new point.
Scroll - Increase/Decrease distances.
Ctrl - Delete oldest point
Shift - Delete newest point.
It took me a while, but I studied up on "Node Code" and came out pretty good. I'm trying to find a way to turn it into a game, but I don't want to get distracted. Doing this in C++ for performance increase is a possibility.
_______________________
stage.quality = "LOW";
var xlimit:Number = stage.stageWidth;
var ylimit:Number = stage.stageHeight;
var points:Array = new Array();
var i:int = 0;
var j:int = 0;
var gf:Number = .2;
var fr:Number = .1;
var sf:Number = .009;
var bn:Number = -.8;
var md:Number = 110;
stage.addEventListener(MouseEvent.MOUS E_DOWN, mouseDown);
function mouseDown(evnt:MouseEvent):void {
var point:Array = new Array(new Point(mouseX,mouseY),0,0);
points.push(point);
}
stage.addEventListener(Event.ENTER_FRA ME, enterFrame);
function enterFrame(evnt:Event):void {
graphics.clear();
graphics.lineStyle(1,0xFFFFFF,.07);
for (i=0; i<points.length; i++) {
var p1:Array = points[i] as Array;
p1[1] -= fr*Math.cos(Math.atan2(p1[2], p1[1]));
p1[2] -= fr*Math.sin(Math.atan2(p1[2], p1[1]));
p1[2] += gf;
p1[0].x += p1[1];
p1[0].y += p1[2];
if (p1[0].x>xlimit) {
p1[0].x = xlimit;
p1[1] *= bn;
}
if (p1[0].y>ylimit) {
p1[0].y = ylimit;
p1[2] *= bn;
}
if (p1[0].x<0) {
p1[0].x = 0;
p1[1] *= bn;
}
for (j=i+1; j<points.length; j++) {
var p2:Array = points[j] as Array;
var dx:Number = p2[0].x - p1[0].x;
var dy:Number = p2[0].y - p1[0].y;
if (Math.sqrt(dx*dx+dy*dy) < md) {
p1[1] -= dx*sf;
p1[2] -= dy*sf;
p2[1] += dx*sf;
p2[2] += dy*sf;
}
}
}
for (i=0; i<points.length; i++) {
p1 = points[i] as Array;
for (j=i+1; j<points.length; j++) {
p2 = points[j] as Array;
graphics.moveTo(p1[0].x, p1[0].y);
graphics.lineTo(p2[0].x, p2[0].y);
}
}
}
stage.addEventListener(KeyboardEvent.K EY_DOWN, keyDown);
function keyDown(evnt:KeyboardEvent):void {
if (evnt.keyCode == 17) {
points.splice(0,1);
}
if (evnt.keyCode == 16) {
points.splice(points.length-1,1);
}
}
stage.addEventListener(MouseEvent.MOUS E_WHEEL, mouseRoll);
function mouseRoll(evnt:MouseEvent):void {
md += evnt.delta;
}
Some big ones. I've switched from Flash 8 to CS3, this means I will now be using AS3. For those of you that don't know, AS3 is VERY different from AS2. It's so different I was set back to square 1 when I first switched. ("Uh, what happened to onEnterFrame?").
I'm progressing very quickly, but I'm still not as fluent as I was with AS2, so the flash that I upload may be simpler. If your using AS2 and are trying to use my Source/Script, you're just out of luck.
On a side note, progress with my game is going very smooth. Check it out. You'll notice a lot more features along with a laser sight. I've decided that bullets will be instantaneous, so that will solve most previous difficulties with the control scheme. Because I'm nice, I'll let you guys have a look at the script currently. It's not much, but damn it's functional:
var inc:int = 0;
var stalker1s:Array = new Array();
var stalker2s:Array = new Array();
//User-Defined Functions.
function addStalker1(xcor:Number,ycor:Number) {
var stalker1:stalker1_link = new stalker1_link();
stalker1s.push(stalker1);
stage.addChild(stalker1);
with (stalker1) {
x = xcor;
y = ycor;
}
}
function addStalker2(xcor:Number,ycor:Number) {
var stalker2:stalker2_link = new stalker2_link();
stalker2s.push(stalker2);
stage.addChild(stalker2);
with (stalker2) {
x = xcor;
y = ycor;
}
}
addStalker1(0,0);
addStalker1(67,87);
addStalker2(0,0);
addStalker2(67,45);
//Player's Variables.
var xc1:Number = 0;
var yc1:Number = 0;
var xc2:Number = 0;
var yc2:Number = 0;
var dx:Number = 0;
var dy:Number = 0;
var vx:Number = 0;
var vy:Number = 0;
var it:Number = .5;
var sp:Number = 60;
var fr:Number = .99;
var glow_inc:Number = 0;
var laser_flag:Boolean = false;
var laser_x:Number = 0;
var laser_y:Number = 0;
var has_clicked:Boolean = false;
var sling_line:Sprite = new Sprite();
stage.addChild(sling_line);
var laser_sight:Sprite = new Sprite();
stage.addChild(laser_sight);
stage.addEventListener(MouseEvent.MOUS E_DOWN, mouseDown);
function mouseDown(evnt:MouseEvent):void {
has_clicked = true;
xc1 = root.mouseX;
yc1 = root.mouseY;
}
stage.addEventListener(MouseEvent.MOUS E_UP, mouseUp);
function mouseUp(evnt:MouseEvent):void {
has_clicked = false;
vx = dx/sp+vx*it;
vy = dy/sp+vy*it;
sling_line.graphics.clear();
laser_sight.graphics.clear();
}
stage.addEventListener(Event.ENTER_FRA ME, enterFrame);
function enterFrame(evnt:Event):void {
//Enemy's Actions.
for (inc = 0; inc<stalker1s.length; inc++) {
var stalker1:MovieClip = stalker1s[inc];
stalker1.x += 2*(player.x-stalker1.x)/Math.sqrt((pla yer.x-stalker1.x)*(player.x-stalker1.x )+(player.y-stalker1.y)*(player.y-stal ker1.y));
stalker1.y += 2*(player.y-stalker1.y)/Math.sqrt((pla yer.x-stalker1.x)*(player.x-stalker1.x )+(player.y-stalker1.y)*(player.y-stal ker1.y));
stalker1.rotation = Math.atan2(player.y-stalker1.y, player.x-stalker1.x)*180/Math.PI;
}
for (inc = 0; inc<stalker2s.length; inc++) {
var stalker2:MovieClip = stalker2s[inc];
stalker2.x += 3*(player.x-stalker2.x)/Math.sqrt((pla yer.x-stalker2.x)*(player.x-stalker2.x )+(player.y-stalker2.y)*(player.y-stal ker2.y));
stalker2.y += 3*(player.y-stalker2.y)/Math.sqrt((pla yer.x-stalker2.x)*(player.x-stalker2.x )+(player.y-stalker2.y)*(player.y-stal ker2.y));
stalker2.rotation = Math.atan2(player.y-stalker2.y, player.x-stalker2.x)*180/Math.PI;
}
//Player's Actions.
vx *= fr;
vy *= fr;
if (Math.sqrt(vx*vx+vy*vy)<.3) {
vx = 0;
vy = 0;
}
player.x += vx;
player.y += vy;
xc2 = root.mouseX;
yc2 = root.mouseY;
if (has_clicked == true) {
dx = xc1-xc2;
dy = yc1-yc2;
with (sling_line) {
graphics.clear();
graphics.lineStyle(1,0xFFFFFF,1/Math.p ow((dx*dx+dy*dy),.25)+.1);
graphics.moveTo(xc1, yc1);
graphics.lineTo(xc2, yc2);
}
with (laser_sight) {
graphics.clear();
graphics.lineStyle(1, 0xDD2222, .7);
graphics.moveTo(player.x, player.y);
}
laser_flag = false;
laser_x = player.x;
laser_y = player.y;
while (laser_flag == false) {
laser_x += 3*Math.cos(Math.atan2(dy, dx));
laser_y += 3*Math.sin(Math.atan2(dy, dx));
if (laser_x<0 || laser_y<0 || laser_x>stage.stageWidth || laser_y>stage.stageHeight) {
laser_flag = true;
}
for (inc=0; inc<stalker1s.length; inc++) {
stalker1 = stalker1s[inc];
if (stalker1.hitTestPoint(laser_x,laser_y ,true)) {
laser_flag = true;
}
}
for (inc=0; inc<stalker2s.length; inc++) {
stalker2 = stalker2s[inc];
if (stalker2.hitTestPoint(laser_x,laser_y ,true)) {
laser_flag = true;
}
}
}
laser_sight.graphics.lineTo(laser_x, laser_y);
}
player.rotation = Math.atan2(dy, dx)*180/Math.PI;
if (player.x < 0) {
player.x = 0;
vx *= -.8;
}
if (player.y < 0) {
player.y = 0;
vy *= -.8;
}
if (player.x>stage.stageWidth) {
player.x = stage.stageWidth;
vx *= -.8;
}
if (player.y>stage.stageHeight) {
player.y = stage.stageHeight;
vy *= -.8;
}
var glow:GlowFilter = new GlowFilter(0xABBBBA,1,Math.sin(glow_in c)*2+12,Math.sin(glow_inc)*2+12,1,5,fa lse,true);
player.filters = [glow];
glow_inc += .2;
}
I won't be uploading anything new for a while. This project is too ambitious. Feel free to leave any comments.
EDIT FEBRUARY 15, 2008.
I was going to post in a new page, but I'll think from now on I'll just constantly update this page. I stayed home today, and worked on this:
YOU CAN SHOOT AND KILL THEM NAO.
Space to shoot.
EDIT FEBRUARY 22, 2008.
Progress is slowing. Schoolwork is piling up so I've been very busy, not to mention I have the attention span of a mosquito. I've scripted several new enemies, but you only see 2 for spoiler reasons. I'm also simultaneously working on another project. I've called it "MD" for brevity, and It should be done in about 3 weeks.
Comment if you'd like.
EDIT MARCH 1, 2008
Things look bright. I'm spending the weekend In Phoenix so I've got all the time in the world. I'm also designing the shell of the flash, and it's looking great.
EDIT MARCH 8, 2008
I've been working on some other stuff at the moment and Flash keeps keeps giving me null object reference warnings, so It's been getting tougher. I started a little journal to keep my ideas, so I don't forget.
Updated: 03/08/08 4:51 AM 4 comments | Log in to comment! | Share this!Pretty strait-forward. I made snow; complete with glowing.
____________________
Script:
In the main frame panel:
var pressing:Boolean = true;
var timer:Number = 0;
var gf:Number = .25;
var fr:Number = .8;
function onEnterFrame():Void {
timer++;
if (timer%15 == 0) {
var dot:MovieClip = attachMovie("dot", "dot"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
dot._x = Math.random()*Stage.width;
}
}
function onMouseDown():Void {
pressing = !pressing;
}
In the "white dot" MovieClip :
import flash.filters.GlowFilter;
var vx:Number = 0;
var vy:Number = 0;
function onEnterFrame():Void {
var glow:GlowFilter = new GlowFilter(0xFFFFFF, 1, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, 3, 3, false, _root.pressing);
this.filters = [glow];
vy += _root.gf;
vx *= _root.fr;
vy *= _root.fr;
_x += vx;
_y += vy;
if (_y>Stage.height) {
removeMovieClip(this);
}
}
____________________
Explanation:
var pressing:Boolean = true;
var timer:Number = 0;
Initiatives.
var gf:Number = .25;
var fr:Number = .8;
Physics control. I used a single, _root variable instead of one in every "snowflake" to reduce lag.
function onEnterFrame():Void {
timer++;
if (timer%15 == 0) {
var dot:MovieClip = attachMovie("dot", "dot"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
dot._x = Math.random()*Stage.width;
}
}
Creates a "snowflake" every 15 frames.
function onMouseDown():Void {
pressing = !pressing;
}
Determines if you have clicked.
import flash.filters.GlowFilter;
Sets up glow effect.
var vx:Number = 0;
var vy:Number = 0;
Init.
function onEnterFrame():Void {
var glow:GlowFilter = new GlowFilter(0xFFFFFF, 1, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, 3, 3, false, _root.pressing);
this.filters = [glow];
Adds the glow and sets the glow amount based on how far the mouse is from the "flake".
vy += _root.gf;
vx *= _root.fr;
vy *= _root.fr;
Gravity and friction.
_x += vx;
_y += vy;
Moving the MovieClip.
if (_y>Stage.height) {
removeMovieClip(this);
}
Deletes the MovieClip if it is below the screen.
}
Copyright 2008 Ryan Keathley.
Updated: 01/31/08 10:53 PM 2 comments | Log in to comment! | Share this!A simple throwing engine meant to mimic something like ball physics.
NOTE: I based this engine off of Keith Peter's Engine. However, his engine wasn't nearly as dynamic as my revised version.
Throwing Engine.
Source.
____________________
Script:
Placed inside the ball MovieClip. Frame actions.
var dragging = false;
var left:Number = 0;
var right:Number = Stage.width;
var bottom:Number = Stage.height;
var thickness:Number = (_height+_width)/4;
var vx:Number = 0;
var vy:Number = 0;
var vt:Number = 0;
var maxSpeed:Number = 10;
var throwSpeed:Number = .9;
var friction:Number = .999;
var bounce:Number = -.9;
var gravity:Number = .4;
function onPress():Void {
dragging = true;
this.startDrag();
}
function onRelease():Void {
dragging = false;
this.stopDrag();
}
function onReleaseOutside():Void {
dragging = false;
this.stopDrag();
}
function onEnterFrame():Void {
if (dragging) {
vx = (_x-oldX)*throwSpeed;
vy = (_y-oldY)*throwSpeed;
oldX = _x;
oldY = _y;
} else {
_rotation += vx*360/(thickness*2*Math.PI);
vy += gravity;
vx *= friction;
vy *= friction;
vt = Math.sqrt(vx*vx+vy*vy);
if (vt>maxSpeed) {
vx = vx*maxSpeed/vt;
vy = vy*maxSpeed/vt;
}
_x += vx;
_y += vy;
if (_y+thickness>bottom) {
_y = bottom-thickness;
vy *= bounce;
}
if (_x+thickness>right) {
_x = right-thickness;
vx *= bounce;
}
if (_x-thickness<left) {
_x = thickness;
vx *= bounce;
}
}
}
____________________
Setting up the .fla:
Create your ball. Make sure it's completely round and even, or else it will look odd. Turn it into a symbol, and add the script to the MovieClip's frame actions. You may adjust the variable, I tried hard to make it very dynamic.
____________________
Explanation:
var dragging = false;
Initiative....
var left:Number = 0;
var right:Number = Stage.width;
var bottom:Number = Stage.height;
Sets the "walls" where the ball will bounce from.
var thickness:Number = (_height+_width)/4;
Sets the thickness of the ball. I could've just used "_height/2" or "_width/2", but I wanted it to be perfect.
var vx:Number = 0;
var vy:Number = 0;
var vt:Number = 0;
Moar initiatives. (I should really just group these together.)
var maxSpeed:Number = 10;
var throwSpeed:Number = .9;
maxSpeed sets how fast the ball is allowed to go. If you don't want a limited speed just remove the "if(vt>maxSpeed)" part and this variable; or you could just be lazy and set it to something high like 999999.
var friction:Number = .999;
var bounce:Number = -.9;
var gravity:Number = .4;
Amount of air friction, bounciness, and force of gravity, respectively.
function onPress():Void {
dragging = true;
this.startDrag();
}
function onRelease():Void {
dragging = false;
this.stopDrag();
}
function onReleaseOutside():Void {
dragging = false;
this.stopDrag();
}
Determines if you are pressing the ball, starts and stops dragging, and uses "dragging" as a flag.
function onEnterFrame():Void {
if (dragging) {
vx = (_x-oldX)*throwSpeed;
vy = (_y-oldY)*throwSpeed;
oldX = _x;
oldY = _y;
Updates vx and vy for when you release.
} else {
_rotation += vx*360/(thickness*2*Math.PI);
Dynamic rolling based on the size of the ball. I know, I'm awesome.
vy += gravity;
vx *= friction;
vy *= friction;
Applies gravity and air friction
vt = Math.sqrt(vx*vx+vy*vy);
if (vt>maxSpeed) {
vx = vx*maxSpeed/vt;
vy = vy*maxSpeed/vt;
}
Determines the total velocity and applies limits.
_x += vx;
_y += vy;
Moves the ball...
if (_y+thickness>bottom) {
_y = bottom-thickness;
vy *= bounce;
}
if (_x+thickness>right) {
_x = right-thickness;
vx *= bounce;
}
if (_x-thickness<left) {
_x = thickness;
vx *= bounce;
}
Applies the walls and bounce.
}
}
Copyright 2008 Ryan Keathley.
Updated: 01/31/08 10:52 PM 1 comment | Log in to comment! | Share this!For this project I decided to retun to my olden days of Kinematics and Physics. I decided to try to replicate a trampoline, and the project was a dashing success. On we go shall we?
____________________
Setting up the flash:
Make a small dot (for aesthetic purposes, although it can be anything.) and turn it into MovieClip. Remove the MovieClip from the stage so that it exists only in the library. Open up the MovieClip's properties window from the library and give it an linkage name of "dot". Once again, change the frame rate to something practical (25-45).
____________________
Script:
In the main frame panel:
var spring_loc:Number = 300;
var pressing:Boolean = false;
var dot:MovieClip = attachMovie("dot", "dot", getNextHighestDepth());
dot._x = Stage.width/2;
dot._y = 50;
function onMouseDown():Void {
pressing = true;
}
function onMouseUp():Void {
pressing = false;
}
In the frame actions (not ClipEvents) of the dot MovieClip. *Note: This may be accessed by double clicking the MovieClip in the library, and opening the Actios panel*
function mvx() {
x2 = _root._xmouse;
xvel = x2-x1;
x1 = x2;
return xvel;
}
function mvy() {
y2 = _root._ymouse;
yvel = y2-y1;
y1 = y2;
return yvel;
}
var vx:Number = 0;
var vy:Number = 0;
var gf:Number = .22;
var fr:Number = .99;
var bn:Number = -.8;
function onEnterFrame():Void {
var mouse_vx:Number = mvx()/80;
var mouse_vy:Number = mvy()/80;
vy += gf;
vx *= fr;
vy *= fr;
if (_y>_root.spring_loc) {
vy -= Math.sqrt(_y-_root.spring_loc)/13;
}
if (_root.pressing == true) {
vx += mouse_vx;
vy += mouse_vy;
}
if (_x<0) {
_x = 0;
vx *= bn;
}
if (_x>Stage.width) {
_x = Stage.width;
vx *= bn;
}
_x += vx;
_y += vy;
}
____________________
Explanation:
var spring_loc:Number = 300;
This sets the y distance at which the forces of elasticity will begin to act on the dot.
var pressing:Boolean = false;
Just more meaningless, initiative variables....
var dot:MovieClip = attachMovie("dot", "dot", getNextHighestDepth());
dot._x = Stage.width/2;
dot._y = 50;
Adds the dot MovieClip to the stage, gives it an instance name of "dot" and sets it's position.I like to use attachMovie() for this because it doesn't give the MovieClip a negetive depth, which is something that can be very limiting.
function onMouseDown():Void {
pressing = true;
}
function onMouseUp():Void {
pressing = false;
}
Simple enough. If you're clicking it sets "pressing" to true, otherwise it sets it to false.
Now for the dot's actions; and all the physics.
function mvx() {
x2 = _root._xmouse;
xvel = x2-x1;
x1 = x2;
return xvel;
}
function mvy() {
y2 = _root._ymouse;
yvel = y2-y1;
y1 = y2;
return yvel;
}
Simple function pair that returns the mouse's "velocity".
var vx:Number = 0;
var vy:Number = 0;
Initiative variables.
var gf:Number = .22;
Sets the force of gravity.
var fr:Number = .99;
Sets amount of air friction.
var bn:Number = -.8;
Sets how much the dot will bounce off walls.
function onEnterFrame():Void {
Every frame....
var mouse_vx:Number = mvx()/80;
var mouse_vy:Number = mvy()/80;
For some reason I needed variables for this.
vy += gf;
vx *= fr;
vy *= fr;
Applies gravity and air friction.
if (_y>_root.spring_loc) {
vy -= Math.sqrt(_y-_root.spring_loc)/13;
}
If the dot is past the point where the elasticity is supposed to take hold, keep subtacting from vy until it's forced back up again. Imagine it's landing on an invisible rubber band, and the farther it falls into it the stronger the forces become. Notice the Math.sqrt( , without it the forces became too rigid and the dot would barely sink before being abruptly thrown back up.
if (_root.pressing == true) {
vx += mouse_vx;
vy += mouse_vy;
}
This checks the variable created in the main frame and sees if the mouse is down so it can begin the throwing part.
if (_x<0) {
_x = 0;
vx *= bn;
}
if (_x>Stage.width) {
_x = Stage.width;
vx *= bn;
}
The walls and bouncing. Multiplies vx by a negetive number less than one to get it moving with less speed in the opposite direction. Just like real bouncing >:U.
_x += vx;
_y += vy;
Moves the dot according to the previously set variables...
____________________
If you are going to use this in a project or game you must give me credit and have my permission in advance. Copyright 2008 Ryan Keathley.
Updated: 01/21/08 4:29 AM 0 comments | Log in to comment! | Share this!As a nice little side project, I have decided I'm going to post my Experimental flash on my user page, along with the script and a brief explanation. I will provide a link to download the source and hotlink to the .swf. I'll start by posting a little engine I came up with in school.
I cannot Hotlink to the .swf at this time, sorry. (SwfUp is down and ImageShack hates me.)
Setting up the .fla:
Create a MovieClip, and remove it from the Stage so that it only exists in the library. Right click the MovieClip in the library and select "Linkage". Check "Export for ActionScript" and in "Identifier" type "dot". Change the Frame Rate from 12 so that it will run smoothly ( I used 40), and add this script to the Main Frame Panel:
var nd:Number = 0;
var lm:Number = 7;
function onMouseDown():Void {
if (nd<=lm) {
var dot:MovieClip = attachMovie("dot", "dot"+nd, getNextHighestDepth());
dot._x = _xmouse;
dot._y = _ymouse;
nd++;
}
}
function onEnterFrame():Void {
clear();
for (var i:Number = 0; i<nd; i++) {
var dot:MovieClip = this["dot"+i];
dot._x += Math.random()*2-1;
dot._y += Math.random()*2-1;
for (var j:Number = i+1; j<nd; j++) {
var ndot:MovieClip = this["dot"+j];
lineStyle(1, 0x000000, 100);
moveTo(dot._x, dot._y);
lineTo(ndot._x, ndot._y);
}
}
}
Now test the flash. What should appear is a blank screen. Start clicking around what should begin to appear is lines that connect the MovieClip you created. The result will be a very cool effect.
Explanation:
var nd:Number = 0;
var lm:Number = 7;
This initiates the variables that will be used later. "lm" limits the amount of dots allowed to be created. It can be changed from 7 to any other number, and I have recorded the script running smoothly at low quality with 30 dots on the stage. Just be cautious, as performance decreases at a geometric rate.
function onMouseDown():Void {
When you click....
if (nd<=lm) {
Check to see if you have not reached the limit.
var dot:MovieClip = attachMovie("dot", "dot"+nd, getNextHighestDepth());
dot._x = _xmouse;
dot._y = _ymouse;
nd++;
Attaches the MovieClip you created to the stage, gives it custom instance name (dot0,dot1,dot2....), and sets its position to the place you clicked,.
}
}
function onEnterFrame():Void {
Runs every frame.
clear();
for (var i:Number = 0; i<nd; i++) {
var dot:MovieClip = this["dot"+i];
Runs a for loop and specifies all the dots that have been created.
dot._x += Math.random()*2-1;
dot._y += Math.random()*2-1;
Moves the dots randomly for that "jiggle" effect
for (var j:Number = i+1; j<nd; j++) {
var ndot:MovieClip = this["dot"+j];
lineStyle(1, 0x000000, 100);
moveTo(dot._x, dot._y);
lineTo(ndot._x, ndot._y);
Within the previous for() loop, specifies the other dots created with instance names higher than the one before, and draws a line between them. This results in every single dot being connected by a line.
}
}
}
I will post more later.
EDIT EDIT EDIT EDIT EDIT EDIT
I re-wrote this script. Now you don't have to make a MovieClip, just add the script and done!!!
var nd:Number = 0;
var lm:Number = 100;
function onMouseDown():Void {
if (nd<lm) {
_root["x"+nd] = _xmouse;
_root["y"+nd] = _ymouse;
nd++;
}
}
function onEnterFrame():Void {
clear();
for (var i:Number = 0; i<nd; i++) {
if (Key.isDown(Key.SPACE)) {
_root["x"+i] += Math.random()*4-2;
_root["y"+i] += Math.random()*4-2;
}
for (var j:Number = i+1; j<nd; j++) {
lineStyle(1, 0xFADFAD, 100);
moveTo(_root["x"+i], _root["y"+i]);
lineTo(_root["x"+j], _root["y"+j]);
}
}
}
The difference is instead of making a MC it makes variables X0,Y0, X1, Y1...... It also only jiggles when you hold space, allowing you to draw really cool designs first.
Updated: 01/20/08 2:17 PM 1 comment | Log in to comment! | Share this!I stopped production of the platformer, because after finishing the engine I realized I know nothing of side-scroller AI or XML sockets. Instead I'm starting production on a top-view shooter. I'm confident this one will be completed because it's so simple. I've finished the movement engine, I've got enemies planned, and interface design is easy. I'm just concerned that my controller scheme will ruin the game. Here is the movement engine, so make any suggestions for it.
0 comments | Log in to comment! | Share this!After weeks of brain-storming, side tracking, and caffiene abuse I have decided to focus all of my attention on one single project. I cannot say much on the project as things have yet to be decided, all I can disclose at this point that it will be a strategic shooter that will focus on planing and cooperation rather than who is the best shot.
I'm working on developing a platformer engine at this point, but it is not going smoothly so any help will be appreciated. Anyone interested in helping should PM me.
Updated: 12/26/07 2:36 AM 0 comments | Log in to comment! | Share this!