Create an "xspeed" variable and an "xmax" variable. Set xmax to, say, 4. Then, do a script like this:
forever set [xmax] to (4) if < key [right arrow v] presed > set [xvel v] to 0 forever if < key [right arrow v] pressed > change x by (xvel) change [xvel v] by (1) if < <(xvel) > (xmax) > > set [xvel] to (xmax)
Offline
mythbusteranimator wrote:
Create an "xspeed" variable and an "xmax" variable. Set xmax to, say, 4. Then, do a script like this:
when gf clicked forever set [xmax v] to [4] if <key [right arrow v] pressed ?> set [xvel v] to (0) forever if <key [right arrow v] pressed ?> change x by (xvel) change [xvel v] by (1) if <(xvel) > (xmax)> set [xvel v] to (xmax)
Fixed your scripts.
Offline
Give this a try:
Create a variable called "Velocity" and another one called "LKP" and use this script:
when gf clicked set [Velocity v] to [0] forever if <key [left arrow v] pressed?> set [LKP v] to [1] change [Velocity v] by (-0.5) end if <key [right arrow v] pressed?> set [LKP v] to [2] change [Velocity v] by (0.5) end if <(Velocity) > (4)> set [Velocity v] to (4) end if <(Velocity) < (-4)> set [Velocity v] to (-4) end if <<<(LKP) = [1]> and <(Velocity) > (0)>> or <<(LKP) = [2]> and <(Velocity) < (0)>>> set [Velocity v] to [0] end set [Velocity v] to ((Velocity) * (0.8)) change x by (Velocity) end
Last edited by SciTecCf (2012-05-04 10:31:53)
Offline
SciTecCf wrote:
Give this a try:
Create a variable called "Velocity" and another one called "LKP" and use this script:when gf clicked set [Velocity v] to [0] forever if <key [left arrow v] pressed?> set [LKP v] to [1] change [Velocity v] by (-0.5) end if <key [right arrow v] pressed?> set [LKP v] to [2] change [Velocity v] by (0.5) end if <(Velocity) > (4)> set [Velocity v] to (4) end if <(Velocity) < (-4)> set [Velocity v] to (-4) end if <<<(LKP) = [1]> and <(Velocity) > (0)>> or <<(LKP) = [2]> and <(Velocity) < (0)>>> set [Velocity v] to [0] end set (Velocity) to ((Velocity) * (0.7)) change x by (Velocity) end
What is "LKP"?
Offline
mythbusteranimator wrote:
SciTecCf wrote:
Give this a try:
Create a variable called "Velocity" and another one called "LKP" and use this script:when gf clicked set [Velocity v] to [0] forever if <key [left arrow v] pressed?> set [LKP v] to [1] change [Velocity v] by (-0.5) end if <key [right arrow v] pressed?> set [LKP v] to [2] change [Velocity v] by (0.5) end if <(Velocity) > (4)> set [Velocity v] to (4) end if <(Velocity) < (-4)> set [Velocity v] to (-4) end if <<<(LKP) = [1]> and <(Velocity) > (0)>> or <<(LKP) = [2]> and <(Velocity) < (0)>>> set [Velocity v] to [0] end set (Velocity) to ((Velocity) * (0.7)) change x by (Velocity) endWhat is "LKP"?
Last Key Pressed.
Last edited by SciTecCf (2012-05-04 10:13:51)
Offline
SciTecCf wrote:
Give this a try:
Create a variable called "Velocity" and another one called "LKP" and use this script:when gf clicked set [Velocity v] to [0] forever if <key [left arrow v] pressed?> set [LKP v] to [1] change [Velocity v] by (-0.5) end if <key [right arrow v] pressed?> set [LKP v] to [2] change [Velocity v] by (0.5) end if <(Velocity) > (4)> set [Velocity v] to (4) end if <(Velocity) < (-4)> set [Velocity v] to (-4) end if <<<(LKP) = [1]> and <(Velocity) > (0)>> or <<(LKP) = [2]> and <(Velocity) < (0)>>> set [Velocity v] to [0] end set [Velocity v] to ((Velocity) * (0.8)) change x by (Velocity) end
Here's an example: Velocity Movement Example
Last edited by SciTecCf (2012-05-04 10:40:20)
Offline