xna

What limitations does WPF have comparing to XNA?

南楼画角 提交于 2019-12-11 16:33:49
问题 I believe WPF is better for game in situations like creating buttons, textblock, label, progressbar... 回答1: WPF is a very different technological approach to graphics from XNA. First off, it's a retained mode API instead of an immediate mode API. This will give you less (almost no) control over how and when things are rendered when compared to XNA. It also potentially will have a higher cost in terms of performance and potentially lower responsiveness, at least with a lot of objects (when

How to get the number of Processors on Windows Phone

旧城冷巷雨未停 提交于 2019-12-11 15:41:15
问题 I'm wondering how to get the number of processors on Windows Phone... as documented in the MSDN the following statement always throws a MethodAccessException: Environment.ProcessorCount Any help would be appreciated. Thanks, j3d 回答1: According to this forum post, which links to the MSDN doc that you mentioned, you can't get the processor count programatically on Windows Phone. 回答2: As described in MSDN this Property has a SecurityCriticalAttribute that makes for internal only, you can't use

Rendering a line into a 1x1 RenderTarget2D does not change the target's pixel color

人盡茶涼 提交于 2019-12-11 14:58:53
问题 What I am trying to achieve is the following: my pass will return a huge array with several unique numbers repeating over and over, which I need to retrieve and process on CPU. I tried rendering into a 2000x1 texture and then sampled it on the CPU with RenderTarget2d.GetData<>() and a foreach loop. It was awfully slow :). So I sidestepped my problem, the idea now is to render to a 1x1 texture multiple times. Inbetween passes I will extend a parameter array in my shader to include the numbers

Generating terrain in C# using perlin noise

寵の児 提交于 2019-12-11 14:12:40
问题 I'm working on civilization game in C# and XNA. I use a two dimensional integer array, populated with a loop, to generate tiles, I've done a ton research and have been unable to find a way to generate earth like terrain. Can anyone explain how to do this or at least give me code that could do it, though I would prefer and explanation? Thank you. 回答1: I use an algorithm similar to this to make my terrain. Basicly it generates some random numbers and uses a sine wave to generate hills, when

Is there some standard functionality in XNA to efficiently implement a 2D Camera on a large world

谁都会走 提交于 2019-12-11 13:51:06
问题 I am making a 2d space game with many moving objects. I have already implemented a camera that can move around and draw the objects within the view. The problem now is that I have to check for every object wether it is within the rectangle of my view before I draw it (O( n ) operations where n is the number of objects in my world). I would like a more efficient way to acquire all the objects within the view so I only have to draw them. I know a bunch of data structures that can achieve a O

Screen size integers. C#

我的梦境 提交于 2019-12-11 13:19:35
问题 I make a class Resize.cs and that takes an image from the Images.cs class and finds the width and height of the image by creating a new integer for each the width and height. I also make a resize to change the size of the image to fit the screen. public static int resize = 1; public static int backgroundWidth = resize * Images.Background.Width; public static int backgroundHeight = resize * Images.Background.Height; Then I take the width and height and move it over to the Game1.cs (The main

Quaternions, rotate a model and align with a direction

一个人想着一个人 提交于 2019-12-11 13:02:33
问题 Suppose you have quaternion that describes the rotation of a 3D Model. What I want to do is, given an Object (with rotationQuaternion, side vector...), I want to align it to a target point. For a spaceship, I want the cockpit to point to a target. Here is some code I have ... It's not doing what I want and I don't know why... if (_target._ray.Position != _obj._ray.Position) { Vector3 vec = Vector3.Normalize(_target._ray.Position - _obj._ray.Position); float angle = (float)Math.Acos(Vector3

Rotating the whole level

限于喜欢 提交于 2019-12-11 12:54:04
问题 I have a XNA programm which draws a field (50x50) of a texture The code of the drawing looks like that: namespace Village { public class DrawLogic { internal static void DrawCreatures(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, Dictionary<string, Texture2D> creatureTextures, List<Creature> list, Coordinate current) { spriteBatch.Begin(); foreach (var item in list) { Vector2 origin = new Vector2(0, 0); if (item.Selected) { spriteBatch.Draw(creatureTextures[

Move sprite like in Pokémon

有些话、适合烂在心里 提交于 2019-12-11 12:08:45
问题 I have a game, where I want my characters to move in my field square by square, like in Pokémon. With the code I have, it is moving square by square just it skips on every key hit about 4-5 squares. And just jumps around. Can someone help me to get my code work in a similar manner like Pokémon? The code I have is as follows. public class Map { private Map() { Position = new Vector2(0, 0); } public string Data { get; set; } public string[][] MapData { get; set; } public ContentManager Content

How can I draw a sprite in it's own class?

*爱你&永不变心* 提交于 2019-12-11 11:54:36
问题 I'm trying to program a game with a friend, and I'm very confused as to how to draw sprites. I can draw code in my Game1 class, below. namespace SweetGeorgiaBrown { /// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework.Game { enum GameStates { TitleScreen, Overworld, Menu, Battle, GameOver }; GameStates gameState = GameStates.Battle; GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D dinoTex; Texture2D alienTex;