# Tagged Questions

106 views

### How can I properly rotate a 2D vector in the “flipped” XNA client space?

In my 2d XNA game, because SpriteBatch treats world space as client space and has positive Y axis down and negative up, I've built my game's world space with that coordinate system too. However, I've ...
127 views

### How do I find two points at an angle on opposite sides of a circle?

With reference to my previous question: I'm using micklh's answer, which works perfectly. However, it calculates the gradient based on two points, a starting point and an ending point. I want to ...
181 views

### Code to generate a color gradient within a texture using a diagonal line

I want to generate a color gradient between two colors from x1,y1 to x2,y2. I'm unsure how to do this though. I can use Color.Lerp to get all of the color steps, but the problem is that I don't ...
214 views

### In a semi-infinite procedural (chunk based) map, how do you handle objects larger than a single chunk?

I'll use an example to try and be more specific. Assume this is for a 2D top-down game. Chunks in this are made up of 32x32 tiles. If procedural buildings were to be generated based on some kind of ...
48 views

### Percentages for different platform generation [duplicate]

I have a level manager, which creates levels and levels create platforms. Levels can contain a variety of platforms. I dont really understand how I can say: I want a 10% of one platform being ...
103 views

### Automatically zoom out the camera to show all players

I am building a game in XNA that takes place in a rectangular arena. The game is multiplayer and each player may go where they like within the arena. The camera is a perspective camera that looks ...
521 views

### Why does the order matter in multiplication of matrixes?

I stumbled on this question because I had the same problem with my camera, and changing the multiplication order worked. I ran into a similar problem when scaling a model. This code produced the ...
293 views

### Rotate around the centre of the screen

I want my camera to rotate around the centre of screen and I'm not sure how to achieve that. I have a rotation in the camera but I'm not sure what its rotating around. (I think it might be rotating ...
137 views

### Rotating sprite 180 deg

I should say first, that I have the rotation down. Its just that I want my square to rotate exactly 180 degrees. Currently, it will rotate but it will rotate but by less each jump. So after several ...
1k views

### how to rotate enemy to face player? [duplicate]

Okay so i havebeen rotating my enemy to face the player using float targetrotation = Math.Atan2(playerpos-enemypos); enemy.rotation = targetrotation; (<this line of code i want to change) This ...
637 views

### 360+ degree rotation skips back to 0 degrees when using Math.Atan2(y, x)

I'm new to XNA and this is my first actual project, so forgive my noobness. I'm using jointAngle = System.Math.Atan2(RightStick.Y, RightStick.X); in order to set an angle of a joint (farseer) so ...
311 views

### Min/Max of two vectors?

This seems like a simple question, but i'm having trouble searching the internet for it. In XNA, during a collision detecting method, I would determin the minimum of some vectors. // Get the minimum ...
238 views

### Vector vs Scalar velocity?

I am revamping an engine I have been working on and off on for the last few weeks to use a directional vector to dictate direction; this way I can dictate the displacement based on a direction. ...
271 views

### How can I get a 2D texture to rotate like a compass in XNA?

I'm working on a small maze puzzle game and I'm trying to add a compass to make it somewhat easier for the player to find their way around the maze. The problem is: I'm using XNA's draw method to ...
978 views

### Simulating a sine wave/oscillating pattern for enemies

I'm creating a simple top down shooter, right now I have an enemy which simply follows the player. I'd like to change things up and have the enemies move towards the player but in a wave like motion. ...
210 views

### How to offset particles from point of origin

Hi I'm having troubles off setting particles from a point of origin. I want my particles to spread out after a certain radius from a the point of origin. For example, this is what I have right now: ...
369 views

### Calculating the correct particle angle in an outwards explosion

I'm creating a simple particle explosion but am stuck in finding the correct angle to rotate my particle. The effect I'm going for is similar to this: Where each particle is going outwards from the ...
497 views

### Breakout… Getting the ball reflection X angle when htitting paddle / bricks [duplicate]

Im currently creating a breakout clone for my first ever C# / XNA game. Currently Ive had little trouble creating the paddle object, ball object, and all the bricks. The issue im currently having is ...
211 views

### Determining my playable area/field of view

Contrary to what I found searching for the answer, I'm not trying to see whether a character is in view of another character. What I need to find out is the size of the field of view. This is because ...
337 views

### Rotation matrices from Quaternion.Identity and -Quaternion.Identity are the same?

If I create a rotation matrix from an identity quaternion then it is the same as a creating it from a negative identity quaternion Matrix m0 = ...
394 views

### Implementing framerate independence

I know the following line of code has the effect of moving 3 units per milliseconds independent of framerate, but my sucky mathematical intuition is unable to understand WHY this works translation *= ...
209 views

### Question about Target parameter of Matrix.CreateLookAt

I have a newbie question that's causing me a little bit of confusion when experimenting with cameras and reading other peoples implementations - does this parameter represent a point or a vector? In ...
712 views

### When to use Euler vs Axis angles vs Quaternions?

I understand the theory behind each but I was wondering if people could share their experiences in when one would use one over the other For instance, if you were implementing a chase camera, a ...
1k views

### Orthographic Camera Zooming

In XNA I am using a spritebatch to render a board. I have created a camera class which can provide me a view and projection matrix. Currently I am supplying the view matrix to my sprite batch when I ...
361 views

I am creating a quad that starts as a single quad, then divides itself multiple times (from 1 -> 4 -> 16 -> 64 -> 256 etc) but I have encounted an issue. When I get to 64 sub divisions only 16 quads ...
262 views

### Can someone explain this Pulsate code to me

// Pulsate the size of the selected menu entry. double time = gametime.TotalGameTime.TotalSeconds; float pulsate = (float)Math.Sin(time * 6) + 1; scale = new Scale(1 + pulsate * 0.05f,1 + pulsate * ...
841 views

### XNA: How to Flip/Mirror a position over a custom vector?

I want to flip Horizontally my Sprite/Texture however the SpriteEffects.FlipHorizontally isn't cutting it for me as it just flips the texture in place. I want to flip the texture over a specified ...
374 views

### How do I create weapon attachments?

My question is; I am developing a game for XNA and I am trying to create a weapon attachment for my player model. My player model loads the .md3 format and reads tags for attachment points. I am able ...
197 views

### How to make sure that a Point A moving in the direction V reaches at Point B?

Let say I have, Point A(X1,Y1) moving in the direction V(W, H). I need to make sure that it reaches B(X2,Y2). I think I need to subtract some value in Point A(X1, X2). But not know what? I also sure ...
175 views

### Calculate the direction, From Outer Polygon Point to Inner Polygon inside Point

I was able to find the co-ordinates of inner Polygon using this trick. Need the co-ordinates of innerPolygon But, I have some problem in getting the direction from Outer Polygon Point to Inner ...
90 views

### Need the co-ordinates of innerPolygon

Let say I have this diagram, Given that i have all the co-ordinates of outer polygon and the distance between inner and outer polygon is d is also given. How to calculate the inner polygon ...
2k views

### How to move a line of sprites in a sine wave?

So, I'm spawning a horizontal line of enemies that I would like to have move in a nice wave. Currently I tried: Enemy.position.X += Enemy.velocity.X; Enemy.position.Y += ...
374 views

### Confused about order of operation when using a Matrix in XNA, C#

Here are two different pieces of code This is what I started with Vector2 hold = Vector2.Transform(pos1, mat1); Matrix inv = Matrix.Invert(mat2); Vector2 pos2 = Vector2.Transform(hold, inv); And ...
497 views

### Problems with 3D rotation when creating a 3D skeleton

I am writing a simple BVH parser in C# using the XNA framework. At the moment I have managed to parse in all the data and my goal is to find out the global coordinates of all the joints in the ...
669 views

### Function for sun movement?

So, given a sun sprite set at the horizon (x = 0, y = worldheight/2) I'm trying to devise a function to make the sun rise, then fall. The best way to do this would be the sin function, but I have no ...
498 views

### Moving along a flat plane with accordance to camera view

I'm making a 3D game, and I'm stuck on a little experiment. I currently have a flat plane with a free camera running around, and a sphere (really, a light approximated as a sphere) that rests above ...
956 views

### Line segment / circle intersection - X value seems wrong?

Major Edit I'm making a Breakout clone, and having difficulty with collision detection between a circle and line segment. Apologies, my earlier question was a result of frustration and no sleep :) ...
5k views

### Get position of point on circumference of circle, given an angle?

I would like to know how to get a specific point on the circumference of a circle, given an angle. The diameter of the circle is 1, and the center point of the circle is { X: 0.5, Y: 0.5 }.
4k views

### Getting the angle between two objects?

I have a set of boxes which create a sort of path, they don't intersect very smoothy and to help that process I'm trying ot find a way to get an angle between them that can make it easier to generate ...
178 views

### An ellipse outside two points?

I am trying to generate an ellipse outside two points (two-dimensional vectors). Is there a formular for that, or a cool way of doing that in C# XNA? What I am trying to do is have a particle circle ...
3k views

### Determine arc-length of a Catmull-Rom spline

I have a path that is defined by a concatenation of Catmull-Rom splines. I use the static method Vector2.CatmullRom in XNA that allows for interpolation between points with a value going from 0 to 1. ...
897 views

### Are game programmers aware of all the physics derivatives?

I am trying to study XNA for game programming. XNA has many methods that can simplify developer's life, such as reflecting the vector when it hits a solid plane. I know these are good and developers ...
505 views

### Get intersection of vector in the middle of the screen

My screen resolution is 640x480 and I have two Vector2 objects located at (10,10) and (600, 320). How can I connect these two objects and extend the line to encompass the whole screens width, how can ...
485 views

### Calculating and detecting curves

How can I detect the 'steepness' of a curve? For example, if the user swipes their finger across the screen in a curve, what's the best way of detecting whether the curve is almost a semi-circle, or ...
950 views

### Physics timestep questions

I've got a projectile working perfectly using the code below: //initialised in loading screen 60 is the FPS - projectilEposition and velocity are Vector3 types gravity = new Vector3(0, ...
386 views

### XNA - Weird bug with 2D Sprite Rotation

I have a problem with my XNA Game, I have a function where I need my sprite to face towards an enemy, using this code: Vector2 currentPosition = Position; Vector2 nearestEnemy = ...
1k views

### snapping an angle to the closest cardinal direction

I'm developing a 2D sprite-based game, and I'm finding that I'm having trouble with making the sprites rotate correctly. In a nutshell, I've got spritesheets for each of 5 directions (the other 3 come ...
7k views

### Rotate vector by matrix?

If I have a Vector, say (1,1), how can I rotate it around the origin (0,0)? I'm working in XNA if that helps.