pong game : ball speed slider / racket scripts

  • dirksmith
  • Student
  • Student
  • dirksmith
  • Posts: 78

Post 3+ Months Ago

Hi

I'm adapting a pong game and am having trouble with the relationship between the script controlling the speed of the ball and the script controlling the left (computer) racket.

I've moved the startDrag slider from the top right of the game - to the bottom left - and changed the startDrag co-ordinates. But this has screwed up the left hand racket movement when hitting the tennis ball.


The left racket mc is called 'left'. Can anyone see the part of the script that needs to be changed to get the left racket working as it shld.

U can see the game here:
http://www.dirksmith.com/pong/pongTest.html

script below

Thanx

Dirk





Scene 1
Symbol 13, <diff>
Symbol 12, <setter>
Actions for Symbol 12
onClipEvent (enterFrame) {
/:drag = Math.round(_root.diff._y - this._y)/ -10 ;
}
(empty), (hits1)
(empty), (misses1)
(empty), (hits2)
(empty), (misses2)
Actions for Frame 1
fscommand("allowscale", "false");
Symbol 10, <centre>
Symbol 2, <top>
Symbol 3, <bottom>
Symbol 1, <bal>
Actions for Symbol 1
onClipEvent (load) {
xpos = _root.bal._x;
ypos = _root.bal._y;
}
onClipEvent (enterFrame) {
setProperty(this, _x, this._x + /:xspeed);
setProperty(this, _y, this._y + /:yspeed);
if (this._x >= _root.right._x and this._y >= _root.right._y - 25 and this._y <= _root.right._y + 25) {
_root.bal._x = _root.bal._x-(_root.bal._x-_root.right._x);
/:xspeed = -/:xspeed - 0.2;
/:hits1 = /:hits1 + 1;
}
if (this._x <= _root.left._x and this._y >= _root.left._y - 25 and this._y <= _root.left._y + 25) {
_root.bal._x = _root.bal._x + (_root.left._x - _root.bal._x);
/:hits2 = /:hits2 + 1;
/:xspeed = -/:xspeed;
}
if (this._y < _root.top._y) {
/:yspeed = -/:yspeed;
}
if (this._y >_root.bottom._y) {
/:yspeed = -/:yspeed;
}
if (this._x >= _root.right._x + 12) {
/:misses1 = /:misses1 + 1;
/:xspeed = 0;
/:yspeed = 0;
setProperty("/bal", _x, xpos);
setProperty("/bal", _y, ypos);
}
if (this._x <= _root.left._x - 12) {
/:misses2 = /:misses2 + 1;
/:xspeed = 0;
/:yspeed = 0;
setProperty("/bal", _x, xpos);
setProperty("/bal", _y, ypos);
}
}
Symbol 4, <right>
Actions for Symbol 4
onClipEvent (enterFrame) {
setProperty(this, _y, _root._ymouse );
}
Symbol 5, <left>
play animation 1
Actions for play animation 1
on (rollOver) {
setProperty("/stop", _visible, "1");
}
on (rollOut) {
setProperty("/stop", _visible, "0");
}
on (release, keyPress "<Space>") {
/:xspeed = Random(3) + 3;
/:yspeed = Random(1) + 3;
setProperty("/bal", _x, xpos);
setProperty("/bal", _y, ypos);
}
Symbol 9
Actions for Symbol 9
onClipEvent (enterFrame) {
if (_root.bal._x <= _root.centre._x) {
/:lefty = _root.left._y;
/:baly = _root.bal._y;
if (/:lefty >= /:baly) {
/:speed2 = (/:baly - /:lefty)/(/:drag);
setProperty("/left", _y, /:lefty + /:speed2);
} else if (/:lefty <= /:baly) {
/:speed2 = (/:lefty - /:baly)/(/:drag);
setProperty("/left", _y, /:lefty - /:speed2);
}
}
}
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.