I am having problems working on this project about making a baffle game. I have most of the code written already I just can't figure out how to do the shot laser part and determining where the laser exits the box.

The point of the game is that there are a number of obstructions, called baffles, which you cannot see, placed in the box. The object of the game is to find the baffles. You select a number between 0 and 39, which activates a laser beam originating at that location. You are then told where the beam leaves the box. If the beam does not encounter a baffle, it will exit directly opposite to where it entered. If the beam encounters a baffle, it will be deflected at right angles, either right or left, depending on the direction of the baffle. You can locate the baffles by shooting beams into the box, using the deflections of the beams as hints to the placement and direction of the baffles.

Here is an example of the laser shots:
10 11 12 13 14 15 16 17 18 19
9 |_|_|_|_|_|_|_|_|_|_| 20
8 |_|_|_|_|_|_|_|_|_|_| 21
7 |_|_|_|_|_|_|_|_|_|_| 22
6 |_|_|_|_|_|_|_|_|_|_| 23
5 |_|_|_|_|_|_|_|_|_|_| 24
4 |_|_|_|_|_|_|_|_|_|_| 25
3 |_|_|_|_|_|_|_|_|_|_| 26
2 |_|_|_|_|_|_|_|_|_|_| 27
1 |_|_|_|_|_|_|_|_|_|_| 28
0 |_|_|_|_|_|_|_|_|_|_| 29
39 38 37 36 35 34 33 32 31 30

Again, I am experiencing a lot of trouble with "shooting the laser" and determining where the laser exits the baffle. If you could please help me and guide me to figure out how to go about this it would be greatly appreciated. Thank you so much!! :)

Do you mean like:

Shoot in 23, if there's no baffle it will exit in 6, if there's a baffle, it will exit in for example 12?
Could you post some of your code?

I like the idea, it's an interesting game...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.