function init() { top = 0; left = 0; bottom = 280; right = Stage.width; vpx = 3; vpy = -4; } vx = 0; vy = 0; gravity = 0.5; bounce = -0.7; debut = getTimer(); Mouse.hide(); init(); onEnterFrame = function () { temps.text = Math.round(getTimer() - debut) / 1000; point._x = point._x + vpx; point._y = point._y + vpy; if (point._x + point._width / 2 > right) { point._x = right - point._width / 2; vpx = vpx * -1; } else { if (point._x - point._width / 2 < left) { point._x = left + point._width / 2; vpx = vpx * -1; } } if (point._y + point._height / 2 > bottom) { delete onEnterFrame; gotoAndStop("perdu"); } else { if (point._y - point._height / 2 < top) { point._y = top + point._height / 2; vpy = vpy * -1; } else { if (0 != (0 != point._y + point._height / 2 > pad._y & 0 != point._x > pad._x - pad._width / 2) & 0 != point._x < pad._x + pad._width / 2) { point._y = pad._y - point._height / 2; vpy = vpy * -1.05; vpx = (point._x - pad._x) / 4; vpy = vpy * 1.05; } } } line._rotation = (Stage.width / 2 - _xmouse) * 0.22; pad._x = _xmouse; vy = vy + gravity; ball._x = ball._x + vx; ball._y = ball._y + vy; if (ball._y > 540) { delete onEnterFrame; gotoAndStop("perdu"); } bounds = line.getBounds(this); if (ball._x > bounds.xMin && ball._x < bounds.xMax) { angle = line._rotation * 3.14159265359 / 180; cosine = Math.cos(angle); sine = Math.sin(angle); x = ball._x - line._x; y = ball._y - line._y; y1 = cosine * y - sine * x; if (y1 > (0 - ball._height) / 2) { x1 = cosine * x + sine * y; vx1 = cosine * vx + sine * vy; vy1 = cosine * vy - sine * vx; y1 = (0 - ball._height) / 2; vy1 = vy1 * bounce; x = cosine * x1 - sine * y1; y = cosine * y1 + sine * x1; vx = cosine * vx1 - sine * vy1; vy = cosine * vy1 + sine * vx1; ball._x = line._x + x; ball._y = line._y + y; } } } ;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question