# (Help) - Platform game shoot in both directions

**URL:** https://forum.kirupa.com/t/help-platform-game-shoot-in-both-directions/331740
**Category:** flash
**Created:** [October 10, 2013, 4:28am UTC](https://forum.kirupa.com/t/help-platform-game-shoot-in-both-directions/331740 "2013-10-10T04:28:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![monomega](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@monomega](https://forum.kirupa.com/u/monomega)
#### Post date: [October 10, 2013, 4:28am UTC](https://forum.kirupa.com/t/help-platform-game-shoot-in-both-directions/331740/1 "2013-10-10T04:28:14Z")

</div>

I have been trying to make my character shoot in both directions but so far I only manage to make the bullets or “blasts” to stop when the character faces left, or the character runs right when I shoot, or turns left when I shoot.

stage.focus=stage;  
matazon.gotoAndStop(“stand”);  
var moveRight:Boolean=false;  
var moveLeft:Boolean=false;  
var gravity:Number=2;  
var velocity:Number=1.1;  
var jumpPower:Number=0;  
var isJumping:Boolean=false;  
var ground:Number=630-matazon.height;  
var droneDirection:Number=5;  
var matazonScale:Number=matazon.scaleX;  
import flash.ui.Keyboard;  
stop();

stage.addEventListener(KeyboardEvent.KEY\_DOWN, shootBlast);  
stage.addEventListener(Event.ENTER\_FRAME, runAnimation);  
stage.addEventListener(Event.ENTER\_FRAME, leftWall);  
stage.addEventListener(Event.ENTER\_FRAME, rightWall);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN, jump);  
stage.addEventListener(Event.ENTER\_FRAME, nojump);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN, downKey);  
stage.addEventListener(KeyboardEvent.KEY\_UP, upKey);  
stage.addEventListener(Event.ENTER\_FRAME, moveOver);  
stage.addEventListener(Event.ENTER\_FRAME, matazonFunction);  
stage.addEventListener(Event.ENTER\_FRAME, droneLeft);  
stage.addEventListener(Event.ENTER\_FRAME,checkCollision);

function checkCollision(event:Event) {  
if (matazon.hitTestObject(drone)) {

```
	stage.removeEventListener(KeyboardEvent.KEY_DOWN, shootBlast);
	stage.removeEventListener(Event.ENTER_FRAME, runAnimation);
	stage.removeEventListener(Event.ENTER_FRAME, leftWall);
	stage.removeEventListener(Event.ENTER_FRAME, rightWall);
	stage.removeEventListener(KeyboardEvent.KEY_DOWN, jump);
	stage.removeEventListener(Event.ENTER_FRAME, nojump);
	stage.removeEventListener(KeyboardEvent.KEY_DOWN, downKey);
	stage.removeEventListener(KeyboardEvent.KEY_UP, upKey);
	stage.removeEventListener(Event.ENTER_FRAME, moveOver);
	stage.removeEventListener(Event.ENTER_FRAME, matazonFunction);
	stage.removeEventListener(Event.ENTER_FRAME, droneLeft);
	stage.removeEventListener(Event.ENTER_FRAME,checkCollision);
	removeChild(drone);
	gotoAndStop("endgame");
}

```

}

function shootBlast(event:KeyboardEvent) {  
if (event.keyCode==Keyboard.SHIFT) {  
var Blast:blast=new blast();  
Blast.x=matazon.x+30;  
Blast.y=matazon.y-50;  
addChild(Blast);  
Blast.addEventListener(Event.ENTER\_FRAME, moveBlast);  
}  
}

function moveBlast(e:Event) {  
e.target.x+=5;  
if (e.target.x\>=800) {  
e.target.removeEventListener(Event.ENTER\_FRAME, moveBlast);  
removeChild(MovieClip(e.target));  
}  
}

function runAnimation(event:Event) {  
if (moveRight==true &&(matazon.currentFrame == 14)) {

```
	matazon.gotoAndStop(2);

} else {

	matazon.gotoAndStop(matazon.currentFrame+1);

}

```

}

function rightWall(event:Event) {  
if (matazon.x\<25) {  
matazon.x=25;  
}  
}

function leftWall(event:Event) {  
if (matazon.x\>775) {  
matazon.x=775;  
}  
}

function jump(event:KeyboardEvent) {  
if (event.keyCode==Keyboard.SPACE &&(!isJumping)) {  
jumpPower=25;  
isJumping=true;

```
}

```

}  
function nojump(event:Event) {  
if (isJumping) {  
matazon.y-=jumpPower;  
jumpPower-=2;  
}

```
if (matazon.y+gravity&lt;ground) {
	matazon.y+=gravity;
	matazon.gotoAndStop("jump");
} else {
	matazon.y=ground;
	isJumping=false;

}

```

}

function matazonFunction(event:Event) {  
gravity\*=velocity;  
matazon.y+=gravity;  
if (matazon.hitTestObject(floor)) {

```
	velocity=0;

} else {

	velocity=1.1;

}

```

}

function droneLeft(event:Event) {  
drone.x=drone.x+droneDirection;  
if ((drone.x \< 75) || (drone.x \> 725)) {  
droneDirection=- droneDirection;  
drone.scaleX=- drone.scaleX;  
}  
}

function downKey(event:KeyboardEvent) {  
if (event.keyCode==Keyboard.RIGHT) {  
moveRight=true;  
}  
if (event.keyCode==Keyboard.LEFT) {  
moveLeft=true;  
}

}

function upKey(event:KeyboardEvent) {  
if (event.keyCode==Keyboard.RIGHT) {  
moveRight=false;  
}  
if (event.keyCode==Keyboard.LEFT) {  
moveLeft=false;  
}  
}

function moveOver(event:Event) {  
if (moveRight==true) {  
matazon.x+=20;  
matazon.scaleX=matazonScale;  
} else {

```
	if (moveLeft==true) {
		matazon.x-=20;
		matazon.scaleX=- matazonScale;
	} else {
		matazon.gotoAndStop("stand");
	}

}

```

}
