i think what you want is:
<when green flag clicked> <forever> <if><key[ up ] keypressed> <point in direction( 0 <end> <if><key[ left ] key pressed> <point in direction( -90 <end>
so on
Offline
All right:
/^^^^^^^^^^^^^^^\_____ [When flag clicked____] [forever] [][if <key [right arrow] pressed?>] [][][turn [5] degrees right] [][end of if______________________] [][if <key [left arrow] pressed?>] [][][turn [5] degrees left] [][end of if_____________________] [][if <key [up arrow] pressed?>] [][][move [5] steps] [][end of if___________________] [end of forever]
Last edited by The-Whiz (2009-07-18 10:06:17)
Offline
The-Whiz wrote:
All right:
Code:
/^^^^^^^^^^^^^^^\_____ [When flag clicked____] [forever] [][if <key [right arrow] pressed?>] [][][turn [5] degrees right] [][end of if______________________] [][if <key [left arrow] pressed?>] [][][turn [5] degrees left] [][end of if_____________________] [][if <key [up arrow] pressed?>] [][][move [5] steps] [][end of if___________________] [end of forever]
ok that works but i need this too:
when i click left or right arrow my sprite makes a full circle but i don't want my sprite to do that. I want to go as far as 45 degrees left and right. How can I do that?
Offline
Yes...
/^^^^^^^^^^^^^^^\_____ [When flag clicked____] [forever] [][if <key [right arrow] pressed?>] [][][turn [5] degrees right] [][end of if______________________] [][if <key [left arrow] pressed?>] [][][turn [5] degrees left] [][end of if_____________________] [][if <key [up arrow] pressed?>] [][][move [5] steps] [][end of if___________________] [][if <(direction) > (45)>] [][][point in direction (45)] [][end of if_____________________] [][if <(direction) < (-45)>] [][][point in direction (-45)] [][end of if_____________________] [end of forever]
That should work.
Offline
Ok this is getting complicated...
/^^^^^^^^^^^^^^^\_____ [When flag clicked____] [forever] [][if <key [right arrow] pressed?>] [][][turn [5] degrees right] [][end of if______________________] [][if <key [left arrow] pressed?>] [][][turn [5] degrees left] [][end of if_____________________] [][if <key [up arrow] pressed?>] [][][move [5] steps] [][end of if___________________] [][if <(direction) > (45)>] [][][point in direction (45)] [][end of if_____________________] [][if <(direction) < (-45)>] [][][point in direction (-45)] [][end of if_____________________] [][if <key [up arrow] pressed?] [][][change (Y-vel) by 1] [][else] [][][change (Y-vel) by -1] [][end of if_________________] [][change y by (Y-vel)] [end of forever]
Last edited by The-Whiz (2009-07-18 15:57:56)
Offline
markyparky56 wrote:
i think what you want is:
Code:
<when green flag clicked> <forever> <if><key[ up ] keypressed> <point in direction( 0 <end> <if><key[ left ] key pressed> <point in direction( -90 <end>so on
Close, but it should be [turn cw (2) degrees] for up;
[turn ccw (2) degrees] for down.
If you just point in one direction for each, then that limits it to two directions.
Offline
The-Whiz wrote:
Ok this is getting complicated...
Code:
/^^^^^^^^^^^^^^^\_____ [When flag clicked____] [forever] [][if <key [right arrow] pressed?>] [][][turn [5] degrees right] [][end of if______________________] [][if <key [left arrow] pressed?>] [][][turn [5] degrees left] [][end of if_____________________] [][if <key [up arrow] pressed?>] [][][move [5] steps] [][end of if___________________] [][if <(direction) > (45)>] [][][point in direction (45)] [][end of if_____________________] [][if <(direction) < (-45)>] [][][point in direction (-45)] [][end of if_____________________] [][if <key [up arrow] pressed?] [][][change (Y-vel) by 1] [][else] [][][change (Y-vel) by -1] [][end of if_________________] [][change y by (Y-vel)] [end of forever]
this last doesn't work with Y-vel. Do you have some other idea?
Offline
Well do you mean
/^^^^^^^^^^^^^^^\_____ [When flag clicked____] [forever] [][if <key [right arrow] pressed?>] [][][turn [5] degrees right] [][end of if______________________] [][if <key [left arrow] pressed?>] [][][turn [5] degrees left] [][end of if_____________________] [][if <key [up arrow] pressed?>] [][][move [5] steps] [][else] [][][move [-5] steps] [][end of if___________________] [][if <(direction) > (45)>] [][][point in direction (45)] [][end of if_____________________] [][if <(direction) < (-45)>] [][][point in direction (-45)] [][end of if_____________________] [end of forever]
I don't really understand what you mean...
Offline
The-Whiz wrote:
[][if <key [up arrow] pressed?]
[][][change (Y-vel) by 1]
[][else]
[][][change (Y-vel) by -1]
[][end of if_________________]
[][change y by (Y-vel)]
[end of forever]
This part dont work well. Dont you have another idea on this principle?
Offline
do you mean?:
Sprite1: <when green flag clicked> <forever> <if><mouse down?> <go to x:( <mouse x> )y:( <mouse y>) <end> <end> Sprite2 (This one is the laser) <when green flag clicked> <forever> <wait until><mouse down?> <play sound[ Laser sound ] <repeat until><< <touching[ Enemy] <or> <touching[ edge] >> <point in direction( Sprite1) <move( 10 )steps> <end> <end>
Is that what your wanting?
Offline
markyparky56 wrote:
do you mean?:
Code:
Sprite1: <when green flag clicked> <forever> <if><mouse down?> <go to x:( <mouse x> )y:( <mouse y>) <end> <end> Sprite2 (This one is the laser) <when green flag clicked> <forever> <wait until><mouse down?> <play sound[ Laser sound ] <repeat until><< <touching[ Enemy] <or> <touching[ edge] >> <point in direction( Sprite1) <move( 10 )steps> <end> <end>Is that what your wanting?
no it isn't working do you have something else on your mind
Offline
what isn't working about it?
Offline
You may need to add in a <go to[ player
Offline
If you want to use Y-vel, you have to use trig. You have to change the Y-vel by the cosine of the direction, and use a variable X-vel, changed by the sine of the direction. Lastly, you must change the X and Y by X-vel and Y-vel, respectively. You would get something like this (I added a resetting script at the beginning and used 1/10 values):
[blocks]
<when green flag clicked>
<set{ X-vel }to( 0
<set{ Y-vel }to( 0
<go to x
0 )y
0
<forever>
<if><key[ right arrow ]pressed?>
<turn cw( 5 )degrees>
<end>
<if><key[ left arrow ]pressed?>
<turn ccw( 5 )degrees>
<end>
<if><( <direction> <<> -45 )>
<point in direction( -45
<end>
<if><( <direction> <>> 45 )>
<point in direction( 45
<end>
<if><key[ up arrow ]pressed?>
<change{ X-vel }by( sin(<direction>)
<change{ Y-vel }by( cos(<direction>)
<else>
<change{ Y-vel }by( -1
<end>
<change x by( (( <{ X-vel }> <*> 0.1 ))
<change y by( (( <{ Y-vel }> <*> 0.1 ))
<end>
[/blocks]
Offline