hi
im trying to create something in scratch where by the user can move the sprite (javelin thrower) forwards and backwards and then release a javelin which is attached to the thrower when a key is pressed.
The javelin needs to go in an arc & fall to the ground , once the user has thrown the javelin the game should reset.
Any help or guidance would be thanked
Offline
I know it has something to do with trig, but I'm sure what.
Offline
Well, you need a javelin sprite, and it needs to use the following script:
when gf clicked forever repeat until <key [space v] pressed?>// follow mouse till space pressed go to [mouse-pointer v] end wait (0.1) secs set [xvel v] to ((mouse x) - (x position)) set [yvel v] to ((mouse y) - (y position)) repeat until <touching [edge v]?> change x by (xvel) change y by (yvel) change [yvel v] by (-1) end wait (5) secs
Offline
Hardmath123 wrote:
Well, you need a javelin sprite, and it needs to use the following script:
when gf clicked forever repeat until <key [space v] pressed?>// follow mouse till space pressed go to [mouse-pointer v] end wait (0.1) secs set [xvel v] to ((mouse x) - (x position)) set [yvel v] to ((mouse y) - (y position)) repeat until <touching [edge v]?> change x by (xvel) change y by (yvel) change [yvel v] by (-1) end wait (5) secs
You need direction as well.
I think it's this:
if <(y position) > [0]> point in direction ([atan v] of (([0] - (x velocity)) / ([0] - (y velocity)))) else point in direction ([0] - ([atan v] of (([0] - (x velocity)) / ([0] - (y velocity)))))
Offline
Splodgey wrote:
Hardmath123 wrote:
Well, you need a javelin sprite, and it needs to use the following script:
when gf clicked forever repeat until <key [space v] pressed?>// follow mouse till space pressed go to [mouse-pointer v] end wait (0.1) secs set [xvel v] to ((mouse x) - (x position)) set [yvel v] to ((mouse y) - (y position)) repeat until <touching [edge v]?> change x by (xvel) change y by (yvel) change [yvel v] by (-1) end wait (5) secsYou need direction as well.
I think it's this:if <(y position) > [0]> point in direction ([atan v] of (([0] - (x velocity)) / ([0] - (y velocity)))) else point in direction ([0] - ([atan v] of (([0] - (x velocity)) / ([0] - (y velocity))))) end
Oh, yeah. Thanks for that!
Offline
mrbacak wrote:
thanks hardmath but i need to know how to tie the javelin to the thrower and move the thrower forwards & backwards + when space is pressed realease
can you help me with this ??
You can use this;
repeat until <key [space v] pressed?> goto [Player v] endI've just realised; what do you mean?
repeat until <key [space v] pressed?> set x to (([x position v] of [player v]) + (How much it's in the wrong place)) //or - set y to (([y position v] of [player v]) + (How much it's in the wrong place)) //again, or - end
Offline