I've been doing a platformer with a walking person (Actually Greek God). He has a series of 5 costumes that he uses when walking.
Here's my script:
When gf clicked Set [Step v] to [RightFoot] //Make it so that he starts walking with his right foot forever if <key [right arrow v] pressed if <(Step) = [RightFoot] Point in direction [90 v] Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] secs Switch to costume [FullRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] Secs Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot] Point in direction [90 v] Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] secs Switch to costume [FullLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] Secs Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [RightFoot] end end if <key [left arrow v] pressed if <(Step) = [RightFoot] Point in direction [-90 v] Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] secs Switch to costume [FullRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] Secs Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot] Point in direction [90 v] Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] secs Switch to costume [FullLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] Secs Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [RightFoot] end end endThe problem with this is that when you switch direction in the middle of a step, it has to finish the step it's currently on before switching direction. Any suggestions? Sorry if this is too complicated or if I'm not being very clear.
Offline
Maltese_Falcon wrote:
I've been doing a platformer with a walking person (Actually Greek God). He has a series of 5 costumes that he uses when walking.
Here's my script:When gf clicked Set [Step v] to [RightFoot] //Make it so that he starts walking with his right foot forever if <key [right arrow v] pressed> if <(Step) = [RightFoot]> Point in direction [90 v] Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] secs Switch to costume [FullRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] Secs Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot]> Point in direction [90 v]> Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] secs Switch to costume [FullLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] Secs Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [RightFoot] end end if <key [left arrow v] pressed> if <(Step) = [RightFoot]> Point in direction [-90 v] Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] secs Switch to costume [FullRightStep v] Wait [0.1] secs Switch to costume [MiddleRightStep v] Wait [0.1] Secs Switch to costume [StartRightStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot]> Point in direction [90 v] Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] secs Switch to costume [FullLeftStep v] Wait [0.1] secs Switch to costume [MiddleLeftStep v] Wait [0.1] Secs Switch to costume [StartLeftStep v] Wait [0.1] secs Switch to costume [StandingStill] Set [Step v] to [RightFoot] end end endThe problem with this is that when you switch direction in the middle of a step, it has to finish the step it's currently on before switching direction. Any suggestions? Sorry if this is too complicated or if I'm not being very clear.
I think I fixed it.
Offline
Maltese_Falcon wrote:
Maltese_Falcon wrote:
I've been doing a platformer with a walking person (Actually Greek God). He has a series of 5 costumes that he uses when walking.
Here's my script:When gf clicked set [Step v] to [RightFoot] //Make it so that he starts walking with his right foot forever if <key [right arrow v] pressed?> if <(Step) = [RightFoot]> point in direction [90 v] switch to costume [StartRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] secs switch to costume [FullRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] Secs switch to costume [StartRightStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot]> point in direction [90 v] switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] secs switch to costume [FullLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] Secs switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [RightFoot] end end if <key [left arrow v] pressed?> if <(Step) = [RightFoot]> point in direction [-90 v] switch to costume [StartRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] secs switch to costume [FullRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] Secs Switch to costume [StartRightStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot]> point in direction [90 v] switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] secs switch to costume [FullLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] Secs switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [RightFoot] end endThe problem with this is that when you switch direction in the middle of a step, it has to finish the step it's currently on before switching direction. Any suggestions? Sorry if this is too complicated or if I'm not being very clear.I think I fixed it.
fixed the scratchblocks.
Last edited by Liamadams (2013-04-20 16:12:48)
Offline
Liamadams wrote:
Maltese_Falcon wrote:
Maltese_Falcon wrote:
I've been doing a platformer with a walking person (Actually Greek God). He has a series of 5 costumes that he uses when walking.
Here's my script:When gf clicked set [Step v] to [RightFoot] //Make it so that he starts walking with his right foot forever if <key [right arrow v] pressed?> if <(Step) = [RightFoot]> point in direction [90 v] switch to costume [StartRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] secs switch to costume [FullRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] Secs switch to costume [StartRightStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot]> point in direction [90 v] switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] secs switch to costume [FullLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] Secs switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [RightFoot] end end if <key [left arrow v] pressed?> if <(Step) = [RightFoot]> point in direction [-90 v] switch to costume [StartRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] secs switch to costume [FullRightStep v] wait [0.1] secs switch to costume [MiddleRightStep v] wait [0.1] Secs Switch to costume [StartRightStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [LeftFoot] end if <(Step) = [LeftFoot]> point in direction [90 v] switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] secs switch to costume [FullLeftStep v] wait [0.1] secs switch to costume [MiddleLeftStep v] wait [0.1] Secs switch to costume [StartLeftStep v] wait [0.1] secs switch to costume [StandingStill v] set [Step v] to [RightFoot] end endThe problem with this is that when you switch direction in the middle of a step, it has to finish the step it's currently on before switching direction. Any suggestions? Sorry if this is too complicated or if I'm not being very clear.I think I fixed it.
fixed the scratchblocks.
There was an extra end at the end of the forever loop. Anyway, yes, I do have an idea, or ideas, depending on how you look at it. So, somehow you're going to need to change the script so that you can switch directions easily. One method which you shouldn't do is adding in a bunch of if's into your code so that it can exit out easily. For example:
switch to costume [MiddleLeftStep v] wait (0.1) Secs if <key [left arrow v] pressed?> switch to costume [StartLeftStep v] wait (0.1) secs if <key [left arrow v] pressed?> switch to costume [StartLeftStep v] wait (0.1) secs end end
next costume
switch to costume ((costume #) - (1))
Last edited by ErnieParke (2013-04-19 21:27:00)
Offline