I am making a 2D scroller game called evolution. One of the functions is walking & running. Forever, if the up arrow key is pressed, the player moves up. If the up arrow key AND the 'r' key are pressed, the player runs up. This works with every arrow key. I made it so that when you walk, it says:
when gf clicked forever if <pause = 0> if <<key [up arrow] pressed> and <not <key [r] pressed>>> point in direction (0) switch to costume (walk up) wait (speed/10) else if <<key [up arrow] pressed> and <key [r] pressed>> point in direction (0) switch to costume (walk up) wait (speed/25) endand
when gf clicked forever if <pause = 0> if <<key [up arrow] pressed> and <(5) > (walk up)>> if <<not<key [r]>pressed>> change [walk up] by (1) wait (speed/10) else change (walk up) by (1) wait (speed/25) endThe problem is that when I press the up arrow key AND the 'r' key, it moves at the same speed than when I DON'T press the 'r' key, even though I put <(speed) / (10)> when the 'r' key isn't pressed, and <(speed) / (25)> when the r'r key IS pressed. Oh btw, the "speed" variable = 1, but that is something that will change depending on how far ahead you are in the game.
Offline
frank1281 wrote:
when gf clicked forever if <(pause) = [0]> if <<key [up arrow v] pressed?> and <not <key [r v] pressed?>>> point in direction (0 v) switch to costume [walk up v] wait ((speed) / [25]) secs else if <<key [up arrow v] pressed?> and <key [r v] pressed?>> point in direction (0 v) switch to costume [walk up v] wait ((speed) / [25]) secs endandwhen gf clicked forever if <(pause) = [0]> if <<key [up arrow v] pressed?> and <(5) > (walk up)>> if <not<key [r v]pressed?>> change [walk up v] by (1) wait ((speed) / [10]) secs else change [walk up v] by (1) wait ((speed) / [25]) secs end
I fixed up your scripts for you so that people will more easily understand them.
Last edited by henley (2012-07-09 14:23:18)
Offline
I don't see why you don't just do this:
when gf clicked forever if <key [up arrow v] pressed?> switch to costume [walk up v] point in direction (0 v) if <key [r v] pressed?> move [10] steps else move [5] steps end end endIt should work just the same. Unless you want fancy smooth movement. If you want that, I'll post it later
Offline
I don't, because it's a scroller game, which means that the player doesn't move, but the floor moves around him. It's an illusion, more or less. What I'm doing is just changing his costume so that it looks as if he were moving, and the variables are to change how fast his costumes change, therefore it looks as if he were running faster.
Offline
I see.
Then why not just do this?
when gf clicked forever if <key [up arrow v] pressed?> switch to costume [walk up v] point in direction (0 v) if <key [r v] pressed?> set [walk up v] to (10) else set [walk up v] to (5) end end end
Offline