A Flash Developer Resource Site

1. ## [cs3]

Hi guys .. I'm having a strange problem with my new game.. it's basically volleyball but it's in first person perspective, well kind of.. basically the idea of the game is to return the cpu's return..

An Fancy pong really. .. OK so I've got the 3D element working kind of but having problems with the return.. as in the cpu returning the shot.. I've looked at the code over and over and can't work it out..

Any help would be gratefully received.

Code:
```moveBall = function(returned){

zoomZ = 60;
shiftX = 0;
shiftY = 0;
z0=60;
PZ = {y:190};
//
//PZ={x:0,y:0}
function f3dscale (z) {
//trace(z);
var scale = zoomZ*z0/(z0+z);
return scale;
}

function f3dPoint (x, y, z) {
// trace ("x="+x);
var x3d = (x+shiftX)*f3dscale(z)/100+PZ.x;
var y3d = (y+shiftY)*f3dscale(z)/100+PZ.y;
var pt = {x:x3d, y:y3d};
return pt;
}
function update3dObject (clip, x, y, z) {
//trace(x+"/"+y+"/"+z+"-");
var pt2 = f3dPoint(x, y, z);
clip._xscale =  f3dscale(z);
clip._yscale =  f3dscale(z);
clip.ball_mc._rotation = f3dscale(z*3);
//trace(f3dscale(z));
clip._x = pt2.x;
clip._y = pt2.y;
}
//
function init () {
//
ballHeld = false;
trace("init");
ball.x = 0;
ball.y = -1;
ball.z = 0;
update3dObject(ball, ball.x, ball.y, ball.z);
initSpeed = -42;
initZspeed = 5;
gravity = 1.5;
count = 0;
animate=false;
update3dObject(ball, ball.x, ball.y, ball.z);
scount=false;
num = random(2);
d = random(40)
trace(d);
trace(num);
}
//
function go(returned){
//
ball.onEnterFrame = function(){
trace("go");
//
if (ball.animate == false) {
return;
}else if(ball.animate == true){
//
if(returned){
count--;
this.z -= initZspeed;
this.y -= initSpeed-(gravity/count)-4;

if(this.y >= 150){
//
if(!scount){
trace("Swap layers net")
this.swapDepths(net);
scount=true;
}
}

//
}else{
count++;
this.z += initZspeed;
this.y += initSpeed+(gravity*count)+4;

if(this.y <= 150){
//
if(!scount){
trace("Swap layers net")
this.swapDepths(net);
scount=true;
}
}

}
//X pos
if(d<=19){
trace("-")
ball._x -= randPos[num];
}else{
trace("+")
ball._x += randPos[num];
}
trace("array =" + randPos[num]);
//
if(this.y <= 150){
//
if(!scount){
trace("Swap layers net")
this.swapDepths(net);
scount=true;
}
}
trace("yscaler = "+this._yscale);

//AI
if(this.hitTest(enemy)and this._yscale <=25){

if(!hit){
trace("other player hit");
enemy.gotoAndPlay("jump_1");
delete this.onEnterFrame
//Call
//init();
hit = true;
go(true);
//
}else{
//enemy.gotoAndPlay("jump_0");
}
}
//Player Return Shot
if(this.hitTest(player) and this._yscale >=50){
trace("player hit");
score += 10;
}else{
trace("miss");
}
if (this.y>= 0) {
trace("stop");
ballHeld = true;
delete this.onEnterFrame
initSpeed=0-(initSpeed+(gravity*Count));
this.y+=2*(initSpeed) ;count=0;
if(this.y>=0){this.animate=false;}
}
update3dObject(this, this.x, this.y, this.z);
}
}
}
init();
go();
}```

2. Just realized i forgot to put a subject name doh.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap