xna

Vector math, finding the angle

纵然是瞬间 提交于 2019-12-14 02:16:15
问题 I am trying to learn XNA by writing a small 2D game, it's a Top-Down perspective and Im trying to have double movement, moving along the axis using Left-Right and Up-Down keys, as well as looking right at the mouse cursor, so that the player can run and aim at the same time. I have one vector for the player position (m_PlayerPos), and one vector for the mouse position (m_MousePos), and im trying to get the correct angle towards the mouse position. Im using the formula method: public static

Game Jitters on xBox360

早过忘川 提交于 2019-12-14 02:12:14
问题 Ok i've got my game nearing completion, everything is working perfectly in it and it runs fairly well on my computer (running at around 99Mb RAM). But when i run it on my xBox, i tend to get occasional jitters of the main player character. I do have explosions and billboard effects inside my game however i'm doing all that rendering on the xBox GPU (that was originally causing the jitters when explosions occurred, but not anymore). The jitters are random as well, not when i'm spawning large

Rotating a vector

╄→尐↘猪︶ㄣ 提交于 2019-12-13 21:02:21
问题 I want to do a simple vector rotation. The goal is to head my first-person camera which is currently pointing to to target t with direction d to a new target t1 with a new direction d1. The transition between d and d1 should be a smooth movement. With public void FlyLookTo(Vector3 target) { _flyTargetDirection = target - _cameraPosition; _flyTargetDirection.Normalize(); _rotation = new Matrix(); _rotationAxis = Vector3.Cross(Direction, _flyTargetDirection); // This bool tells the Update()

Strange in ShakeGesture Library on Windows Phone Application

ぐ巨炮叔叔 提交于 2019-12-13 20:36:22
问题 i've a problem with windows phone shakegesture library. I build an application which its shaking the sound will go out and its work nicely but strange bug make me confused. I've two page of it. This is my seperated code : void Instance_ShakeGesture1(object sender, ShakeGestureEventArgs e) { Stream stream = TitleContainer.OpenStream("Sounds/C.wav"); effect = SoundEffect.FromStream(stream); effectInstance = effect.CreateInstance(); if (effectInstance.State != SoundState.Playing ||

What's wrong with my XNA cube?

风格不统一 提交于 2019-12-13 20:16:01
问题 I'm following this sample trying to build on it. I incorporated the code into my solution, which is a windows form app (a little tricky w/ XNA). When I finally got a cube to draw it ended up inside out... or outside in... or? See for yourself. The app is now several thousand lines so I can't paste it here. I'll need to know where to start looking. Any idea what's wrong here? It looks like the sides are getting drawn out of order... but that shouldn't matter. The graphics engine should

how to move 3d object in XNA?

夙愿已清 提交于 2019-12-13 19:11:05
问题 I want to move a 3d car model, when I press the left or right arrow key I change the angle, when I press the up arrow the car drives. This is the code in the update method: float dirX = (float)Math.Sin(angle); float dirY = (float)Math.Cos(angle); if (Keyboard.GetState().IsKeyDown(Keys.Up)) { position += new Vector3(-dirX, dirY, 0); if (Keyboard.GetState().IsKeyDown(Keys.Left)) { angle += 0.015f; } if (Keyboard.GetState().IsKeyDown(Keys.Right)) { angle -= 0.015f; } } This is the calculating

C#: Cannot assign to foreach iteration variable

坚强是说给别人听的谎言 提交于 2019-12-13 17:24:09
问题 I'm trying to condense this by wrapping it in a loop: if (pos.X + pixelRadius < 0) { pos.X = bounds.Width - pixelRadius; } else if (pos.X + pixelRadius > bounds.Width) { pos.X = pixelRadius; } if (pos.Y + pixelRadius < 0) { pos.Y = bounds.Heigh - pixelRadius; } else if (pos.Y + pixelRadius > bounds.Height) { pos.Y = pixelRadius; } My first instinct was to do something like this: foreach (float coord in new float[] { pos.X, pos.Y }) { float upperBound = (coord == pos.X ? bounds.Width : bounds

Device / Emulator option missing in XNA on Visual Studio 2013

喜夏-厌秋 提交于 2019-12-13 16:29:06
问题 Note: I have reviewed all the XNA / VS 2013 related posts on stackoverflow and didn’t find this issue mentioned once. I have followed various guides and installed XNA Game Studio 4.0 under Visual Studio 2013. All works well, I can open my existing projects and even create new projects. There’s just one little problem: I’m missing the option to RUN / DEBUG the project to Device / Emulator. Instead, I only have default “Start” option available after using which I get an error message saying I

XNA Number lock affects input

时间秒杀一切 提交于 2019-12-13 16:25:49
问题 I have an interrupt that on keyboard keypress gives me the coordinating key. When the number lock is ON, the keys come up as Numpad1, Numpad2, etc. When the number lock is OFF, the numpad keys turn into End, Left, Right, Up, PageLock... I cant have this happening because I need to keep those keys (Left, Right..) as the actual arrow keys. Id rather have the input not be affected by the number lock at all. However, I can't seem to mitigate this as I am getting the input from XNA directly. Can

Preventing execution pause when dragging game window

浪子不回头ぞ 提交于 2019-12-13 14:26:24
问题 I have a server and a client. But when ever I start moving the game window, it stops executing code until the window stops moving,causing a connection timed out because the server or client stopped responding for a while. What do I need to do in order to make the game always run code, even when the game window is being moved? 回答1: This is a known issue with XNA games, and there are several ways around it. One way is to move a fake window frame, which isn't the game window really. Game window