Little Help Fellow Programmers ?
Well multi in theory , it is all connected through the Ethernet so you can only have LAN battles, it's not the thing that troubles me as I am going to use simple string code words to tell the comp on the other side to do the same things I do on my side.
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
Re: Little Help Fellow Programmers ?
BTW we figured the alt issue and now the account is disabled. Please avoid doing it in the future, those accounts can be used to do nasty things ...
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
-
- Rear Admiral
- Posts:1890
- Joined:Sat Dec 01, 2012 9:39 am
- Affiliation:GLORIOUS REPUBLIC
Re: Little Help Fellow Programmers ?
Just to clarify, this isn't me. Fr0st will tell you as muchTotally not fr0st wrote:You guys are no fun.


Re: Little Help Fellow Programmers ?
We figured it out as I said, no need to worry. I still don't get how I should apply that ray casting method , a diagram would be helpful .
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
- fr0stbyte124
- Developer
- Posts:727
- Joined:Fri Dec 07, 2012 3:39 am
- Affiliation:Aye-Aye
Re: Little Help Fellow Programmers ?
Uh, it looks like this, I suppose.

What you are calculating each loop are the grid point intercepts for each ray. It looks like a lot of calculations, but it is low overhead, and I can show you how to optimize it further if you need more juice.
Depending on how many rays you cast, you can make the sampling more or less accurate, and because you are getting back the point intercepts of the sampling, you can visualize the rays on the screen by drawing shapes with the graphics library you have.
Like I said earlier, the Bresenham line algorithm is even more efficient, but it won't give you intercept points, so it is extra work to visualize.

What you are calculating each loop are the grid point intercepts for each ray. It looks like a lot of calculations, but it is low overhead, and I can show you how to optimize it further if you need more juice.
Depending on how many rays you cast, you can make the sampling more or less accurate, and because you are getting back the point intercepts of the sampling, you can visualize the rays on the screen by drawing shapes with the graphics library you have.
Like I said earlier, the Bresenham line algorithm is even more efficient, but it won't give you intercept points, so it is extra work to visualize.
Re: Little Help Fellow Programmers ?
Well I tried to make the line of sight so that we won't have to do such things with shooting but if we do it already then we should do it properly : I will have standard LoS around tanks that is not blocked by stuff (fairly easy to make) and whenever I shoot I will use that code to see the point where it collides with something. As far as I get it if I Math.Floor( ) the P_new co-ordinates I will get the Tile that the shot collided with so I can edit it. Is it fine like that ? Also in the Tile properties I will change bool isVisiable to int. This way whenever a tank sees or stops seeing a cell I can increase and decrease the count so I know that when it's 0 no other tanks watch this Tile.
BTW as it was buried a few pages ago here is the code you showed me:
BTW as it was buried a few pages ago here is the code you showed me:
fr0stbyte124 wrote:Raycasting would be the easiest. With a set angular resolution, start with a point and an xy vector. You can either dynamically calculate this with trig functions, or pre-compute the full list. The vector doesn't need to be normalized.
Start with a point P and vector D, (assuming positive D.x and D.y, and coordinates are 1 = tile)
stepsX = (Math.Ceiling(P.x) - P.x) / D.x; //number of arbitrary steps to reach next X
stepsY = ((Math.Ceiling(P.y) - P.y) / D.y; //number of arbitrary steps to reach next Y
Whichever is smaller is the first intercept you are going to cross. Have a condition for both, as well as one for the rare condition where stepsX == stepsY. Let's say it stepsX was smaller:
P_new.x = P.x + (D.x * stepsX);
P_new.y = P.y + (D.y * stepsX);
target_tile.x++;
viewDistance++;
Keep going until you go off the map or your viewDistance maxes out.
By changing the number of rays casted, you can change the performance of the routine. One nice thing about this method is you get back points where the ray intersects the grid. You can use this to draw polygons on the screen to visually see what the raycasting is sending back.
There's a much more efficient line generating method called the Bresenham Line algorithm, which you can look up, but the way I showed is easier to understand and debug, so start with that.
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
Re: Little Help Fellow Programmers ?
Frost a small question:
I tried to use this little piece of code to get the local area connection IP:
IPAddress ip;
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); // get local IP addresses
ip = localIPs[2]; // is local address ... or at least on my comp
The problem is that this code returns a whole bunch of IPs and the IP I need is changing location in the array all the time (depending on the computer).
How can I pinpoint the correct address I can use to setup a local Ethernet server using my TcpListener server; for getting incoming clients and transmissions.
Also can I start the server program from inside my main program ? (I mean they are in different projects, one windows for and one console application)
I tried to use this little piece of code to get the local area connection IP:
IPAddress ip;
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); // get local IP addresses
ip = localIPs[2]; // is local address ... or at least on my comp
The problem is that this code returns a whole bunch of IPs and the IP I need is changing location in the array all the time (depending on the computer).
How can I pinpoint the correct address I can use to setup a local Ethernet server using my TcpListener server; for getting incoming clients and transmissions.
Also can I start the server program from inside my main program ? (I mean they are in different projects, one windows for and one console application)
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
- fr0stbyte124
- Developer
- Posts:727
- Joined:Fri Dec 07, 2012 3:39 am
- Affiliation:Aye-Aye
Re: Little Help Fellow Programmers ?
If the computers have a distinctive name, you can do it like this
Dns.GetHostAddresses("Some PC-Name");
If you need a true peer-to-peer network, where you define a single endpoint which is the same for every peer, and has no managing servers, you should look into WCF+PNRP. There's a lot to learn and set up, though, and it complicates everything.
Unless you have a very good reason for not using a centralized host server, I would stick with that. If you don't want to hard code a static IP and don't have a computer name to use, check out http://www.noip.com/. It's free and lets you make a temporary URL for an IP address, including intranet IPs.
Dns.GetHostAddresses("Some PC-Name");
If you need a true peer-to-peer network, where you define a single endpoint which is the same for every peer, and has no managing servers, you should look into WCF+PNRP. There's a lot to learn and set up, though, and it complicates everything.
Unless you have a very good reason for not using a centralized host server, I would stick with that. If you don't want to hard code a static IP and don't have a computer name to use, check out http://www.noip.com/. It's free and lets you make a temporary URL for an IP address, including intranet IPs.
Re: Little Help Fellow Programmers ?
I'm back to that raycasting method. What I lack the understanding of is what exactly is the point of vector D - is it the shooting co-ordinates or the location of the next intercept ? P is the tank right ? It seems like I should one of them to the last intercept in order to get new results ....
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
- fr0stbyte124
- Developer
- Posts:727
- Joined:Fri Dec 07, 2012 3:39 am
- Affiliation:Aye-Aye
Re: Little Help Fellow Programmers ?
D, simply put, is the direction for each ray you cast outward from the tank. P is a point starting at the tank and moving outward along D. By looping that code, or whatever it ends up looking like, it should stop at the border between every tile, at which point you can check to see if there is an obstacle in the way. If not, keep going until you get to the edge of the tank's firing range. Those tiles which no ray passed through cannot be hit.
Remember, though, that I haven't actually seen this game, so I am trying to read your mind as to how the game is supposed to work.
Remember, though, that I haven't actually seen this game, so I am trying to read your mind as to how the game is supposed to work.
Re: Little Help Fellow Programmers ?
I was trying to figure out how to use this method for checking the obstacles in front of the projectile without using the PoV but alright ...
Anyway in the meantime I came with another, maybe less efficient but good enough for me way to calculate the obstacles in the way of the tank: I have the origin point and the projectile's destination point. I build an equation using those points for a line (I dunno what kind of lines you make but my line looks like y = mx + n , case of a line parallel to the Y axis is viewed separately).
Now previously (because it was the case on my sketch and I am a dumbbutt -.- ) I altered between the x and y co-ordinates as I noticed that the line crossed once x then y then x then y, so all I needed is to put that x or y value and get the point but eventually I did notice it doesn't work for lower angles as the line passes a few times through x (or for y in an opposite example) before crossing another axis.
I need a condition to figure out when I should put x cord and see at which y it intersects or the opposite. If I get this I will have it figured and I will be able to explain to the examiner what the hell I did there for a change -.- .
Anyway in the meantime I came with another, maybe less efficient but good enough for me way to calculate the obstacles in the way of the tank: I have the origin point and the projectile's destination point. I build an equation using those points for a line (I dunno what kind of lines you make but my line looks like y = mx + n , case of a line parallel to the Y axis is viewed separately).
Now previously (because it was the case on my sketch and I am a dumbbutt -.- ) I altered between the x and y co-ordinates as I noticed that the line crossed once x then y then x then y, so all I needed is to put that x or y value and get the point but eventually I did notice it doesn't work for lower angles as the line passes a few times through x (or for y in an opposite example) before crossing another axis.
I need a condition to figure out when I should put x cord and see at which y it intersects or the opposite. If I get this I will have it figured and I will be able to explain to the examiner what the hell I did there for a change -.- .
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
- fr0stbyte124
- Developer
- Posts:727
- Joined:Fri Dec 07, 2012 3:39 am
- Affiliation:Aye-Aye
Re: Little Help Fellow Programmers ?
Copying this again for reference. If you are familiar with parametric equations, you can think of this as one of those. One of the advantages to this is that you can treat the x axis and the y axis the same way. Here, you calculate the distance to the next tile crossing in the x direction and the y direction. Whichever has a shorter distance is the first one you cross. You can even reuse the result from the previous loop, but it is cheap enough that there isn't much need.fr0stbyte124 wrote: Start with a point P and vector D, (assuming positive D.x and D.y, and coordinates are 1 = tile)
stepsX = (Math.Ceiling(P.x) - P.x) / D.x; //number of arbitrary steps to reach next X
stepsY = ((Math.Ceiling(P.y) - P.y) / D.y; //number of arbitrary steps to reach next Y
Whichever is smaller is the first intercept you are going to cross. Have a condition for both, as well as one for the rare condition where stepsX == stepsY. Let's say it stepsX was smaller:
P_new.x = P.x + (D.x * stepsX);
P_new.y = P.y + (D.y * stepsX);
target_tile.x++;
viewDistance++;
Whether you do that or not is up to you, but I would strongly recommend against using a linear equation unless you have a very good reason for doing it. There are too many caveats and special cases to deal with, and ends up greatly over-complicating things. Video games always use vector math.
Re: Little Help Fellow Programmers ?
Well there is only one case I need to view: when the line is parallel to the Y axis, the rest is easy if you know when to switch between putting X in and putting Y in.
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN
- fr0stbyte124
- Developer
- Posts:727
- Joined:Fri Dec 07, 2012 3:39 am
- Affiliation:Aye-Aye
Re: Little Help Fellow Programmers ?
...Well I'm sure you can handle it. Let me know if you run into any more snags.
Re: Little Help Fellow Programmers ?
The reasoning why I want to stick to my plan is because it is my plan, and as more parts of my work are actually mine in this project the better. If I can find my own solution that works decently it is usually the best.
They're watching ... 
"I am forbidden tag" -CvN

"I am forbidden tag" -CvN