Forum rules: Forum rule Nº 15 is strictly enforced in this subforum.
#94962 by Dman49
Fri Aug 19, 2011 2:26 pm
I am trying to figure out how I can use vector lines. What I want to do is have a line (which you can't see) go from the center of one image to the center of another. I then want this line to detect if there is anything in the way of this line. I'll have 1 image attack another, and I want to be able to have it tell if there is a wall or block in the way of his attack.

If anyone can help it would be much appreciated.
Advertising
#95440 by Zasisem
Sun Aug 21, 2011 7:40 pm
Dman49 wrote:I'll have 1 image attack another, and I want to be able to have it tell if there is a wall or block in the way of his attack.

For this I'm sure I can help you, can you give a bit more detail?
Advertising
#95493 by cmbeke
Sun Aug 21, 2011 11:48 pm
you need to find the equation of the line, and then check for any intersections with walls on any point of the line. check out this for info on how to get the equation of a line with two points, http://www.purplemath.com/modules/strtlneq.htm
#95604 by Dman49
Mon Aug 22, 2011 2:42 pm
Zasisem wrote:
Dman49 wrote:I'll have 1 image attack another, and I want to be able to have it tell if there is a wall or block in the way of his attack.

For this I'm sure I can help you, can you give a bit more detail?


I have a grid. two players are on 2 spaces. One of them needs to be able to see the other if he can attack it. I wan't to know if his field of vision to the other player is blocked by a wall or obstruction. So I need to form 1 line from the middle of one player to the middle of the other.

Who is online

Users browsing this forum: No registered users and 1 guest