So recently, while taking a Flash class at school, I've become interested at making simple games. So far I've created a basic platform engine, but I wanted to make it better. So I decided to try to implement slope detection into my engine, with a while loop. Though, all it seems to do is freeze up the flash player. Anyone wanna tell me how or why? Here is my code:
`
onClipEvent (load) {
speed = 3;
gravity = 0;
r = _height/2;
jumping = false;
jumpheight = 20;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
gravity = -jumpheight;
jumping = true;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
}
if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (!_root.ground.hitTest(_x, _y, true)) {
gravity++;
_y += gravity;
} else {
jumping = false;
gravity = 0;
}
while (_root.ground.hitTest(_x, _y-1+r, true)) {
jumping = false;
_y--;
}
}