Blau
  • Member for 10 years, 5 months
  • Last seen more than a month ago
4 answers
21 votes
21k views
Calculating minimum velocity of the projectile needed to hit target in parabolic arc
15 votes

Parabolic trayectory function is defined as: Fx = Vox*t + Ox; Fy = -0.5 * g * t * t + Voy*t + Oy; Known values: P: the target point. O: the origin point. g: gravity. t: time needed to ...

View answer
1 answers
6 votes
5k views
How do I get the height of an XNA SpriteFont?
Accepted answer
12 votes

MeasureString() returns to you a Vector2 where the X is the width and Y is the height of the text. Also the SpriteFont class has a LineSpacing member that gives you the height of a line, including ...

View answer
2 answers
7 votes
11k views
How do I enable higher FPS in XNA 4.0?
Accepted answer
11 votes

if Game.IsFixedTimeStep is true the update method will be called every 1/60 seconds http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.isfixedtimestep.aspx "The default value for ...

View answer
2 answers
10 votes
2k views
"Line of sight" path across navigation mesh
Accepted answer
7 votes

You are looking for a funnel algorithm. Here you are a simple one http://digestingduck.blogspot.com.es/2010/03/simple-stupid-funnel-algorithm.html Basically, the algorithm identify edges as ...

View answer
2 answers
5 votes
1k views
What can I do to render generated 2D terrain in XNA?
7 votes

You can create a Texture2D this way. Texture2D Mountain = new Texture2D( GraphicsDevice, Width, Height); Color[] PixelData = new Color[Width * Height]; Color colA,colB; ...

View answer
2 answers
5 votes
3k views
How can I fade something to clear instead of white?
Accepted answer
6 votes

If you work with premultiplied alpha, the default behaviour, you have to multiply the alpha.... public void Update() { color*= 0.95f; position.X += 3; if (color.A <= 10) isDead = ...

View answer
2 answers
1 votes
425 views
XNA 4.0 problem Initializing Instanced Classes in for loop
6 votes

Don't create a random generator in each call to the AddParticle() method. It will return always the same value. Also you may want to pass a different seed to the the generator each time you create ...

View answer
3 answers
-5 votes
2k views
How can I find a point on a line when I have only two other points?
Accepted answer
5 votes

$$ \begin{align} P &= t (B-A) + A \\ P_x &= t (B_x - A_x) + A_x \\ P_y &= t (B_y - A_y) + A_y \\ \end{align} $$ $$ \frac {P_x - A_x} {B_x - A_x} = \frac {P_y - A_y} {B_y - A_y} $$ $$ \...

View answer
2 answers
0 votes
259 views
elongate or scale limbs of a model in XNA
Accepted answer
5 votes

it can be done modifying the bone transform of your model. You don't need submeshes, each vertex in a model should have a bone weight property that quantify how that vertex is affected by the bone ...

View answer
2 answers
0 votes
180 views
How do I make a vector exactly reach a line?
Accepted answer
5 votes

You should calculate the intersection point (IP) between the two lines. (X - Ax) (Y - Ay) EQ1 = -------- = -------- => (X-Ax) * (By-Ay) - (Y - Ay) * (Bx - Ax) = 0; (Bx - Ax) ...

View answer
1 answers
0 votes
569 views
(XNA) Checking coordinates, directly vs List<Vector2> vs Dictionary<X, List<Y>>
Accepted answer
5 votes

bool[,] Rooms = new Rooms[Width, Height]; bool IsPositionAvalaible(int x, int y) { return !Rooms[x,y];} bool SetPositionValue(int x, int y, bool Avalaible) { Rooms[x,y] = !Avalaible; }

View answer
1 answers
1 votes
616 views
How can I create a resizeable 2D camera with parallax scrolling?
4 votes

The X position of the background have to be calculated with the X position of the player and a speed factor. Texture2D ParallaxTex; Rectangle ParallaxBounds = graphics.Viewport.Bounds; ...

View answer
3 answers
0 votes
339 views
Different types of cubes
4 votes

I think are doing over engineering the cubes... it would be easier to use an enum, it is better because let's you indexing cube properties in arrays or sorting the cubes easily, You don't need to ...

View answer
6 answers
24 votes
19k views
How do dialog trees work?
4 votes

You can use TreeSharp and behaviour trees to model a dialogue system. TreeSharp is a library that provides a simple behaviour tree implementation. IA bots for wow are done with this, so it's mature......

View answer
2 answers
0 votes
153 views
List has no value after adding values in
Accepted answer
4 votes

You may have several problems: A) Using string for directions is not a good idea... because the string comparation is slow and case insensitive... is much better using an enumeration or integers......

View answer
3 answers
6 votes
1k views
Debugging a custom content pipeline processor in XNA?
Accepted answer
4 votes

You can launch a external debugger... you only have to add the line System.Diagnostics.Debugger.Launch() and you will can debug it. I think that you maybe need Visual Studio Professional or the .Net ...

View answer
2 answers
4 votes
5k views
What is an efficient packing algorithm for packing rectangles into a polygon?
4 votes

In this sample you can find an algorithm to pack small textures into a big texture, that is quite similar to your matter... and maybe a good start to solve it. http://create.msdn.com/en-US/education/...

View answer
2 answers
2 votes
2k views
Problems using easing equations in C# XNA
4 votes

This are the meanings: t = TimeElapsed =&gt; Range[0, Duration] b = InitialValue; c = FinalValue - InitialValue; d = Duration; I have a similar code to this for every easing function: ...

View answer
2 answers
1 votes
496 views
How to get the result of random item with different possibility?
4 votes

int TotalWeight = 100; int[] ItemWeights = new int[] {80, 10, 10}; enum Items {Apple, Orange, Banana} Items GetRandomItem() { int random = Random.Next(TotalWeight); int i=0; while (...

View answer
3 answers
7 votes
10k views
How do I make objects move along a path?
4 votes

You need a list of points and a list of balloons class Path { List&lt;Vector2&gt; Points; float[] Lengths; Vector2[] Directions; void Build() { Lengths = new float[Points....

View answer
3 answers
6 votes
23k views
How do I find a point given an angle and distance to it?
3 votes

I think this will be enough if you don't use scale. float Angle = RotationTankA - RelativeAngle; PosTankB = PosTankA + new Vector2(cos(Angle), sin(Angle)) * Distance;

View answer
1 answers
0 votes
1k views
render sprites with a transparent background (XNA)
Accepted answer
3 votes

You are drawing all sprites in the same postition and same size, if textures don't have alpha channel you will only see one of them. Test this to draw a grid with 8 columns: var size = 100; ...

View answer
1 answers
0 votes
253 views
Collision Issues
Accepted answer
3 votes

Seems to me that you are not applying the bone transforms. If you are going to evaluate collisions this way, it would be much better to calculate the absolute bounding spheres in world coordinates. ...

View answer
1 answers
1 votes
176 views
How can I make it so that my player object doesn't penetrate world collision when I'm holding down movement keys in that direction?
3 votes

I have drawed this to explain the behaviour when a collision with AABB boxes is present. When you have choosen what dimension has to be fixed, you can change the position of the object that was ...

View answer
2 answers
2 votes
617 views
2D field of view detection inverted
Accepted answer
3 votes

"dot" is a cosin not an angle, can not be compared to "fovRad" that is an angle You can get angle of "dot" with an arccosine function, or get the cosine of "fovRad" to compare them.

View answer
3 answers
8 votes
2k views
How do I make a moving object stop smoothly at the end of a path?
3 votes

You can use XnaTweener that provides easing functions that interpolate values from one point to another in a easy way... Here is a reply with some code based in the Xna Tweener project and a video ...

View answer
5 answers
2 votes
476 views
Particle System in XNA - cannot draw particle
3 votes

you call to base.LoadContent() inside LoadContent and the method is not overrided. Maybe adding the override tag and removing the content manager parameter will do the trick ... public override ...

View answer
1 answers
1 votes
482 views
XNA - Drawing zoomed 2D sprites
Accepted answer
3 votes

Use SamplerState.PointClamp to avoid the GPU interpolating texture coordinates with the nearest points.

View answer
4 answers
4 votes
3k views
XNA - Update vertices property stored in a VertexBuffer
Accepted answer
3 votes

To change a vertex buffer it can't be active: GraphicsDevice.SetVertexBuffer(null); To transfer vertex data to the gpu memory: VertexBuffer.SetData&lt;VertexPositionColor&gt;(VertexData); To ...

View answer
5 answers
6 votes
4k views
How do I add Different Screens to my C#/XNA Game?
3 votes

maybe this method not the best, but for pong game could be enough, and is easy to understand. Make a enum with your states: enum States { Menu, Playing, Pause, Lost, Win, Intro } In your update ...

View answer
1
2 3 4 5