# [AS2] Diagonal Movement Problem

5 posts

 Ok so my problem is with the directional controls(up down left right), when i move right and up and press space(which is shoot), my character moves up and to the right and creates a bullet moving right. However, when i press left, up, and space, he will not move up, just shoot and continue to move left. If i press space first and THEN either left or up, he will just move in the first direction, not the second. Here is my code, any help would be appreciated: [Format,](http://www.kongregate.com/forums/4-game-programming/topics/39889-proper-forum-code-formatting-guide) indent, repost. Also, we don’t need a full source dump. Part of your job as a poster requesting help is to narrow down the problem as much as you can: the simpler you make it for us to see what and where your problem is, the faster and more reliable a response you’ll get. So stick to posting the code that is actually relevant to your problem. Anyone trying to sift through your code as presented has my sympathy. Sorry about that, the way i saw it, the more information the better but here you go, this is the movement and shooting section of the main loop in the character: ` if (Key.isDown(Key.RIGHT)) { _x = _x + speed; _xscale = -66; this.gotoAndStop(2); } if (Key.isDown(Key.LEFT)) { _x = _x - speed; _xscale = 66; this.gotoAndStop(2); } if (Key.isDown(Key.UP)) { _y = _y - speed; this.gotoAndStop(2); } if (Key.isDown(Key.DOWN)) { _y = _y + speed; this.gotoAndStop(2); } shootStop += 1; if (Key.isDown(83) && shootStop > 5) { if (_xscale < 0) { _root.soundFX.attachSound("Laser"); _root.soundFX.start(); var bullet = _root.attachMovie("rapT", "rapT" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet._x = _x + 87; bullet._y = _y - 33; shootStop = 0; } if (_xscale > 0) { _root.soundFX.attachSound("Laser"); _root.soundFX.start(); var bullet2 = _root.attachMovie("rapT2", "rapT2" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet2._x = _x - 87; bullet2._y = _y - 33; shootStop = 0; } } //////////////// IDLE SHOOTING RIGHT if (Key.isDown(Key.SPACE) && (!Key.isDown(68)) && (!Key.isDown(83)) and _xscale == -66 and shootStop > 5 && (!Key.isDown(Key.RIGHT))) { _root.soundFX.attachSound("Laser"); _root.soundFX.start(); this.gotoAndStop(1); shootStop = 0; var bullet = _root.attachMovie("rapB", "rapB" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet._x = _x + 87; bullet._y = _y - 33; var bullet = _root.attachMovie("rapB", "rapB" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet._x = _x + 127; bullet._y = _y - 33; var bullet = _root.attachMovie("rapB", "rapB" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet._x = _x + 47; bullet._y = _y - 33; var shot = _root.attachMovie("EnemyHitEffect", "EnemyHitEffect" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); shot._x = _x + 55; shot._y = _y - 35; } //////////////// IDLE SHOOTING LEFT if (Key.isDown(Key.SPACE) && (!Key.isDown(68)) && (!Key.isDown(83)) and _xscale == 66 and shootStop > 5 && (!Key.isDown(Key.LEFT))) { _root.soundFX.attachSound("Laser"); _root.soundFX.start(); this.gotoAndStop(1); shootStop = 0; var bullet2 = _root.attachMovie("rapB2", "rapB2" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet2._x = _x - 87; bullet2._y = _y - 33; var bullet2 = _root.attachMovie("rapB2", "rapB2" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet2._x = _x - 127; bullet2._y = _y - 33; var bullet2 = _root.attachMovie("rapB2", "rapB2" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet2._x = _x - 47; bullet2._y = _y - 33; var shot = _root.attachMovie("EnemyHitEffect", "EnemyHitEffect" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); shot._x = _x - 55; shot._xscale *= -1; shot._y = _y - 35; } //////////////// RUN SHOOTING RIGHT if (Key.isDown(Key.SPACE) && (!Key.isDown(68)) && (!Key.isDown(83)) and _xscale == -66 and shootStop > 5) { _root.soundFX.attachSound("Laser"); _root.soundFX.start(); shootStop = 0; var bullet = _root.attachMovie("rapB", "rapB" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet._x = _x + 60; bullet._y = _y - 33; var bullet = _root.attachMovie("rapB", "rapB" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet._x = _x + 100; bullet._y = _y - 33; var bullet = _root.attachMovie("rapB", "rapB" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet._x = _x + 140; bullet._y = _y - 33; var shot = _root.attachMovie("EnemyHitEffect", "EnemyHitEffect" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); shot._x = _x + 75; shot._y = _y - 35; } /////////////////RUN SHOOTING LEFT if (Key.isDown(Key.SPACE) && (!Key.isDown(68)) && (!Key.isDown(83)) and _xscale == 66 and shootStop > 5) { _root.soundFX.attachSound("Laser"); _root.soundFX.start(); shootStop = 0; var bullet2 = _root.attachMovie("rapB2", "rapB2" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet2._x = _x - 100; bullet2._y = _y - 33; var bullet2 = _root.attachMovie("rapB2", "rapB2" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet2._x = _x - 60; bullet2._y = _y - 33; var bullet2 = _root.attachMovie("rapB2", "rapB2" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); bullet2._x = _x - 140; bullet2._y = _y - 33; var shot = _root.attachMovie("EnemyHitEffect", "EnemyHitEffect" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); shot._x = _x - 75; shot._xscale *= -1; shot._y = _y - 35; } } } ` - Indents do not appear when i post but it is formatted so my apologies, will take any suggestions Wrap your code in pre tags. `
`   myCodeHere   `
` results in ` myCodeHere ` and will preserve formatting. ^^ Thanks for the tip