Any help would be greatly appreciated...
I've been programming simple programs for quite a while now. I've been playing this game called Couronne, it's a cue stick based game like billiards. It's played on a perfectly square board although the camera angle makes it look like a trapezoid. You start by placing your ring on the back line of the board, click and drag to aim with the cue, then release to shoot the ring. Here's a screenshot of the game http://img706.imageshack.us/img706/6264/couronnei.png In that screen shot, it's the other player's turn. When it's my turn, I place the ring on the back red line to shoot.
I've been trying to write a program to draw a straight line from my cue stick to the opposite side of the board, reflect off of the back wall, and come back to my side of the board. So I know where exactly my ring will go after hitting the wall. The problem I'm facing is, I don't know the formula for the angle. It's a square board, but to the eye, it looks like a trapezoid because the camera angle. I was wondering if there's a way to figure out the angle of the camera? I was also wondering how I could figure out the angle for the line to reflect off of the back wall. I was also wondering if the angle would have to change the further from the center of the line you get. When you play the game and you put the piece on the line at the right and pull back the cue, it's not straight up and down because of the angle of the camera, so it's harder to judge the angle when you're shooting further from the center. Is there a way I could work around that?
I would greatly appreciate it if you could help me out.
bear with me, it's a complex problem
I don't think you have to take into consideration the view for the game?
You should separate functionality like game and view in your code.
The viewport may draw lines to coordinates placed by the Couronne game. ok?
so in order to make a line in the view of a player, you make an invisible shot tracking the ring. And you draw a line in the viewport with these coordinates, made by an invisible simulation of a shot.
would that work?
Well, I couldn't really make a mock simulation of the shot without knowing the angle formula in the first place.
I guess I could make get it to read which two pixels the line begins and ends and possibly figure every possible angle in the game. If I did that, it'd use A LOT of CPU and it'd be way to robust and complex.
hmm, I thought you had made the game already? Sometimes its hard to pull the 3d coordinates from the game engine so you take the screen/viewport coordinates instead.
I really think you should use a 3d engine for this. the angle of the cue stick will be your least problem I can assure you.
what about depth for example? If a ring is placed closer to the view than another? how will you calculate if a ring drops in a hole? how will you calculate ring interaction? Are those questions already answered?
Can't you simulate it in a regular square and use the coordinates of the line as proportionals for the coordinates in the trapezoid? i.e. point A hits at 4/10 of the right line, B at 2/3 of the back line etc... and then you move those results over to the trapezoids lines.
One problem might be the distance to the center of the square. For some camera settings, half distance is not the perceived half distance but something else. And if you look in the drawing you can see that the distance from half the table is shorter to the back of the table than it is to the front. Since the sides are straight I assume the effect to be proportional.