# Moving platforms and slopes

**URL:** <https://forum.kirupa.com/t/moving-platforms-and-slopes/58729>\
**Category:** Uncategorized\
**Created:** [July 25, 2004, 6:03pm UTC](https://forum.kirupa.com/t/moving-platforms-and-slopes/58729 "2004-07-25T18:03:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elPooter](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@elPooter](https://forum.kirupa.com/u/elPooter)\
**Post date:** [July 25, 2004, 6:03pm UTC](https://forum.kirupa.com/t/moving-platforms-and-slopes/58729/1 "2004-07-25T18:03:36Z")

</div>

Ok, as everyone might know, I have been working on an art based game for some time now, and I have yet again run into a another problem with the ground. I want to create some moving platforms that go side to side or up and down, and I want the character to be able to walk up and down slopes. My code for the ground goes like this:

```php
  
onClipEvent (enterFrame) {
	if (_root.limits.hitTest(getBounds(_root).xMax, _y, true)) {
		this._x -= 2;
	}
	if (_root.limits.hitTest(getBounds(_root).xMin, _y, true)) {
		this._x += 2;
	}
	if (_root.limits.hitTest(_x, getBounds(_root).yMin, true)) {
		this._y += 5;
	}
	if (_root.limits.hitTest(_x, getBounds(_root).yMax, true)) {
		this._y -= 5;
	}
}  

```

If any one would like to help, please reply. thanks in advance :thumb:.

```
  -El Pooter.
```

---

<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:** [July 30, 2004, 12:35pm UTC](https://forum.kirupa.com/t/moving-platforms-and-slopes/58729/2 "2004-07-30T12:35:49Z")

</div>

how about setting a real limit instead of testing and pushing your character back up?

character.\_y = Math.max(ground.\_y, character.currentY);

Now you have set a limit that the character wil never be able to cross, without limiting other free movement. (this is actually just a if/else statement, but looks nicer)

In this example character.currentY is variable (your character jumping around and stuff), ground.\_y should be pretty constistant, or not, your choice 😉

---

<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:** [July 31, 2004, 11:55pm UTC](https://forum.kirupa.com/t/moving-platforms-and-slopes/58729/3 "2004-07-31T23:55:38Z")

</div>

oh! Thanx man!
