This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-18 16:58:22

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Help me...

I need a script that affects the gravity of a arrow.


Get ready for domination of:  tongue

Offline

 

#2 2012-05-18 17:20:49

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Help me...

Could you elaborate more?


Why are the secret organizations getting all the attention?  mad

Offline

 

#3 2012-05-18 17:30:59

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Help me...

Kind of like an archery game. I have this arrow, and it needs to be affected by gravity, instead of going up forever.. How would I do this?

Can't really explain.


Get ready for domination of:  tongue

Offline

 

#4 2012-05-18 17:42:29

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Help me...

Oh! That arrow. I thought you meant something else...Hm. I gather that this archery game is an archer(or bow or whatever) is at the bottom of the screen, and you shoot at targets at the top of the screen. Is that correct?


Why are the secret organizations getting all the attention?  mad

Offline

 

#5 2012-05-18 17:47:06

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Help me...

Yes, there is.
And he doesn't move.

Last edited by coolhogs (2012-05-18 17:47:24)


Get ready for domination of:  tongue

Offline

 

#6 2012-05-18 17:50:40

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Help me...

One last question, and I can answer your question, is this an overhead view, or is the archer actually shooting up?


Why are the secret organizations getting all the attention?  mad

Offline

 

#7 2012-05-18 17:51:57

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Help me...

Uh, what do you mean?


Get ready for domination of:  tongue

Offline

 

#8 2012-05-18 17:56:16

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Help me...

Is the archer shooting across the range, or up in the air? That would make an impact.


Why are the secret organizations getting all the attention?  mad

Offline

 

#9 2012-05-18 18:00:06

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Help me...

Up in the air.


Get ready for domination of:  tongue

Offline

 

#10 2012-05-18 18:11:47

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help me...

The easiest way would be to use velocity, but you'd still have to get the arrow to point in the correct direction.  This is what I would do:

when gf clicked
forever
go to [archer v]
point towards [mouse-pointer v]
if <mouse down?>
set [x-vel v] to ((power)*([sin v] of (direction)))
set [y-vel v] to ((power)*([cos v] of (direction)))
repeat until <touching [edge v]?>
change [y-vel v] by (-0.4)
change x by (x-vel)
change y by (y-vel)
if<(y-vel) = [0]>
if<(x-vel) = [0]>
point in direction (180 v)
else
point in direction ((([abs v] of (x-vel))/(x-vel))*(90))
end
else
if<(y-vel) < [0]>
point in direction (([atan v] of ((x-vel)/(y-vel))) + (180))
else
point in direction ([atan v] of ((x-vel)/(y-vel)))
end
end
end
end


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#11 2012-05-18 18:14:51

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Help me...

set [POWER v] to [(distance to [mouse pointer v])/(10)]
set [xvel v] to [([sin v] of (POWER))
set [yvel v] to [([cos v] of (POWER))
wait until <key [space v] pressed>
repeat until <<touching [target v]> or <touching [edge v]> or <y position < -200>
 change y by (yvel)
 change x by (xvel)
 change [yvel v] by [1] //Or however strong you want the gravity to be
end
 
Those scratchblocks are probably aq total fail, but I hope you know what I mean.

Last edited by mythbusteranimator (2012-05-18 18:16:24)


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#12 2012-05-18 18:37:16

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Help me...

I've made a project here that will solve the problem. The scripting is a bit less complicated than moregamesnow's, but it still works, rather nicely if I do say so myself.  tongue


Why are the secret organizations getting all the attention?  mad

Offline

 

#13 2012-05-18 20:25:40

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Help me...

I've made a few arrow-shooting games that may help, but shoot from the side, not up.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#14 2012-05-18 21:16:27

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Help me...

MoreGamesNow wrote:

The easiest way would be to use velocity, but you'd still have to get the arrow to point in the correct direction.  This is what I would do:

when gf clicked
forever
go to [archer v]
point towards [mouse-pointer v]
if <mouse down?>
set [x-vel v] to ((power)*([sin v] of (direction)))
set [y-vel v] to ((power)*([cos v] of (direction)))
repeat until <touching [edge v]?>
change [y-vel v] by (-0.4)
change x by (x-vel)
change y by (y-vel)
if<(y-vel) = [0]>
if<(x-vel) = [0]>
point in direction (180 v)
else
point in direction ((([abs v] of (x-vel))/(x-vel))*(90))
end
else
if<(y-vel) < [0]>
point in direction (([atan v] of ((x-vel)/(y-vel))) + (180))
else
point in direction ([atan v] of ((x-vel)/(y-vel)))
end
end
end
end

You forgot something to set the power  tongue


........................................................................................................................................................................................................................................

Offline

 

#15 2012-05-18 21:25:13

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help me...

zubblewu wrote:

MoreGamesNow wrote:

long script

You forgot something to set the power  tongue

I expected coolhogs to set the power  tongue


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#16 2012-05-18 23:19:07

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Help me...

How do you do that?


Get ready for domination of:  tongue

Offline

 

#17 2012-05-19 01:53:57

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: Help me...

coolhogs wrote:

How do you do that?

by adding in the set power to [x] block at the beginning. It's already incorporated into the script.

Offline

 

#18 2012-05-19 08:20:01

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Help me...

Oh. I would do something like distance to mouse pointer / 10


........................................................................................................................................................................................................................................

Offline

 

Board footer