xna

Why isn't my 3D collision detection working?

本秂侑毒 提交于 2019-12-23 05:38:05
问题 I have several objects in my world, there are three primary types. The first is self, which is the player, the player does not move, but they do rotate. The second are bullets which fly out away from the user in a straight line. And the third are targets, these just sit somewhere and wait to be hit. Here's the code I'm using to do collision detection and it isn't working: foreach (GameObject go in bullets) { float goRadius = go.Model.Meshes.Sum((x) => x.BoundingSphere.Radius) * go.Scale;

MessageBox & Dialogs on XNA (C#)

若如初见. 提交于 2019-12-23 04:57:26
问题 I'm having the following code as part of my XNA game: private void gameOver() { if (!m_IsGameOver) { string message = String.Format("GAME OVER!!!{0}Your score is: {1}", Environment.NewLine, GameScore); if (MessageBox.Show(message, "GameOver", MessageBoxButtons.OK) == DialogResult.OK) { this.Exit(); } m_IsGameOver = true; } } private void gameWon() { string message = String.Format("You Won!!!{0}Your score is: {1}", Environment.NewLine, GameScore); if (MessageBox.Show(message, "You Won!",

XNA Find nearest Vector from player

﹥>﹥吖頭↗ 提交于 2019-12-23 03:53:07
问题 I have a List of vectors and a PlayerVector I just want to know how I can find the nearest Vector to my PlayerVector in my List. Here are my variables: List<Vector2> Positions; Vector2 Player; The variables are already declared and all, I just need a simple code that will search for the nearest position to my player. Isn't there a simple way? 回答1: Create a int called distanceToPlayer, set it to 0. Create a int called nearestObject set it to 0. Loop through all the objects with a for loop. It

how to show lots of sprites from one texture and have them move at intervals XNA 4.0

五迷三道 提交于 2019-12-23 01:46:39
问题 Hi I'm new to xna and I'm trying to make a simple game where your a little ship that moves around and avoids asteroids that fall down from the top to the bottom. I've got the ship moving and one asteroid falling but I don't know how to get lots of asteroids falling from the same texture and how to get them falling at intervals. This is my asteroids class so far: namespace Asteroids { class Asteroids { Texture2D AsteroidTexture; Vector2 Position; Random random = new Random(); float

XNA Window Resize Invokes LoadContent

旧巷老猫 提交于 2019-12-22 18:33:04
问题 Anytime I resize my XNA Window to the smallest possible resolution (0 pixels high) the program starts invoking LoadContent again which causes my app to crash (since I only want it to load content once). What can I do, is there a way I can stop the user from resizing my window too much (such as setMinimumSize in Java). Or is there another solution? Thanks, 回答1: To stop the user resizing your window too much, set the MinimumSize property on the form associated with the game window. Add the

XNA Window Resize Invokes LoadContent

蹲街弑〆低调 提交于 2019-12-22 18:33:03
问题 Anytime I resize my XNA Window to the smallest possible resolution (0 pixels high) the program starts invoking LoadContent again which causes my app to crash (since I only want it to load content once). What can I do, is there a way I can stop the user from resizing my window too much (such as setMinimumSize in Java). Or is there another solution? Thanks, 回答1: To stop the user resizing your window too much, set the MinimumSize property on the form associated with the game window. Add the

Massive multiplayer in xna

Deadly 提交于 2019-12-22 18:25:05
问题 What do you think about xna and massive multiplayer? for example server and 100 clients? Is there any nice tutorial how to create client server application in xna? 回答1: There certainly are tutorials on how to do it. Personally I use Lidgren for my online prototype. I've only tested it with 4 people total and the server running on a low resource ubuntu vps, running on Mono, so I can't tell you how it will scale up but I'm sure others could. For quick reading check out the site, http://code

Poor performance on 360 and WP7

荒凉一梦 提交于 2019-12-22 18:16:57
问题 I've just got my 2D sprite game running on the 360 and WP7 and it's far slower on these than the Windows counterpart. The FPS is about a frame a second, but on windows its smooth. I'm using Farseer the latest version in this. Is there anything on these two platforms that could cause such a drastic slowdown? Thanks in advance. 回答1: Yes. There are DEFINITELY things on those two platforms that can cause significant slowdowns. The CLR on the 360 and WP7 have much slower garbage collectors than on

Getting Acces to Other Classes Variables

会有一股神秘感。 提交于 2019-12-22 13:52:54
问题 I'm working on a pong game, since i'm new at programming, i don't know how to get acess to another class variable. I have seperate classes, green and blue paddles, a ball, and game1.cs. I control the ball movement with bool movingUp, movingLeft; It bounces off the borders of the screen, but i don't know how to make it work with the paddles. Basically, how do i check the position of the paddle, and make so when the ball touches the paddle, it bounces off? I mean, how to detect the collision?

Infinite Scrolling Background in XNA

狂风中的少年 提交于 2019-12-22 13:05:08
问题 I'm drawing a ground texture in a sidescrolling platformer like this: spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, _camera.GetViewMatrix(Parallax)); foreach (Sprite sprite in Sprites) sprite.Draw(spriteBatch); spriteBatch.End(); In Sprite.Draw() public void Draw(SpriteBatch spriteBatch) { if (Texture != null) spriteBatch.Draw(Texture, Position, new Rectangle(0, 0, Texture.Width, Texture.Height), Color.White, Rotation, Origin, Scale, SpriteEffects.None, ZIndex); }