rotation and angle problem

Non-platform specific questions.

rotation and angle problem

Postby JayInACob » Wed Jun 04, 2008 2:21 pm

im trying to make a pong clone, but in which the player can rotate the board thing to get better shots.

Anyway, i need to get it so the opponent flipper adjusts its angle so it always hits the ball in a specific direction, or better, to hit a specific point on my side of the area.

Any help would be greatly appreciated!! :D
JayInACob
 
Posts: 6
Joined: Fri Aug 17, 2007 5:00 pm
Score: 0 Give a positive score

Re: rotation and angle problem

Postby DST » Sat Jun 07, 2008 5:01 am

Cheat! That's how Capcom does it!

Just make him hit it there! No physical response, no fairness. Make him to what you want!

Make it like this perhaps:

ball>collision>enemyflipper
Code: Select all
ball.angle=direction(x, y, player.x, player.y+rand(100)-50);


Now the ball with move toward player one +- up to 50 degrees in either direction!
You can alter this in any way you want, and of course this might be a problem if player one is on the edge of the screen, as the ball might be hit off the top or bottom.

So add adjustments;

Code: Select all
if (player1.y>-140 && player.y <140){do what i just said}
else if (player 1.y<-140 || player1.y>140){ball.angle=0;}


Now if the player is at the top or bottom, the enemy will hit it straight down the middle!

This is all of course, assuming that the playfield is in a normal horizontal state.

If it rotates, perhaps you can adjust the angle like this:
Code: Select all
ball.angle=direction(x, y, player.x, player.y)+(rand100)-50;


Now the offset will simply be on either angle side of player 1, regardless of whether the playfield is horizontal or vertical.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron