View Full Version : SlingShot
LittleMasterNik
01-28-2006, 07:00 PM
Hey,
I haven't posted for a long time but now i'm wondering how to make a sling shot. It's just a giant slingshot in the ground and I need to know how to use the elastic. I can't figure out how to make it when you pull back the elastic it shoots the balls. I need it so you can make it shot in any direction just by pulling it how ever you do. If someone can help, thank in advance.
arkhan
01-28-2006, 07:06 PM
but how is this going to work? with the mouse? like, when you press it holds the elastic and shoots by releasing it?
well...for that, .just calculate the angle and ditance from the mouse to the base of the sling shot when its released.
LittleMasterNik
01-28-2006, 07:09 PM
Ya, using the mouse. And you can stretch it around so the balls will go in different directions. Also you just hold it down and when you let go it shoots the balls. O ya, I don't know that sort of action script so that's why i'm wondering if somebody could help me write it.
eatmorchikin6464
01-28-2006, 09:45 PM
I don't think you are ready for that.
eatmorchikin6464
01-28-2006, 10:18 PM
I don't think you are ready for that.
3QuarterAiming
01-28-2006, 11:18 PM
I don't think you are ready for that.
warning! double post!
anyway, we are making the game. niklas and me. i cant say my real name to anyone so call me leaf
but i think you use distance mixed with speed. i need some distance scripts and ill use them with my +1 speed scriptsn to do this, but it will take ages.
power to the max!
so yeah we need some help
Soon to be flash master
01-28-2006, 11:46 PM
ok leaf
PM the people who are nice to you, you are on a brink of a major flame
3QuarterAiming
01-29-2006, 12:07 AM
ok leaf
PM the people who are nice to you, you are on a brink of a major FLAME,
sorry my friend made me put that last bit. you used to be nice to me and little master nik is nice. and so is steven g3ko (now) and caleb hes not on this forum
EDIT; whats FLAME
p.s. im a fag and nobody likes me
sorry my friend made me put that last bit.
EDIT; whats FLAME
That made me crack up so much...
Soon to be flash master
01-29-2006, 01:38 AM
i used to be nice? i just think you need to tone down your first flash project from a ultra cool rpg shoot em up game to o i dunno i little easier, i think your getting yourself into somthing you cant handle
i used to be nice? o no i never changed either i am still nice or wasnt nice before
You have to learn the basics, start with mini-games and experiments before you start a BIG Project.
And 3QuarterAiming, dude...learn some stuff
wait I think I did this let me look through all my fla files.
sorry for double post.
Found it but its no use my attempt at this had failed im going to try from scratch.
arkhan
01-29-2006, 04:13 PM
you het the angle by using the atan2 function from the Math class..
you give a direction and it return the radian to that direction..
MC1._rotation=Math.atan2(MC1._y-MC2._y,MC1._x-MC2._x)*180/Math.PI
the distance is the square of the distance power 2..yeah..its like undoing a calc..but with 2 diferent numbers..
dx=MC1._x-MC2._x
dy=MC1._y-MC2._y
dist=Math.sqrt((dx*dx)*(dy*dy))
Im not entirelly sure about the distance one..do some debuging until you fell the result is right..but is basicly it..
Matt just use the edit button
eatmorchikin6464
01-29-2006, 05:04 PM
You have to learn the basics, start with mini-games and experiments before you start a BIG Project.
And 3QuarterAiming, dude...learn some stuff
Youre one to talk. If you don't remember, you used to be just like him.
The Brown Cow
01-29-2006, 05:45 PM
Let's see... How many posts in this thread actually relate to the question at hand? 2? 3?
Kirupa has a nice tutorial on elasticity here (http://www.kirupa.com/developer/actionscript/spring.htm).
Youre one to talk. If you don't remember, you used to be just like him.
Yeah I know, I used to be like him. Glad I changed.
*Looks around* *See's someone go near* MY SEARCH BUTTON! *Shoots with a shotgun*
eatmorchikin6464
01-29-2006, 05:51 PM
But do you honestly think he can then transfer that knowledge into a working slingshot?
LittleMasterNik
01-29-2006, 07:36 PM
Thanks to Arkhan and The Brown Cow since you two, I think, are the only ones who helped. This is what i've done so far:
http://img204.imageshack.us/my.php?image=stretchy3zg.swf
I think it's ok... I used Kirupa to help me... but as you can see the elastic isn't working quit right yet. If someones can help, it would be greatly appreciated.
I think if you would do it side way view instead of that way, it might be way more easier.
LittleMasterNik
01-29-2006, 09:21 PM
Ya, I guess it might be easier... but first I need to figure out how to make the slingshot work properly.
MercuryLime
01-29-2006, 09:27 PM
Ya, I guess it might be easier... but first I need to figure out how to make the slingshot work properly.
Unless you adjust the boundaries with API, I don't think you'll be able to make the rectangle elastic - what I would do is draw the frames for being pulled back, and then tell the string to play each frame depending on the _y.
3QuarterAiming
01-30-2006, 05:29 AM
Unless you adjust the boundaries with API, I don't think you'll be able to make the rectangle elastic - what I would do is draw the frames for being pulled back, and then tell the string to play each frame depending on the _y.
good idea
eatmorchikin6464
01-30-2006, 07:35 PM
I think it's ok... I used Kirupa to help me... but as you can see the elastic isn't working quit right yet. If someones can help, it would be greatly appreciated.
Not to put you down or anything but no matter what you do you will never get it to work right on your own. It takes loads of experience and knowledge to be able to take a tutorial such as that one and then manipulate it to fit your needs. What I see there is just a similar version of that tutorial, probably using almost the same actionscript. The whole point of this tutorial was just to give you an idea of what to start with, only the basis of that script will work for this. You will have to use script to make the ends of the rectangle stay with the slingshot and a script to shoot whatever it is the proper speed (based on how far back the elastic is pulled) and at what angle to do so.
I say....good luck.
vBulletin® v3.7.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.