2 Replies - 1286 Views - Last Post: 30 November 2009 - 10:08 PM Rate Topic: -----

#1 briany  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-November 09

Adobe Macromedia Flash Game Help

Posted 30 November 2009 - 03:35 PM

Hi im making a tennis game on Adobe Macromedia Flash and my game is just not working.... i was wondering if anybody can help me out

the game im making is a insane tennis game with 2 rackets your racket and the computers racket and with 2 balls u have to hi the balls across the screen trying to make it pass each others racket but my collions does not work for my racket i can move it up and down but thats pretty much it and the computers racket collions work but it wont move... could anybody help me fix my game??? thanks...



Start 
stop();

start_btn.onRelease = function()
{
	gotoAndPlay("instructions")
}
controlValues();						

function controlValues()				
{
	horizontalBallSpeed = 20;			
	verticalBallSpeed = 20;				
	horizontalBall2Speed = 10;			
	verticalBall2Speed = 10;				
	computerRacketSpeed = 2;			
	victoryScore = 60;					
}

Gameplay 
init(); 
stop();

this.onEnterFrame = function()
{
	move();
	checkBoundaries(ball_mc);
	checkBoundaries(ball2_mc);
	checkCollisions(ball_mc,ball2_mc,racket_mc);
	checkCollisions(ball_mc,ball2_mc,opponentRacket_mc);
}
function init()
{
	Mouse.hide();
	ball_mc.dx = horizontalBallSpeed;
	ball_mc.dy = verticalBallSpeed;
	ball2_mc.dx = horizontalBallSpeed;
	ball2_mc.dy = verticalBallSpeed;

	topBoundary = 0;
	bottomBoundary = Stage.height;
	leftBoundary = 0;
	rightBoundary = Stage.width;
	Score = 0;
	playerScore = 0;
}

function move()
{
	Racket_mc._y = _ymouse;
	ball_mc._x = ball_mc._x + ball_mc.dx;
	ball_mc._y = ball_mc._y + ball_mc.dy;
	ballXDist = opponentRacket_mc._x - ball_mc._x;
	ball2XDist = opponentRacket_mc._x - ball2_mc._x;
	if(ballXDist, ball2XDist < opponentRacket_mc._y)
	{
		chaseBall = ball_mc;
	}
	else
	{
		chaseBall = ball2_mc;
	}
	trace(chaseBall);
	
	
	if (ball_mc._y < opponentRacket_mc._y)
	{
		opponentRacket_mc.dy = -opponentRacketSpeed;
	}
	else
	{
		opponentRacket_mc.dy = opponentRacketSpeed;
	}
	opponentRacket_mc._y = opponentRacket_mc._y + opponentRacket_mc.dy;
	
	ball2_mc._x = ball2_mc._x + ball2_mc.dx;
	ball2_mc._y = ball2_mc._y + ball2_mc.dy;
	if (ball2_mc._y < opponentRacket_mc._y)
	{
		opponentRacket_mc.dy = -opponentRacketSpeed;
	}
	else
	{
		opponentRacket_mc.dy = opponentRacketSpeed;
	}
	opponentRacket_mc._y = opponentRacket_mc._y + opponentRacket_mc.dy;
	
} 
function checkBoundaries (sprite_mc)
{
	if(sprite_mc._y + sprite_mc._height/2 > Stage.height)		
	{
		sprite_mc.dy = -sprite_mc.dy;
	}
	if (sprite_mc._x + sprite_mc._width/2 > Stage.width)		
	{
		playerScore = playerScore + 1;
		if (playerScore==victoryScore)
		{
			gotoAndPlay("gameLose");
		}
		else
		{
			reset(sprite_mc);
		}
	}
	if(sprite_mc._y < 0)	
	{
		sprite_mc.dy = -sprite_mc.dy;
	}
	if(sprite_mc._x < 0)
	{
		trace("sprite " + sprite_mc + " just went off left side")
		Score = Score + 1;
		if (Score==victoryScore)
		{
			gotoAndPlay("gameLose");
		}
		else
		{
			reset(sprite_mc);
		}
	}
}
function reset(sprite_mc)
{
	sprite_mc._x = Stage.width / 2.0;
	sprite_mc._y = Stage.height / 2.0;
	sprite_mc.dx = -Math.abs(sprite_mc.dx); 
	sprite_mc._x = Stage.width / 2.2;
	sprite_mc._y = Stage.height / 2.2;
	sprite_mc.dx = -Math.abs(sprite_mc.dx);
}

function checkCollisions (currentBall_mc,currentBall2_mc,currentRacket_mc)
{
	if(currentBall_mc.hitTest(currentRacket_mc))
	{
		currentBall_mc.dx = -currentBall_mc.dx;
		currentBall_mc.dy = dyAdjustment (currentBall_mc,currentRacket_mc)
	}
}
function dyAdjustment (currentBall_mc,currentBall2_mc,currentRacket_mc)
{
	relativeY = currentBall_mc._y - currentRacket_mc._y;
	relativePosition = 2* (relativeY / currentRacket_mc._height);
	dyNew = verticalBallSpeed * relativePosition;
	return dyNew;
}
function checkCollision (currentBall_mc,currentBall2_mc,currentRacket_mc)
{
	if (currentBall_mc.hitTest (currentRacket_mc))
	{
		currentBall_mc.dx = -currentBall_mc.dx
		currentBall2_mc.dx = -currentBall2_mc.dx
		currentBall_mc.dy, currentBall2_mc.dy = dyAdjustment (currentBall_mc, currentBall2_mc, currentRacket_mc)
	}
}
[code]



is this how?? thanks

This post has been edited by briany: 30 November 2009 - 10:07 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Adobe Macromedia Flash Game Help

#2 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 789
  • View blog
  • Posts: 7,623
  • Joined: 05-May 05

Re: Adobe Macromedia Flash Game Help

Posted 30 November 2009 - 07:25 PM

Please use the [code] tags so that your code is much easier to see. And re-post it with tabs, just because you can paste and post doesn't mean we can quickly read it.
Was This Post Helpful? 0
  • +
  • -

#3 briany  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-November 09

Re: Adobe Macromedia Flash Game Help

Posted 30 November 2009 - 10:08 PM

View PostWolfCoder, on 30 Nov, 2009 - 06:25 PM, said:

Please use the [code] tags so that your code is much easier to see. And re-post it with tabs, just because you can paste and post doesn't mean we can quickly read it.


they thanks for telling me about the code ap its much better now thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1