I'm making this game where the sprite can move using the arrow keys. The sprite can move at 3 different speeds.
Normal speed (nothing extra pressed)
Slow speed (while holding "v")
Fast speed (while holding "b")
I want the sprite to be able to move diagonally if two keys are held down. This works perfectly fine at normal speed but diagonal movement is partly restricted on slow and fast speed.
On slow speed the Sprite can move Diagonally up-right and down-right but not up-left and down-left.
On fast speed, the sprite can move diagonally up-right and up-left but not down-right and down-left. Please help thanks. Here's the script;
when gf clicked <forever> if <key[up arrow]pressed> if <key[b]pressed> change y by (5) else if <key[v]pressed> change y by (1) else change y by (3) end end end if <key[down arrow]pressed> if <key[b]pressed> change y by (-5) else if <key[v]pressed> change y by (-1) else change y by (-3) end end end end
when gf clicked <forever> if <key[right arrow]pressed> if <key[b]pressed> change x by (5) else if <key[v]pressed> change x by (1) else change x by (3) end end end if <key[left arrow]pressed> if <key[b]pressed> change x by (-5) else if <key[v]pressed> change x by (-1) else change x by (-3) end end end end
Offline
Just do "if up AND right arrow clicked," and then separate for each key, for example:
forever if < < key [up arrow v] pressed > and < key [right arrow v] pressed > > if < key [b] pressed > forever if < < key [b] pressed > and < key [up arrow v] pressed > > change y by (5) change x by (5)And so on, doing that separate for each block. You need to remeber to put the green AND block into the hexagon. This takes a lot of scripting, but it works.
Last edited by mythbusteranimator (2012-04-13 14:40:55)
Offline
PhirripSyrrip wrote:
I'm making this game where the sprite can move using the arrow keys. The sprite can move at 3 different speeds.
Normal speed (nothing extra pressed)
Slow speed (while holding "v")
Fast speed (while holding "b")
I want the sprite to be able to move diagonally if two keys are held down. This works perfectly fine at normal speed but diagonal movement is partly restricted on slow and fast speed.
On slow speed the Sprite can move Diagonally up-right and down-right but not up-left and down-left.
On fast speed, the sprite can move diagonally up-right and up-left but not down-right and down-left. Please help thanks. Here's the script;when gf clicked <forever> if <key[up arrow v]pressed ?> if <key[b v]pressed ?> change y by (5) else if <key[v v]pressed ?> change y by (1) else change y by (3) end end end if <key[down arrow v]pressed ?> if <key[b v]pressed ?> change y by (-5) else if <key[v v]pressed ?> change y by (-1) else change y by (-3) end end end endwhen gf clicked <forever> if <key[right arrow v]pressed ?> if <key[b v]pressed ?> change x by (5) else if <key[v v]pressed ?> change x by (1) else change x by (3) end end end if <key[left arrow v]pressed ?> if <key[b v]pressed ?> change x by (-5) else if <key[v v]pressed ?> change x by (-1) else change x by (-3) end end end end
Fixed your script. Should be easier to read now.
Last edited by jontmy00 (2012-04-15 08:48:26)
Offline
mythbusteranimator wrote:
Just do "if up AND right arrow clicked," and then separate for each key, for example:
forever if < < key [up arrow v] pressed > and < key [right arrow v] pressed > > if < key [b] pressed > forever if < < key [b] pressed > and < key [up arrow v] pressed > > change y by (5) change x by (5)And so on, doing that separate for each block. You need to remeber to put the green AND block into the hexagon. This takes a lot of scripting, but it works.
Should be this
repeat until <<<not <key [b v] pressed?>> or <not <key [up arrow v] pressed?>>> or <not <key [right arrow v] pressed?>>> change y by (5) change x by (5) end
Offline