# Mario game

**URL:** <https://forum.kirupa.com/t/mario-game/200705>\
**Category:** Uncategorized\
**Created:** [September 14, 2006, 12:56pm UTC](https://forum.kirupa.com/t/mario-game/200705 "2006-09-14T12:56:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kanu/32/2508_2.png) [@kanu](https://forum.kirupa.com/u/kanu)\
**Post date:** [September 14, 2006, 12:56pm UTC](https://forum.kirupa.com/t/mario-game/200705/1 "2006-09-14T12:56:04Z")

</div>

[COLOR=#191970]\*\*\*\***_code written on Player\_mc_ [/COLOR]  
onClipEvent (load) {  
\_root.restart();  
jumpSpeed = 6;  
bounds = this.getBounds(this);  
function move(x, y) {  
//trace(x);  
jump = false;  
if (!\_root.map.hitTest(\_x+x+bounds.xMin, \_y+y+bounds.yMin, true)) {  
//trace(“move1”);  
if (!\_root.map.hitTest(\_x+x+bounds.xMax, \_y+y+bounds.yMin, true)) {  
//trace(“move2”);  
if (!\_root.map.hitTest(\_x+x+bounds.xMin, \_y+y+bounds.yMax, true)) {  
//trace(“move3”);  
if (!\_root.map.hitTest(\_x+x+bounds.xMax, \_y+y+bounds.yMax, true)) {  
//trace(“move4”);  
\_x += x;  
\_y += y;  
jump = true;  
//trace(\_x);  
}  
}  
}  
}  
return jump;  
}  
}  
onClipEvent (enterFrame) {  
if (\_root.playGame) {  
\_root.falling = move(0, jumpSpeed);  
if (Key.isDown(Key.UP) && !\_root.falling && !\_root.jumping) {  
gravity = -12;  
\_root.jumping = true;  
}  
if (Key.isDown(Key.LEFT) and \_x\>\_root.left) {  
//\_x\>20) {  
//trace(“aaaaaaaaa”);  
move(-jumpSpeed, 0);  
this.gotoAndStop(“left”);  
}  
if (\_root.\_currentframe != 2) {  
if (Key.isDown(Key.LEFT) and \_x\<=\_root.left) {  
\_root.prevFrame();  
this.\_x = \_root.right;  
//810;  
move(-jumpSpeed, 0);  
this.gotoAndStop(“left”);  
}  
}  
if (Key.isDown(Key.RIGHT)) {  
//trace(“bbbbbbbbbb”);  
//\_x\<615) {  
move(jumpSpeed, 0);  
this.gotoAndStop(“right”);  
}  
if (Key.isDown(Key.RIGHT) and \_x\>=\_root.right) {  
//\_x\>=810){  
\_root.restart();  
\_root.nextFrame();  
}  
if (\_root.jumping) {  
if (gravity\<=12) {  
jump = move(0, gravity-jumpSpeed);  
if (jump == false && gravity\<0) {  
gravity _= -1;  
}  
gravity++;  
} else {  
\_root.jumping = false;  
}  
}  
}  
if (this.\_y\>615) {  
\_root.playGame = false;  
\_root.hero.gotoAndStop(“dead”);  
}  
}  
 code on root_**  
var right:Number = \_root.border.\_x+\_root.border.\_width;  
var left:Number = \_root.border.\_x+10;  
var life:Number = 30;  
var score:Number = 0;  
var playGame:Boolean = true;  
function restart() {  
hero.gotoAndStop(“right”);  
jumping = false;  
playGame = true;  
hero.\_x = map.\_x+10;  
hero.\_y = 550;  
}  
function coin(mc:MovieClip) {  
if (mc.hitTest(\_root.hero)) {  
mc.gotoAndStop(“end”);  
\_root.score += 1000;  
removeMovieClip(mc);  
}  
}  
function hit(mc:MovieClip) {  
if (mc.hitTest(\_r[COLOR=#191970]\*\*\*\*\*\*\*\*_ **code written on Player\_mc** _ [/COLOR]

onClipEvent (load) {  
\_root.restart();  
jumpSpeed = 6;  
bounds = this.getBounds(this);  
function move(x, y) {  
//trace(x);  
jump = false;  
if (!\_root.map.hitTest(\_x+x+bounds.xMin, \_y+y+bounds.yMin, true)) {  
//trace(“move1”);  
if (!\_root.map.hitTest(\_x+x+bounds.xMax, \_y+y+bounds.yMin, true)) {  
//trace(“move2”);  
if (!\_root.map.hitTest(\_x+x+bounds.xMin, \_y+y+bounds.yMax, true)) {  
//trace(“move3”);  
if (!\_root.map.hitTest(\_x+x+bounds.xMax, \_y+y+bounds.yMax, true)) {  
//trace(“move4”);  
\_x += x;  
\_y += y;  
jump = true;  
//trace(\_x);  
}  
}  
}  
}  
return jump;  
}  
}  
onClipEvent (enterFrame) {  
if (\_root.playGame) {  
\_root.falling = move(0, jumpSpeed);  
if (Key.isDown(Key.UP) && !\_root.falling && !\_root.jumping) {  
gravity = -12;  
\_root.jumping = true;  
}  
if (Key.isDown(Key.LEFT) and \_x\>\_root.left) {  
//\_x\>20) {  
//trace(“aaaaaaaaa”);  
move(-jumpSpeed, 0);  
this.gotoAndStop(“left”);  
}  
if (\_root.\_currentframe != 2) {  
if (Key.isDown(Key.LEFT) and \_x\<=\_root.left) {  
\_root.prevFrame();  
this.\_x = \_root.right;  
//810;  
move(-jumpSpeed, 0);  
this.gotoAndStop(“left”);  
}  
}  
if (Key.isDown(Key.RIGHT)) {  
//trace(“bbbbbbbbbb”);  
//\_x\<615) {  
move(jumpSpeed, 0);  
this.gotoAndStop(“right”);  
}  
if (Key.isDown(Key.RIGHT) and \_x\>=\_root.right) {  
//\_x\>=810){  
\_root.restart();  
\_root.nextFrame();  
}  
if (\_root.jumping) {  
if (gravity\<=12) {  
jump = move(0, gravity-jumpSpeed);  
if (jump == false && gravity\<0) {  
gravity _= -1;  
}  
gravity++;  
} else {  
\_root.jumping = false;  
}  
}  
}  
if (this.\_y\>615) {  
\_root.playGame = false;  
\_root.hero.gotoAndStop(“dead”);  
}  
}  
 **code on root** _\*\*\*\*  
var right:Number = \_root.border.\_x+\_root.border.\_width;  
var left:Number = \_root.border.\_x+10;  
var life:Number = 30;  
var score:Number = 0;  
var playGame:Boolean = true;  
function restart() {  
hero.gotoAndStop(“right”);  
jumping = false;  
playGame = true;  
hero.\_x = map.\_x+10;  
hero.\_y = 550;  
}  
function coin(mc:MovieClip) {  
if (mc.hitTest(\_root.hero)) {  
mc.gotoAndStop(“end”);  
\_root.score += 1000;  
removeMovieClip(mc);  
}  
}  
function hit(mc:MovieClip) {  
if (mc.hitTest(\_root.hero)) {  
\_root.playGame = false;  
\_root.hero.gotoAndStop(“dead”);  
removeMovieClip(mc);  
\_root.life–;  
}  
}

* * *

is there is anything wrong in this code but still right and left move is not working and jumping is working perfectly fine even with right and left keys.  
oot.hero)) {  
\_root.playGame = false;  
\_root.hero.gotoAndStop(“dead”);  
removeMovieClip(mc);  
\_root.life–;  
}  
}

* * *

is there is anything wrong in this code but still right and left move is not working and jumping is working perfectly fine even with right and left keys.
