class Alice extends MovieClip { //variables var xaccel:Number = 1; var xmov:Number = 0; var ymov:Number = 0; var yaccel:Number = 1; var xlimit:Number = 5; var ylimit:Number = 5; var reboundLimit:Number = 5; var rebound:Boolean = false; var i:Number = 0; // count variable -- limits rebound to i frames var time:Number = getTimer (); var xdir:String = "center"; var ydir:String = "center"; var spin:Boolean = false; var bonkSound:Sound; var hit1x:Number; // var hit2x:Number; // var hit3x:Number; // var hit4x:Number; // These variables track alices position var hit5x:Number; // for hit testing purposes var hit6x:Number; // var y1:Number; // var y2:Number; // var y3:Number; // //functions function aliceMoves () { if (rebound == true) // { // i++; // if (i > 5) // { // rebound = false; // } // } // if (rebound == false) // { // //trace (this._y); // // if (this._y < 86) // { // ymov+=yaccel; // if (ymov > ylimit) // { // ymov=ylimit; // } // ydir = "over"; // //trace (ydir); } else if (this._y > 90) { ymov-=yaccel; if (ymov < -ylimit) { ymov = -ylimit; } ydir = "under"; //trace (ydir); } else if (this._y >=86 && this._y <= 90) { ymov = 0; ydir = "center"; //trace (ydir); } } if (Key.isDown(39) && this._x < 760) { xdir="right"; xmov += xaccel; if (xmov > xlimit) { xmov = xlimit; } } else if (Key.isDown(37) && this._x > 10) { xdir="left"; xmov -= xaccel; if (xmov < -xlimit) { xmov = -xlimit; } } else if (xdir=="left") { xmov += xaccel; if (xmov > 0 ) { xmov = 0; xdir="center"; } } else if (xdir=="right") { xmov -= xaccel; if (xmov < 0 ) { xmov = 0; xdir="center"; } } this._x += xmov; this._y += ymov; //trace (ymov); } function spinAlice () { if (Key.isDown(32) && !spin) { time = getTimer() +400; spin = true; this.gotoAndPlay (2); } if (getTimer() > time) { spin = false; } } function getAlicePosition () { hit1x=this._x; hit2x=this._x+ (this._width*.6); hit3x=this._x; hit4x=this._x+this._width; hit5x=this._x; hit6x=this._x+(this._width *.6); y1=this._y; y2=this._y+ (this._height * .75); y3=this._y+ this._height; /* trace (y1); trace (y2); trace (y3); trace (hit1x); trace (hit2x); trace (hit3x); trace (hit4x); trace (hit5x); trace (hit6x); */ //trace (xmov); <----output accel to output window } function topLeft () { i=0; rebound = true; xmov = reboundLimit; ymov = reboundLimit; _root.ground.collision = false; } function topRight () { i=0; rebound = true; xmov = -reboundLimit; ymov = reboundLimit; _root.ground.collision = false; } function centerLeft () { i=0; rebound = true; xmov = reboundLimit; _root.ground.collision = false; } function centerRight () { i=0; rebound = true; xmov = -reboundLimit; _root.ground.collision = false; } function bottomLeft () { i=0; rebound = true; xmov = reboundLimit; ymov = -reboundLimit; _root.ground.collision = false; } function bottomRight () { i=0; rebound = true; xmov = -reboundLimit; ymov = -reboundLimit; _root.ground.collision = false; } //handlers function onEnterFrame () { if (_root.ground.scrollStop == false) { aliceMoves (); spinAlice (); getAlicePosition (); } /*trace (dir); trace (xmov); */ } //constructor function Alice () { this._y= -100; bonkSound = new Sound (this); bonkSound.attachSound ('bonk'); bonkSound.setVolume(25); } }