Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.94 / 5.00 9,999 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.02 / 5.00 45,989 Viewsever wonder how to make a throwing game or track the speed of the mouse??
i diddnt see a tutorial on this,so im writing up my own :D
to start off make an _x array and a _y array
so you should have somthing like this in the frame
xar = new Array()
yar = new Array()
now what you need to do is create a variable to increase every frame,like this
var i:Number=0
so now we will increase that every frame like this
onEnterFrame=function(){
i++
}
now we will start with the xmouse
onEnterFrame=function(){
i++
xar[i]=_xmouse
xx=xar[i]-xar[i-1]
}
now,all this does is,add a value to xar
our _xmouse variable
every frame then it gets the distance between that value and the previouse value
sofar we have this
xar = new Array()
yar = new Array()
var i:Number=0
onEnterFrame=function(){
i++
xar[i]=_xmouse
xx=xar[i]-xar[i-1]
}
and for the _ymouse values just add
yar[i]=_ymouse
yy=yar[i]-yar[i-1]
and that does the same thing but with the _ymouse
now are compleate code is
xar = new Array();
yar = new Array();
var i:Number = 0;
onEnterFrame = function () {
i++;
xar[i] = _xmouse;
xx = xar[i]-xar[i-1];
yar[i] = _ymouse;
yy = yar[i]-yar[i-1];
};
see,this is useful beacuse with this you can
throw objects
slide objects
and other cool stuff
example:
http://denvish.net/ulf/220407/77642_throw.fla
http://denvish.net/ulf/220407/77666_throw.php
the fla and the swf
feel free to use the code as shown
Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.
wow nice. to bad denvish doesn't update as:main much anymore.
nice, although i already knew how to do it you can use the principles of that code to do anything like finding how fast an object is rotating, nice work!
its good in theory, but try dragging the ball over to the left, waiting, then dragging it back to the center and then try and throw it. Maybe if you cleared some of the data after 3 seconds or so.
Nice job though
At 4/22/07 11:07 PM, LesPaulPlayer wrote: its good in theory, but try dragging the ball over to the left, waiting, then dragging it back to the center and then try and throw it. Maybe if you cleared some of the data after 3 seconds or so.
Nice job though
thanks,i forgot to post the set interval function to remove variables :/
but i do wish denvish would update more >:U
Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.
At 4/22/07 11:07 PM, LesPaulPlayer wrote: its good in theory, but try dragging the ball over to the left, waiting, then dragging it back to the center and then try and throw it. Maybe if you cleared some of the data after 3 seconds or so.
Nice job though
actually,i diddnt find a glitch and all that removing the data would do is remove a tiny little bit of lag :/
but i might just make a new thread with that in it :D
Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.
Why store all the values in an array?
prevX=prevY=0;
onEnterFrame=function(){
xDist=_xmouse-prevX;
yDist=_ymouse-prevY;
prevY=_ymouse;
prevX=_xmouse;
}
Much easier, less lag. Good tut nonetheless, Well structured, well explained.
thanks vengence,i just diddnt see anything on mouse speed so i made one :D
and i guess i diddnt have to use arrays but incase you wanted it to be able to see past mouse speeds i used arrays :D
but i wish there was an edit post function >:U
Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.
At 4/22/07 09:54 PM, ShittyFlash wrote: wow nice. to bad denvish doesn't update as:main much anymore.
AS: Main is locked, that's why. Also, nice tut.
At 4/24/07 03:16 PM, salted-tator-tot wrote:At 4/22/07 09:54 PM, ShittyFlash wrote: wow nice. to bad denvish doesn't update as:main much anymore.AS: Main is locked, that's why. Also, nice tut.
thanks,but AS: main has been unlocked for about a month now :D
Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.
i swear to god two hours ago i was thinking. Man i want to know mouse speed for a throwing game, but i don't know which tutorial to use.
:P thanx
At 4/24/07 07:30 AM, Vengeance wrote: Why store all the values in an array?
Thats what I was thinking. You also should have included pythagorus to work out the direct distance.
But it was good, anyways.
ok,maby i could have made it simple >:U
but im known for overcomplicating the simple stuff :D
but i found this way much more fun :D
Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.
over coplicated not? i just quickly invented this code, and it works great
onEnterFrame = function ()
{
xspeed = Math.abs(_xmouse-mousex);
yspeed = Math.abs(_ymouse-mousey);
mousespeed = Math.sqrt((xspeed*xspeed)+(yspeed*yspeed ));
mousex = _xmouse;
mousey = _ymouse;
};
mosespeed is the mousespeed
What's the point of the Math.Abs? Squaring / squarooting nullifies it.
At 3/28/09 09:16 AM, StaliN98 wrote: What's the point of the Math.Abs? Squaring / squarooting nullifies it.
point taken
At 3/28/09 11:54 PM, Yambanshee wrote:At 3/28/09 09:16 AM, StaliN98 wrote: What's the point of the Math.Abs? Squaring / squarooting nullifies it.point taken
.....Wth? Math.Abs does have a big point. It's absolute value, which means, it makes the inside value positive. It's also faster (and more efficient) than
Math.sqrt(Math.pow(16,2));
Yam., Why did you bump this thread?
At 3/28/09 06:38 AM, Yambanshee wrote: over coplicated not? i just quickly invented this code, and it works great
onEnterFrame = function ()
{
xspeed = Math.abs(_xmouse-mousex);
yspeed = Math.abs(_ymouse-mousey);
mousespeed = Math.sqrt((xspeed*xspeed)+(yspeed*yspeed ));
mousex = _xmouse;
mousey = _ymouse;
};
mosespeed is the mousespeed
This would be tidier if you replaced "xspeed*xspeed" with "xspeed^2"
And I also think you don't need the abs in this case, as has been said.
Decima: The Last Story of Vald has a Facebook page and a development blog. Give them a look!
------------------------------
At 3/29/09 04:55 AM, Hoeloe wrote:At 3/28/09 06:38 AM, Yambanshee wrote: over coplicated not? i just quickly invented this code, and it works greatThis would be tidier if you replaced "xspeed*xspeed" with "xspeed^2"
onEnterFrame = function ()
{
xspeed = Math.abs(_xmouse-mousex);
yspeed = Math.abs(_ymouse-mousey);
mousespeed = Math.sqrt((xspeed*xspeed)+(yspeed*yspeed ));
mousex = _xmouse;
mousey = _ymouse;
};
mosespeed is the mousespeed
And I also think you don't need the abs in this case, as has been said.
"xspeed^2" won't work (at least with AS 2.0). You should use "Math.pow(xspeed, 2)"
Applejuice ftw