Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vx = vy = 0;
- fric = .85;
- gravity = .3;
- speed = 1;
- w = _width/2;
- h = _height;
- function onEnterFrame() {
- vx *= fric;
- vy += gravity;
- _x += vx;
- _y += vy;
- if (Key.isDown(Key.LEFT)) {
- vx -= speed;
- }
- if (Key.isDown(Key.RIGHT)) {
- vx += speed;
- }
- grounded = false;
- while (vy >= 0 && (_root.flats.hitTest(_x-w, _y, true) || _root.flats.hitTest(_x+w, _y, true))) {
- _y -= gravity;
- vy = 0;
- grounded = true;
- }
- while (_root.flats.hitTest(_x-w+vx, _y-5, true)) {
- _x += vx+speed;
- vx = 0;
- }
- while (_root.flats.hitTest(_x+w+vx, _y-5, true)) {
- _x += vx-speed;
- vx = 0;
- }
- if (!Key.isDown(Key.UP)) {
- keyLock = false;
- }
- if (Key.isDown(Key.UP) && grounded && !keyLock) {
- vy = -5;
- keyLock = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement