Sei sulla pagina 1di 2

Jugador: onClipEvent (load) { var grav:Number = 2; // gravity var speed:Number = 10; // how fast you walk var jumpHeight:Number

= 12; // how high you jump var setspeed:Number = speed; var scale:Number = _xscale; var ex:Number = 5; // makes hitTests better, change for a closer hitTest (warning, more bug gy if smalle, less real if further) this.gotoAndStop(2); } onClipEvent (enterFrame) { action = true; grav++; _y += grav; while (_root.nivel.hitTest(_x, _y, true)) { _y--; grav = 0; } if (Key.isDown(68)) { _x += speed; _xscale = scale; if (_root.nivel.hitTest(_x, _y+3, true)) { this.gotoAndStop(1); } else { this.gotoAndStop(2); } } else if (Key.isDown(65)) { _x -= speed; _xscale = -scale; if (_root.nivel.hitTest(_x, _y+3, true)) { this.gotoAndStop(1); } else { this.gotoAndStop(2); } } else { if (_root.nivel.hitTest(_x, _y+3, true) && !Key.isDown(79) && !K ey.isDown(73)) { this.gotoAndStop(3); } } if (Key.isDown(79) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown( 68) && !Key.isDown(73)) { this.gotoAndStop(5); } if (Key.isDown(73) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown( 68) && !Key.isDown(79)) { this.gotoAndStop(4); } if (Key.isDown(87) && _root.nivel.hitTest(_x, _y+3, true)) { grav = -jumpHeight; _y -= 4; this.gotoAndStop(2); } if (_root.nivel.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root

.nivel.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.nivel.hitTest(_x +(_width/2)+ex, _y-_height, true)) { _x -= speed; } if (_root.nivel.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root .nivel.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.nivel.hitTest(_x -(_width/2)-ex, _y-_height, true)) { _x += speed; } if (_root.nivel.hitTest(_x, _y-_height-15, true)) { grav = 1; } } Vcam: onClipEvent (enterFrame) { _y += (_root.jugador._y-_y)/4; _x += (_root.jugador._x-_x)/4; } Muerte: onClipEvent(enterFrame) { if(_root.jugador.hitTest(this)) { _root.jugador._x = 51.2 _root.jugador. y = 243.1 } }

Potrebbero piacerti anche