Could try something like this, where movement is a variable:
when gf clicked
set [movement] to [0]
forever
move [movement] steps
if <[movement] > [0] >
change [movement] by (-1)
end
if <[movement] < [0] >
change [movement] by (1)
end
if <key [left arrow] pressed?>
turn left [15] degrees
end
if <key [right arrow] pressed?>
turn right [15] degrees
end
if <key [up arrow] pressed?>
move [10] steps
if <[movement] < [10]>
change [movement] by (1)
end
end
if <key [down arrow] pressed?>
move [-10] steps
if <[movement] > [-10]>
change [movement] by (-1)
end
end
end
Offline
Oops, sleight error above. When the up or down arrow key's are pressed the movement variable needs to be changed by more than the amount it's reduced each time the forever block loops round. So if you just change the last part to:
when gf clicked
set [movement] to [0]
forever
move [movement] steps
if <[movement] > [0] >
change [movement] by (-1)
end
if <[movement] < [0] >
change [movement] by (1)
end
if <key [left arrow] pressed?>
turn left [15] degrees
end
if <key [right arrow] pressed?>
turn right [15] degrees
end
if <key [up arrow] pressed?>
move [10] steps
if <[movement] < [10]>
change [movement] by (2)
end
end
if <key [down arrow] pressed?>
move [-10] steps
if <[movement] > [-10]>
change [movement] by (-2)
end
end
end
That'll work. The amount of steps taken, the amount the variable movement is changed by each time and what the variable movement is capped at will change how quickly it moves, accelerates and decelerates. I'll let you play with that.
Offline
PaulBrownMagic wrote:
Could try something like this, where movement is a variable:
when gf clicked set [movement] to [0] forever move [movement] steps if <[movement] > [0] > change [movement] by (-1) end if <[movement] < [0] > change [movement] by (1) end if <key [left arrow] pressed?> turn left [15] degrees end if <key [right arrow] pressed?> turn right [15] degrees end if <key [up arrow] pressed?> move [10] steps if <[movement] < [10]> change [movement] by (1) end end if <key [down arrow] pressed?> move [-10] steps if <[movement] > [-10]> change [movement] by (-1) end end end
Fixed
when gf clicked
set (movement) to [0]
forever
move (movement) steps
if <(movement) > [0] >
change (movement) by (-1)
end
if <(movement) < [0] >
change (movement) by (1)
end
if <key [left arrow v] pressed?>
turn left [15] degrees
end
if <key [right arrow v] pressed?>
turn right [15] degrees
end
if <key [up arrow v] pressed?>
move [10] steps
if <(movement) < [10]>
change (movement) by (1)
end
end
if <key [down arrow v] pressed?>
move [-10] steps
if <(movement) > [-10]>
change (movement) by (-1)
end
end
end
Last edited by topazdragonlord (2013-04-08 12:59:23)
Offline