# Help with mario code

**URL:** <https://forum.kirupa.com/t/help-with-mario-code/65358>\
**Category:** programming\
**Created:** [September 25, 2004, 1:40pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358 "2004-09-25T13:40:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![awketner](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@awketner](https://forum.kirupa.com/u/awketner)\
**Post date:** [September 25, 2004, 1:40pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/1 "2004-09-25T13:40:39Z")

</div>

i’m making a mario style side scroller following the tutorial here: [http://www.kirupaforum.com/forums/showthread.php?t=69442&page=1&pp=15](http://www.kirupaforum.com/forums/showthread.php?t=69442&page=1&pp=15)

BUT…

with my file, when i scroll, sometimes it scrolls too far, AND i was wondering about an array for multiple enemies and how i would go about making a koopa (shell, kicking shell, etc. ) plus i need help with a mario death animation, any help would be appreciated 😏

---

<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 25, 2004, 2:37pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/2 "2004-09-25T14:37:38Z")

</div>

Maybe you should try setting a boundary, like say if he is walking right, and the terrain is at a certain x position (lets say about 400), then the scrollSpeed becomes zero, and he will be allowed to walk (his xspeed will equal 5 or whatever number you most think is necessary). This technique can also be used for the other side.

peace

---

<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 25, 2004, 7:50pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/3 "2004-09-25T19:50:40Z")

</div>

as in when mario reaches a certain x position, the terrain scrolls? or as in when mario reaches a certain point in the terrain? its a saturday, im slow:h: oh, and great tutorial by the way

---

<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 25, 2004, 9:46pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/4 "2004-09-25T21:46:38Z")

</div>

> [@awketner](#):
>
> as in when mario reaches a certain x position, the terrain scrolls? or as in when mario reaches a certain point in the terrain? its a saturday, im slow:h: oh, and great tutorial by the way

No, Mario isnt scrolling, therefore we dont use him to stop the scrolling. We use the terrain. Example: If terrain is at \_x position 50, scrollSpeed = 0 and marioSpeed = 5.

P.S. Thanks for the complement :beam:.

---

<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 26, 2004, 12:58am UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/5 "2004-09-26T00:58:35Z")

</div>

so what you’re saying is to start out with a certain scroll speed? so the terrain is scrolling UNTIL it reaches a certain position, or when it reaches a certain position?

for example:

```php
 on(enterFrame){
scrollspeed = 5;
mariospeed = 0;
groundX = _root.ground._x
}

```

and then

```php
 if(groundX >= 400){
scrollspeed = 0;
mariospeed = 5;
 
etc. etc. etc.

```

---

<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 26, 2004, 3:47am UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/6 "2004-09-26T03:47:41Z")

</div>

Correct. The scrolling will work UNLESS the terrain is at more than 400 (As in your code);

---

<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 26, 2004, 4:17am UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/7 "2004-09-26T04:17:14Z")

</div>

wonderful! thank you

---

<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 26, 2004, 4:48am UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/8 "2004-09-26T04:48:15Z")

</div>

got it… if you think about it, as mario moves, the whole background is scrolling the opposite way, therefore, what you see at the edge of your VISIBLE screen ISNT the x = 0, as x is changing, a possible solution would be to convert a script to make the ground MC move until it reaches a certain point, the question is, how would we go about doing this, my example would be to make an on(Key.isDown()) function to detect when the key is down and making the GROUND scroll during this, and activating the mario running animation, the porblem with this is that it would essentially make mario lock on the center, and im mario games this is not the case, but of course, there are always limitations, especially when it involves my skills. Any other suggestions would be greatly appreciated, or improvements to my plans My other plan would be to make it so in the current view, the left side would be X = 0, and right be x = 400, is this possible? or something of a similar sort?

---

<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 26, 2004, 1:21pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/9 "2004-09-26T13:21:44Z")

</div>

It seems possible, but I’ll have to test it after church. When I’ve got an answer, Ill tell ya.

peace

---

<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 26, 2004, 1:22pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/10 "2004-09-26T13:22:35Z")

</div>

do u still need help with the enemies array and stuff?

---

<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 26, 2004, 8:15pm UTC](https://forum.kirupa.com/t/help-with-mario-code/65358/11 "2004-09-26T20:15:58Z")

</div>

yup
