This project is read-only.


Feb 15, 2011 at 1:42 PM

On start , sorry for my bad English.


I create turn based strategy game. Units will have line of sight (FOV), but i don't know how do this.

When i first time see Krytpon i wonder that can i use this for my game.

Is possible to turn off the light effects and draw game normaly with only one point light with fov and us it like line of sight?


or ( i know that this may by problematic) can You tell my with part o Krypton code is responsible for meke fov



Feb 15, 2011 at 2:03 PM

On this, I was wondering if it'd be possible to use the tech for audio occlusion - blocking and fading ambient sounds instead of light.

Feb 15, 2011 at 3:14 PM

Krypton is purely a 2d graphics processing framework. The field of view in krypton simply creates a piece of geometry which is then used to render a texture. As far as what portion of Krypton creates the geometry, you can check out Krypton/Krypton/KryptonRenderHelper.cs inside the method KryptonRenderHelper.DrawClippedFov(...) 

This method takes a field of view, and creates a "field of view" like geometry to render a texture around a specific point, with a color, and size. It *may* be helpful for what you're looking to do.

But, more likely you're looking for either collision detection between a cone and other geometry. For this, you can check out the Farseer Physics Engine (which has some helpful collision detection functions), or Box2D.XNA (which may also be helpful).

Furthermore, if you want a simple way to see if you're looking in the general direction of another point in space, you could simply use a dot product. Vector2.Dot(..., ...) will provide you with a floating point value, which will return a number between 1 and -1, representing "how much" in the direction of one vector another vector is (about the origin of the vectors). You can then retrieve the angle between the two vectors from this dot product.

A dot B = length of A * length of B * cos theta

cos theta = (A dot B) / (length of A * length of B)

or, assuming A and B are unit length, just

cos theta = A dot B 

SO, the angle between two vectors is

theta = cosinv((A dot B) / (length of A * length of B))


double angle = Math.Acos(Vector2.Dot(A, B) / (A.Length() * B.Length()));


I hope I understood the question. Please let me know if this is helpful :), if not I'll see what I can do.

Feb 15, 2011 at 4:11 PM

Thanks for fast replay.


i like to draw fov  (black shape) in my 2d game , and check that my unit (red cicrle) see unit A and unit B

everything else in my game is done , so i don't wan't use farseer engine.

Sorry if my problems takes your time. i know this is Krypton off-top






Feb 15, 2011 at 4:30 PM

As I said before, Krypton is solely used for render at this point, and has no intention of being used for game logic. Again, I would suggest using Farseer or Box2D.XNA and ray-trace the objects to see if it's the first object hit from the light's source position. Krypton has no intrinsic way to calculate these logical field of views at this time.

Feb 15, 2011 at 9:20 PM
Are you asking to check logic if a certain unit can see another unit, or are you asking for the user NOT to be able to see certain units?
Feb 15, 2011 at 9:31 PM


if unit isn't in fov i don't need to draw this unit.


Feb 15, 2011 at 10:53 PM

Usually for 2D, drawing the unit is probably going to be less intensive than calculating it's exact position behind some other sum of objects. Krypton is very fast, and there are typically many hulls that get rendered per light that are already completely in shadow. This is because the cost of determining if they should or should not be rendered is higher than just rendering them.

Unless you need to figure it out for AI purposes, you may be better off just drawing the unit, unless that drawing is *highly* intensive and time consuming.

If, on the other hand, you just need the unit to "disapear" in to the fog of war, I'm working on that in a seperate task. :