# Vertical root.\_y Scrolling (Piggy Platformer!)

**URL:** <https://forum.kirupa.com/t/vertical-root--y-scrolling-piggy-platformer/135336>\
**Category:** Uncategorized\
**Created:** [January 26, 2005, 5:47pm UTC](https://forum.kirupa.com/t/vertical-root--y-scrolling-piggy-platformer/135336 "2005-01-26T17:47:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhine](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@rhine](https://forum.kirupa.com/u/rhine)\
**Post date:** [January 26, 2005, 5:47pm UTC](https://forum.kirupa.com/t/vertical-root--y-scrolling-piggy-platformer/135336/1 "2005-01-26T17:47:07Z")

</div>

Note: I moved this from [the mario thread](http://www.kirupa.com/forum/showthread.php?t=69442) as I didn’t want to take the wind away from other people’s queries.

Now then,  
How would you vertical root.\_y scrolling when the character jumps? I got the \_x scrolling down, and it seems simple enough. But the jumping is a real pain.

My example is here: [http://www.rhine.ca/test](http://www.rhine.ca/test)

The piggy can jump and the platform will move down, but when the piggy descends, the platform won’t move back up fast enough. So that means for each jump piggy makes, the platform sinks lower and lower.  
Here’s the code I’m using at the moment. The code in red is what makes the platform move:

```auto

if (Key.isDown(Key.UP) && !jumping) {
			if (left == false) {
				this.gotoAndStop("jump_right");
			}
			if (left == true) {
				this.gotoAndStop("jump_left");
			}
			move = false;
			vel_y = 17;
			jumping = true;
		}
		if (jumping == true) {
			vel_y -= 1;
			if (vel_y<=-17) {
				vel_y = -17;
			}
			this._y -= vel_y;
[color=red] **_root.platform._y += vel_y/5;** [/color]
		}
		if (!_root.platform.hitTest(this._x+25, this._y+10, true) && !jumping) {
			fall += 1;
			move = false;
			if (fall>17) {
				fall = 17;
			}
			this._y += fall;
		}
		for (i=1; i<50; i++) {
			if (!_root.platform.hitTest(_x+25, _y-i, true)) {
				_y -= i-3;
				break;
			} else if (_root.platform.hitTest(_x+25, _y-i, true)) {
				fall = 0;
				vel_y = 0;
				jumping = false;
				move = true;
			}
		}

```

Sources are here:  
Flash MX 2004: [http://www.rhine.ca/test/index.fla](http://www.rhine.ca/test/index.fla)  
Flash MX: [http://www.rhine.ca/test/index\_mx.fla](http://www.rhine.ca/test/index_mx.fla)

Hope someone can help -I’ll personally make them a dish from my [Wagamama](http://www.wagamama.com/)cookbook!
