schnrfl wrote:
The move () steps block makes it walk in its direction.
You can also use
[if (direction) = {right (which is usually 90}]
[change x by {positive number}]
[if {direction= = {left (which is usually -90)}]
[change x by {negative number}]You can also replace the direction with costumes that face right and left, respectively. If you are making the player so actions such as fight, you have to make left and right versions of every action.
[if (costume) = {number of costume}]
Offline
I am currently developing a platformer called DRAINED and this was how I did it:
I created a variable called Rdir. When the right arrow was pressed, Rdir would equal one. If the left arrow was pressed, Rdir equals 0. This is helpful for changing in the air. Anyway, when right arrow was pressed I would use:
(When (right arrow pressed) )
(set (Rdir) to (1))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
and reverse for left arrow. Hope I answered your question
Offline
astroLoger wrote:
I am currently developing a platformer called DRAINED and this was how I did it:
I created a variable called Rdir. When the right arrow was pressed, Rdir would equal one. If the left arrow was pressed, Rdir equals 0. This is helpful for changing in the air. Anyway, when right arrow was pressed I would use:
(When (right arrow pressed) )
(set (Rdir) to (1))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
(glide (0.1) sec to x: ((xposition) + (7)) y: (yposition))
(switch to costume (whatever))
and reverse for left arrow. Hope I answered your question
Sorry, it got messed up by the automatic blocks.
Hopefully you got the just of it though.
Offline
The easiest way, if you just want the most simple code possible, is:
[blocks]
<when green flag clicked>
<forever>
<if><key[ left arrow ]pressed?
<turn cw( 3 )degrees>
<end>
<if><key[ right arrow ]pressed?>
<turn cw( 3 )degrees>
<end>
<move( 5 )steps>
<end>
I suppose that isn't the easiest way, but that's the best simple way.
Last edited by kayybee (2011-10-24 19:26:51)
Offline