# Help me make Mario like game

**URL:** <https://forum.kirupa.com/t/help-me-make-mario-like-game/63819>\
**Category:** programming\
**Created:** [September 10, 2004, 8:13am UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819 "2004-09-10T08:13:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Inferno](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@Inferno](https://forum.kirupa.com/u/Inferno)\
**Post date:** [September 10, 2004, 8:13am UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/1 "2004-09-10T08:13:46Z")

</div>

I just started making games with flash, could someone tell me how to make mario like game (moving, jumping, collecting coins etc.) :rambo:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 1:34pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/2 "2004-09-10T13:34:22Z")

</div>

Well, I made a mario game not to long ago, so what the heck ;). What do you want to learn first?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 2:04pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/3 "2004-09-10T14:04:21Z")

</div>

> [@joMan](#):
>
> Well, I made a mario game not to long ago, so what the heck ;). What do you want to learn first?

Umm how to collect coins… and score.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 2:49pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/4 "2004-09-10T14:49:37Z")

</div>

Well then, let us begin :D. Now, the score keeping is actually quite simple. All you will need to do for this, is create a dynamic text, and give it a variable name of “score” and instance name of “score”. Now select the frame, open the actions panel, and type:

```php
_root.score = 0;

```

This will make the score start at zero when the game starts. Here is an fla for this part of the lesson:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 3:03pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/5 "2004-09-10T15:03:35Z")

</div>

Now for the coins. First, you will need a coin, so Draw a coin and convert it to a symbol with a name of “coin”. Then open it’s properties, and give it an instance name of “coin”. Now, we will want more then just one coin, right? Of course :)! So now, we open the frame again, and after the score code, we type the following:

```php

numCoin = 2;
//this determines the ammount of coins placed on the screen, 2, being the number we use//
for (i=2; i<=numCoin; i++) {
	 coin.duplicateMovieClip("coin1"+i, i+100);
	 //now, this will duplicate the coin and name it//
	 _root["coin1"+i]._x = //wherever you wish to set his Y position//
	 _root["coin1"+i]._y = //wherever you wish to set his X position//
}
 

```

Here is the fla source for this part of the lesson:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 3:09pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/6 "2004-09-10T15:09:15Z")

</div>

Wow :), good, clean, tutorial, JoMan! I Understood every thing you said! Have you ever thought of putting a tutorial on Kirupa?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 3:14pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/7 "2004-09-10T15:14:38Z")

</div>

_blush_ Thanks! I like it when my tutorials make sense. I havent really thought of putting any tutorials up… I dont think I’m experienced enough for that.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 7:32pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/8 "2004-09-10T19:32:55Z")

</div>

Hey cool thanks. Now I have made mario and its movements its name is Hero and so now i want when mario hits the coin the coin disappears and scores.

- ive made the floor and walls platforms 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 7:54pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/9 "2004-09-10T19:54:33Z")

</div>

> [@FlashNewbi3](#):
>
> Hey cool thanks. Now I have made mario and its movements its name is Hero and so now i want when mario hits the coin the coin disappears and scores.
> 
> - ive made the floor and walls platforms 🙂

Good :). Ok, next part commin…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 8:06pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/10 "2004-09-10T20:06:38Z")

</div>

how to make him walk and stuff???:puzzled:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 8:20pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/11 "2004-09-10T20:20:55Z")

</div>

Ok, we have our coin, mario, and the score, right? well now we need mario to obtain the coin. First, we need to edit our coin, so right click the coin and select “edit in place”. Now, create another frame for the coin, and remove the coin picture on the second frame. Now, exit the coin, and open its action panel. Type:

```php

onClipEvent (load) {
	 this.stop();
}
onClipEvent (enterFrame) {
	 if (this.hitTest(_root.mario)) {
		 this.gotoAndStop(2);
		 _root.score +=1;
	 }
}

```

Please reply when you are ready for the next part.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 8:21pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/12 "2004-09-10T20:21:35Z")

</div>

> [@kurez](#):
>
> how to make him walk and stuff???:puzzled:

One minute, post comming…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 8:26pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/13 "2004-09-10T20:26:02Z")

</div>

and also walk on platform…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 8:39pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/14 "2004-09-10T20:39:13Z")

</div>

Yayyy!! Thanks…  
If you would be so kind to help me with the enemies too 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 8:42pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/15 "2004-09-10T20:42:38Z")

</div>

Ok, now for mario. First, we draw mario(or import the sprites), then we convert him to a Symbol and name him “mario”, then we give him an instance name of “mario”. Now, we create his moving, jumping, ducking, and dying sequences. Asuming that you know how to do that, we shall move on to the coding. So, we open mario’s action panel, and type:

```php

onClipEvent (load) {
	 vel_y = 0;
//this will be used for his jumping velocoty//
	 started = true;
//this will be required when we make his movement//
	 jumping = false;
//this will be required when we make his jumping//
	 xspeed = 5;
//this is his movement speed//
	 this.stop(); 
//and this commands him to hault on his standing sequence (asuming that you made his standing sequence on his first frame)//
}

```

Now, we start the moving code. So now type:

```php

onClipEvent (enterFrame) {
	 if (started) {
		 if (move) {
			 if (Key.isDown(Key.LEFT)) {
				 this.gotoAndStop("run");
				 this._xscale = -100;
			 }
			 if (Key.isDown(Key.RIGHT)) {
				 this.gotoAndStop("run");
				 this._xscale = 100;
			 }
			 if (Key.isDown(Key.DOWN)) {
				 this.gotoAndStop("duck");
				 xspeed = 0;
				}
		 }
	 }
} 

```

Mind you, the “if (move) {” will be confirmed later on his ground touching code, or “collision detection”. More coming…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 8:44pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/16 "2004-09-10T20:44:46Z")

</div>

> [@FlashNewbi3](#):
>
> Yayyy!! Thanks…  
> If you would be so kind to help me with the enemies too 🙂

Sure :P. That is included with marios moving.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 9:13pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/17 "2004-09-10T21:13:13Z")

</div>

Now, we need to make mario’s jumping. Note: the jumping will also be needed to make the “goombas” die. Since this code is a bit big, I am going to post half of it now, and half after words (that way I can explain things about it). So, now we type the following:

```php

onClipEvent (enterFrame) {
	 if (started) {
		 if (Key.isDown(Key.LEFT)) {
			 this._x -= xspeed;
		 }
		 if (Key.isDown(Key.RIGHT)) {
			 this._x += xspeed;
		 }
		 if (Key.isDown(Key.UP) && !jumping) {
			 this.gotoAndStop("jump");
			 move = false;
			 vel_y = 17;
			 jumpSound.start();
			 jumping = true;
		 }
		 if (jumping == true) {
			 vel_y -= 1;
		 if (vel_y<=-17) {
			 vel_y = -17;
		 }
		 this._y -= vel_y;
	 }
//continued...//

```

Notice, I put “if (started) {” before this, as well as the previous moving code. That is because I use “started” to control the game’s flow of mario’s actions. For example, If I told the game that started = false, mario would stop all of his actions. Also notice, that “vel\_y” was used. “vel\_y” is to command his actuall jumping, and his jumping speed. Now to continue:

```php

	 if (!_root.ground.hitTest(this._x, this._y+15, true) && !jumping) {
		 fall += 1;
		 move = false;
		 this.gotoAndStop("jump");
	 if (fall>17) {
		 fall = 17;
	 }
	 this._y += fall;
}
if (_root.ground.hitTest(this._x, this._y+15, true)) {
	if (vel_y<=1) {
		fall = 0;
		vel_y = 0;
		jumping = false;
		this.jump.gotoAndStop(2);
		move = true;
	 }
}
//continued...//

```

ah yes, the mighty ground hitTest… As I have promised, the “move” was confirmed as “true” :party:.

```php

if (_root.goomba.hitTest(this.jump)) {
	 if (vel_y<=1) {
		 _root.goomba.gotoAndPlay("dead");
		 _root.goomba.xspeed = 0;
		 _root.counter.play();
		 vel_y = 10;		 
	 }
}
}
}
//end//

```

This is what I like to reffer to as “killing”, because this is what kills the goomba. The:

```php
if (_root.goomba.hitTest(this.jump)) {

```

states that if mario is jumping, and he hits the goomba, he will kill it. By now, I am sure that you have noticed the “\_root.counter.play();”, am I right? Well, that will come later. Stay tuned! There is more to come…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 9:21pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/18 "2004-09-10T21:21:49Z")

</div>

> [@kurez](#):
>
> and also walk on platform…

posted it :D. It’s in the _ **BIG** _ post :hugegrin:.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 9:24pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/19 "2004-09-10T21:24:54Z")

</div>

By the way, if either of you has a question or you just dont understand, dont hesitate to ask and I will do my best to assist you. Or you can PM me here on Kirupa. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2004, 9:38pm UTC](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819/20 "2004-09-10T21:38:50Z")

</div>

If i dont want to make the moving all over again and i still want to kill the goomba. how?  
i have these actions in my mario:

```php
 onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 6;
maxjump = 6;
}
onClipEvent (enterFrame) {
if (air == true) {
_y += gravity;
state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
_x -= walkSpeed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
_x += walkSpeed;
_xscale = scale;
}
if (_root.platforms.hitTest(_x, _y, true)) {
air = false;
} else {
air = true;
}
if (Key.isDown(Key.SPACE) && jump == true) {
_y -= jumpSpeed;
}
if (air == false) {
jump = true;
jumpcount = 0;
jumpSpeed = 19;
}
if (Key.isDown(Key.SPACE)) {
jumpcount += 1;
}
if (jumpcount> maxjump && jumpSpeed> -2) {
jumpSpeed -= 2;
}
if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe <4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe <4) {
state = 1;
}
if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe <4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe <4) {
state = 2;
}
if (!Key.isDown(65)) {
gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}

```

[Next page](https://forum.kirupa.com/t/help-me-make-mario-like-game/63819.md?page=2)
