Morphling is right about detecting slope, but I might as well explain how the map itself works in case you or anyone else is interested. I don't know if it's the best method, but this is a general overview of how I did it:
1) The ball is hit. Previously, the players' and ball's coordinates are detected using
Kenoli's method and kept in respective counters (we'll call them playerX, playerY, ballX, ballY). How far the players moved from last cycle (which is essentially the slope the ball has to move in) can be detected using the same method. For instance, let's say player 1 moves his zealot 1 pixel up and 1 pixel to the right. His 'slope' would be 1/1, and we'll place them in slopeX, slopeY.
2) Next it detects the distance of the ball and the two borders it can possibly collide in (in this case, it will be the top and right border). Let's say ballX = 52 and ballY = 50, the top border is 100 and the right border is 100. The absolute value of (ballX - right border) = 48, and the absolute value of (ballY - top border) = 50. We'll put these values in counters distanceX, distanceY.
3) Now we detect which of these two values is lower: (distanceX / slopeX), and (distanceY / slopeY). Why? Because the lower of those two quotients will be the dimension border the ball will land on. Since (distanceX / slopeX) is the lower of the two, we'll call the situation "X Recessive", and we know that the place to order the ball will be somewhere in the right border, so we can set systemX (the counter for the location grid) to the right border (100). Now it's just a matter of the Y dimension.
4) To find the dominate dimension coordinate to order the ball (Y dimension), the formula in this case is (distanceX / slopeX) multiplied by slopeY. You would multiply distanceX and slopeY, then divide it by slopeX, which produces systemY.
5) systemX and systemY are set appropriately for the location grid system to place the location, then the scourge would be ordered. The rest of the triggers (scoring, victory) is obvious.
I didn't explain a lot of why it does what it does, because it would over complicate things. But yeah. I was in an explaining mood. Ask questions if you have any.
Post has been edited 1 time(s), last time on Dec 29 2009, 3:09 am by yoonkwun. Reason: bad example
None.