# MX- i have no idea what im doing

**URL:** <https://forum.kirupa.com/t/mx-i-have-no-idea-what-im-doing/9014>\
**Category:** flash\
**Created:** [December 3, 2002, 2:38am UTC](https://forum.kirupa.com/t/mx-i-have-no-idea-what-im-doing/9014 "2002-12-03T02:38:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fez](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@fez](https://forum.kirupa.com/u/fez)\
**Post date:** [December 3, 2002, 2:38am UTC](https://forum.kirupa.com/t/mx-i-have-no-idea-what-im-doing/9014/1 "2002-12-03T02:38:21Z")

</div>

just so you all know, i didnt actually write this code. so im not really as smart as i may seem…getting back to the point, what im looking for is a semi thorough explanation for the following lines. excluding this  
and this  
and this

```php
init();
function init() {
	right = 500;
	left = 50;
	top = 50;
	bottom = 350;
	ball.vx = Math.random()*20-10;
	ball.vy = Math.random()*20-10;
	ball.onEnterFrame = move;
	pc.onEnterFrame = function() {
		this._y = ball._y;
	};
	player.onEnterFrame = function() {
		this._y = _root._ymouse;
	};
	Mouse.hide();
}
function move() {
	this._x += this.vx;
	this._y += this.vy;
	playerBounds = player.getBounds(_root);
	if (this._x>right-this._width/2) {
		if (this._y>playerBounds.yMin && this._y<playerBounds.yMax) {
			this.vx *= -1;
			this._x = right-this._width/2;
		} else {
			this._x = 275;
			this._y = 200;
			this.vx = Math.random()*20-10;
			this.vy = Math.random()*20-10;
			pcScore++;
		}
	}
	pcBounds = pc.getBounds(_root);
	if (this._x<left+this._width/2) {
		if (this._y>pcBounds.yMin && this._y<pcBounds.yMax) {
			this.vx *= -1;
			this._x = left+this._width/2;
		} else {
			this._x = 275;
			this._y = 200;
			this.vx = Math.random()*20-10;
			this.vy = Math.random()*20-10;
			playerScore++;
		}
	}
	if (this._y>bottom-this._height/2) {
		this.vy *= -1;
		this._y = bottom-this._height/2;
	}
	if (this._y<top+this._height/2) {
		this.vy *= -1;
		this._y = top+this._height/2;
	}
}

```

cheers  
fez

ps. its a pong sort of game btw

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 3, 2002, 3:19am UTC](https://forum.kirupa.com/t/mx-i-have-no-idea-what-im-doing/9014/2 "2002-12-03T03:19:20Z")

</div>

Repost the code using the php tag. There are problems when you use \< and \> .

Nice code, by the way. Which part did you not understand?

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 3, 2002, 5:38pm UTC](https://forum.kirupa.com/t/mx-i-have-no-idea-what-im-doing/9014/3 "2002-12-03T17:38:38Z")

</div>

Yeah, nice code. I definitly agree, who wrote it?

Peace

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 3, 2002, 7:41pm UTC](https://forum.kirupa.com/t/mx-i-have-no-idea-what-im-doing/9014/4 "2002-12-03T19:41:53Z")

</div>

im not sure exactly who wrote it, i got it from h88 in a reply to one of my other posts.  
credit goes to anonymouse fro writing it

```php

init();
function init() {
right = 500;
left = 50;
top = 50;
bottom = 350;
ball.vx = Math.random()*20-10;
ball.vy = Math.random()*20-10;
ball.onEnterFrame = move;
pc.onEnterFrame = function() {
this._y = ball._y;
};
player.onEnterFrame = function() {
this._y = _root._ymouse;
};
Mouse.hide();
}
function move() {
this._x += this.vx;
this._y += this.vy;
playerBounds = player.getBounds(_root);
if (this._x>right-this._width/2) {
if (this._y>playerBounds.yMin && this._y this.vx *= -1;
this._x = right-this._width/2;
} else {
this._x = 275;
this._y = 200;
this.vx = Math.random()*20-10;
this.vy = Math.random()*20-10;
pcScore++;
}
}
pcBounds = pc.getBounds(_root);
if (this._x if (this._y>pcBounds.yMin && this._y this.vx *= -1;
this._x = left+this._width/2;
} else {
this._x = 275;
this._y = 200;
this.vx = Math.random()*20-10;
this.vy = Math.random()*20-10;
playerScore++;
}
}
if (this._y>bottom-this._height/2) {
this.vy *= -1;
this._y = bottom-this._height/2;
}
if (this._y this.vy *= -1;
this._y = top+this._height/2;
}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 3, 2002, 7:44pm UTC](https://forum.kirupa.com/t/mx-i-have-no-idea-what-im-doing/9014/5 "2002-12-03T19:44:08Z")

</div>

lol…parts i didnt understand…lets see…  
basically all of it, although there are little snippets which i can figure out. if a detailed explanation is too muhc, could anyone repost the code to make it move in the other direction, ie i want the paddle to be at the bottom, moving left and right, not up and down. the ball i guess should do the same. i can get the boundaries myself, just cant seem to tweak the rest of the code right

cheers
