Map editor undo function Not actually setting values to tiles I'm currently attempting to implement an undo redo function for my map editor for a tile based 2D platformer game made with XNA. I've found a lot of resources online about this and decided to try to write my own code for it to gain a better understanding of how it works. My issue is when I pass the my tile's information into a stored "Action" and change the data within the newly created Action, it does not actually change the data in my tiles. Below is the Action struct and the UndoBuffer class where I modify the tile's data based on the stored actions that I created elsewhere public struct Action public object StoredItem get set public object ModifiedItem get set public class UndoBuffer private readonly List lt Action gt undoBuffer private readonly List lt Action gt redoBuffer public UndoBuffer() undoBuffer new List lt Action gt () redoBuffer new List lt Action gt () public void StoreAction(object storedItem, object modifiedItem) var action new Action StoredItem storedItem, ModifiedItem modifiedItem undoBuffer.Insert(0, action) public void Undo() if ( undoBuffer.Count 0) return redoBuffer.Insert(0, new Action ModifiedItem undoBuffer 0 .ModifiedItem, StoredItem undoBuffer 0 .StoredItem ) for (int i 0 i lt undoBuffer 0 .StoredItem.Count() i ) Action tempAction undoBuffer 0 tempAction.ModifiedItem i tempAction.StoredItem i undoBuffer 0 tempAction undoBuffer.RemoveAt(0) Here's how I'm passing the data in to the class above private void ReplaceTile(Tile oldTile, TileInfo tileInfo, bool storeAction true) int tileX (int)oldTile.Position.X Tile.Width, tileY (int)oldTile.Position.Y Tile.Height if (tileX lt 0 tileY lt 0 tileY gt tileData.Tiles.Count tileX gt tileData.Tiles tileY .Count) return var storedTiles new ArrayList() var modifiedTiles new ArrayList() if (storeAction) storedTiles.Add( tileData.Tiles tileY tileX .TileInfo) tileData.Tiles tileY tileX .TileInfo tileInfo if (storeAction) modifiedTiles.Add( tileData.Tiles tileY tileX .TileInfo) undoBuffer.StoreAction(storedTiles.ToArray(), modifiedTiles.ToArray()) saved false And here is the actual Tile class and its TileInfo struct public struct TileInfo public string ViewName public int Frame public TileCollision Collision public CollisionType CollisionType public TileProperty TileProperty public SpriteEffects Effects public Color TileColor public float Rotation public float Layer Serializable public class Tile public TileInfo TileInfo public Vector2 Position public const int Width 8 public const int Height 8 public static readonly Vector2 Size new Vector2(Width, Height) public Tile CreateTile(TileInfo tileInfo, Vector2 position) var tile new Tile TileInfo tileInfo, Position position return tile So essentially, I just need the UndoBuffer class to actually change the data within the TileInfo structs that are passed into it, and not change a boxed copy of them.


Save game state information I'm working on my first game, and are looking into the option to save a number of game state settings. One of the things I want to save is the high scores, this will contain a list of the 10 players that scored the highest. I have been looking into this for a while, and was wondering what the best way for this is. While being ingame I will have a list of high scores comprised of Player, Score, Level. This of course needs to be updated each time the score has been beaten, but it also needs to be saved somewhere where it won't be reset the whole time. I would think this kind of information should be saved into a file (either xml or comma separated values). The problem I'm facing is what to do on the initial set up (I would like to have some fake values in the high scores table), however if I add that to the file how do I know that the scores in there are the initial set up ones, or the real ones? Once the player has a endgame for the first time, these fake scores should not being shown anymore. However the player can also reset the scores, and at that point I would like to have the fake scores shown again. So my question is what is the best way of setting this up? Do I keep 2 files, one with the real scores, other with fake ones? or do I keep the fake ones in a list inside the game and when the file with high scores can't be found I use that list?


Equivalent to Draw() method in Unity project? I have been using xna monogame before this. So I read tutorials about unity, made some classes, loaded some sprites, everything "seems" to be going good, but I can't figure out how to add things into the environment, could anyone tell me or guide me to what's the equivalent of Monogame's Draw() method in Unity? Thank you.


At this point in time, avoid XNA? XNA seemed like a valid option a few years ago, but XNA was never a real success, and now it seems like a footnote, even Microsoft seems to treat it that way. Should I just go the DirectX route instead? Ideally, eventually, I'd like my games to be playable on all major platforms (Windows, Linux, Mac all consoles), but my primary focus is getting the games out the door on Windows XP, 7 and 8. EDIT This question and releated might already be answered here What is the future of XNA in Windows 8 or how will managed games be developed in Windows 8?


Grid Based 2D Lighting Problems I am aware this question has been asked before, but unfortunately I am new to the language, so the complicated explanations I've found do not help me in the least. I need a lighting engine for my game, and I've tried some procedural lighting systems. This method works the best if (light xx 1, yy gt light xx, yy ) light xx, yy light xx 1, yy lightPass if (light xx, yy 1 gt light xx, yy ) light xx, yy light xx, yy 1 lightPass if (light xx 1, yy gt light xx, yy ) light xx, yy light xx 1, yy lightPass if (light xx, yy 1 gt light xx, yy ) light xx, yy light xx, yy 1 lightPass (Subtracts adjacent values by 'lightPass' variable if they are more bright) (It's in a for() loop) This is all fine and dandy except for The system favors whatever comes first in the for() loop This is what the above code looks like applied to my game On the left side you can see some weirdness going on The loop goes top to down then to the right column This is how the for() loop goes Light provided from my mouse, should be a full light, but is only half If I could get some help on creating a new procedural or otherwise lighting system I would really appreciate it!


drawing meshes so that they respect the position in space (doesn't draw on top of another mesh if behind it) How can i make my meshes be drawn taking in account which one is in from of another? i.e. if i have a mesh that is farder than another it should be drawn behind the second. Is there a way to do this in xna that is more standardized or do i have to calculate for each mesh myself? If i have to calculate for each mesh by myself, from which point do i calculate the distance to the mesh? the camera position? Here is how i draw them Matrix transforms new Matrix gameobject.model.Bones.Count gameobject.model.CopyAbsoluteBoneTransformsTo(transforms) foreach (ModelMesh mesh in gameobject.model.Meshes) foreach (BasicEffect effect in mesh.Effects) effect.Projection camera.projectionMatrix effect.View camera.viewMatrix effect.World transforms mesh.ParentBone.Index gameobject.orientation mesh.Draw()


Drawing on an image before drawing on screen in XNA using VB.NET I'm programming a game in XNA, using VB.NET. I want to create an intro to the game that zooms in out the whole screen and scaling each image to accomplish this is cumbersome at best. I like to be able to draw a lot of .PNG's (or parts of them) onto a whole image, to then be able to manipulate (scale, turn etc) that whole image, before drawing it with the spriteBatch. The examples I can find use something like dim bitmap as New Bitmap or dim image as New Image but these codes highlights the "Bitmap" or "Image" as red, and I cannot use them. I'd be thankful for any help on this issue! please note I'm new to this, and self taught, so I prefer concrete examples if possible.


How should I draw the GUI if I use a 2D camera? I have a camera in my 2D side scrolling game and I want to implement the GUI. How can I do that? For the moment, I draw everything like this spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.None, RasterizerState.CullNone, null, scaleMatrix camera.GetMatrix()) player.Render(spriteBatch) GUI.Render(spriteBatch) ... spriteBatch.End() Should I separate the GUI drawing code from the camera's transformation matrix? How can I do that? What is the best way to implement the GUI in a Windows Phone 8 project?


How do I clear a specific render target when more than one are set? Or how do I keep the depth but clear the color? Let's say I set two render targets GraphicsDevice.SetRenderTargets(rt0, rt1) If I call GraphicsDevice.Clear(Color.Transparent) both render targets will be cleared. Therefore, how can I clear a render target at a specific index? For example just 'rt1' and not 'rt0'. I would like to avoid texture baking the contents of 'rt0' to another render target and copying them back to 'rt0'. This is because PreserveContents on the XBOX 360 can only hold one render target in memory. EDIT Is there any way just clear the color for a render target? I would like to keep the depth for depth reading.


Exporting XNA class library as a DLL file I have downloaded an open source project that I intend to use with my current game. The download came with all the class files from the original project as well as a pre compiled DLL file representing the project. I was able to easily link this DLL with my current project and get it working just fine, no problems there. The problem I now have is that I want to make a couple of changes to the original libraries (extend its functionality a bit to better suit my needs) and re export the class library as a DLL again, but I have no clue how to do this. Is there some simple way in VS where I can just take the class library and export compile it as a DLL file again or is there more to it than that? This seems like something that should be pretty simple but my efforts to find an answer have so far come up with nothing. Thanks in advance.


XNA Multiple Key Input I'm using the KeyboardState state way (if there are any others) of handling key presses for a PC game. It has been working fine for single key presses but now I am trying to handle multiple key presses at once. I have it grab the newState at the top and then save it to the oldState at the bottom. I've tried it this way if (newState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D2) amp amp newState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt)) if (equipment accessory2 ! null) UseItem(equipment accessory2, "Accessory 2") And I've also tried Microsoft.Xna.Framework.Input.Keys currentPressedKeys newState.GetPressedKeys() bool altPressed false, twoPressed false for (int i 0 i lt currentPressedKeys.Length i ) if (currentPressedKeys i Microsoft.Xna.Framework.Input.Keys.LeftAlt) altPressed true else if (currentPressedKeys i Microsoft.Xna.Framework.Input.Keys.D2) twoPressed true ... if (altPressed) if (equipment accessory2 ! null amp amp twoPressed) UseItem(equipment accessory2, "Accessory 2") Both ways work to a certain degree. The end result is that you're able to press alt and then a key between 1 and 5 to quick use a consumable. Normally you have skills in those slots so holding down alt makes the skills you have bound disappear and instead shows your quick use items. The problem I'm having is that no matter what I have tried, the only way it works is that you have to hold 2 then hold alt. If you hold alt first and press hold 2 it does nothing and doesn't work. I have spent 4 or 5 hours trying to figure out why it only works when you hold down 2 and then press alt. The problem with having it only work this way is if they have a skill bound to 2 then they're going to use the skill so the system is supposed to be to hold down left alt to swap the skill bar to the quick use bar. I can't figure out why both ways I've tried doing multi key input aren't working when I press alt first. EDIT ok it must be something with my keyboard because alt 1 works but 2, 3, 4, and 5 don't work. EDIT2 restarted and 2 5 work now too, was something with my keyboard apparently.


(XNA) Stretching Images (Sprites) without Blur (Rasterizing?) thanks for clicking on this question although it has likely one of the most un specific and confusing titles on this site. I am somewhat new to XNA and I have only posted 1 question on this site before which I didn't understand the answer to fully, but I'll give it another go. I am looking to create a game which allows the user to either go full screen or re size the window to a few preset values, like many mainstream games nowadays allow you to do. I believe I know how to do this in XNA, the problem is, when I toggle full screen, and it stretches the sprites, they appear blurry. I know this is a very obvious problem, as stretching blur (logically). The thing is, I was wondering if there was a way to make it so regardless of the zoom, your sprites look crisp and not blurry? I asked a friend of mine in real life and he said something about rasterizing (which i don't know anything about). The only other thing I can think of I've seen this done a few times in Flash. For examples of what I mean the only game I can think of is Super Smash Flash 2. It seems regardless of the screen size, most of the sprites and images appear crisp, even on the largest of screens. If anybody knows anything about this, please share! Thanks.


XNA 4.0 HLSL strange depth map I want to draw my pre rendered depth map to the scene. I get my depth value in the following way basically (Pixel Shader) Depth is stored as distance from camera far plane distance, 1 d for more precision output.Depth float4(1 (input.Depth.x input.Depth.y),0,0,1) where (Vertex Shader) output.Position mul(input.Position, worldViewProjection) output.Depth.xy output.Position.zw (input output of Vertex Shader) and store it in a RenderTarget2D depthTarg new RenderTarget2D(GraphicsDevice, viewWidth, viewHeight, false, SurfaceFormat.Single, DepthFormat.Depth24, samples, RenderTargetUsage.DiscardContents) But somehow, when I draw that (Single), I get this result (displaying rgb) channel r (all black) channel g channel b channel a Why is there data in every color channel althrough i only defined a value on the red parameter (and 1 on a, but you can somehow see the outlines of the model, so it cant be all 1) And surprisingly, the b channel looks almost like what I am looking for, but has strange lines in it which stay at the same distance to the camera if I move it.


Deserialize inherited classes into the same list in XNA I am writing a Gui for a game (for what else ...). Therefor I wrote a class GuiElement which has some serializeable fields. From this class I deflect a Class "Button" which has one serializeable field more. Furthermore, I have a Class GuiWindow, which is as well deflected from "GuiElement". An Object of this Class has a Field "HandledElements" of the type "List". To know the layout of the Menues, I use XML Files, which look like that (for example) lt ?xml version "1.0" encoding "utf 8" ? gt lt XnaContent xmlns Generic "System.Collections.Generic" gt lt Asset Type "System.Collections.Generic.List GUI.GuiWindow " gt lt Item gt lt Position gt 0 0 lt Position gt lt AlternativeImagePath gt lt AlternativeImagePath gt lt IsActive gt true lt IsActive gt lt Name gt MainMenu lt Name gt lt HandledElements gt lt Item gt lt Position gt 100 100 lt Position gt lt AlternativeImagePath gt lt AlternativeImagePath gt lt IsActive gt true lt IsActive gt lt Name gt Optionen lt Name gt lt Caption gt Optionen lt Caption gt lt Item gt lt HandledElements gt lt Item gt lt Item gt lt Position gt 0 0 lt Position gt lt AlternativeImagePath gt lt AlternativeImagePath gt lt IsActive gt false lt IsActive gt lt Name gt Options lt Name gt lt HandledElements gt lt HandledElements gt lt Item gt lt Asset gt lt XnaContent gt As you can see, the first window has in its "HandledElements" List an Item with the Field . This is a field which only a Button has. The Problem is now I can't deserialize this XML file, because GuiElement does not have this Field, it only has the few fields above. I thought it would know automatically which Class to use,but it doesn't. Do I really have to give my windows a list for each child class of GuiElement? Or can I do another workaround?


How to implement in game purchase? I am currently developing an indie game using XNA C . I would like to give players the opportunity to try a free (but somewhat limited) demo version of the game. Nevertheless, the player should be able to purchase the full version of the game from within the demo version (after short download) immediately unlocking the full version. The tricky part is that I would like to permanently remember this purchase as I would like to give players how purchased the game the opportunity to download additional content etc. for free later. Nevertheless, the user should be able to switch computers or reinstall the game without loosing that "purchased" flag. One (maybe) possible way would be to give each user a serial number that can be checked once at gamestart. Is there a library etc. to support this or is there maybe another best practice for these kinds of things. I guess the well known payment processors as BMC Micro and Fastspring do not support this, do they. PS I would like to keep the game DRM free.


How to smoothly track and draw player movement? I am currently using C XNA Framework to simply connect some development concepts that I've learned used over the past few months. Right now I have a Web Service that keeps track of connected clients and their 2D positions. I have a very small map that uses triangles to represent clients and their positions. What I am seeing is my client updates very smooth (because I update my own position locally before sending it off to the web service), however, other triangles come in and appear choppy. I use a web service that is called approximately every 20ms (and responds pretty quickly might I add). However, I know that XNA framework calls its update draw methods approximately 60 times per second correct? Given this, there is ALWAYS going to be the appearance of choppiness. Is there some strategy or pattern to handling this? I thought about implementing a method on the client side that basically says, give me start position and end position and I'll transition the triangle between the two points smoothly. But this may not be the right answer. What are folks thoughts? I am using a NetTcpBinding from WCF (Duplex). Is this technology simply too slow? Is the right strategy simply to let the Service always tell me where the other clients are and the client simply draws them there? Or does the client compute other information and make assumptions etc? Thanks for any information on this topic!


Best way to do large XNA animations? What's the best way to have large animations in XNA 4.0? I have created a spritesheet with the sprite being 250x400 (more of an image than a sprite but hey ho) and there are approximately 45 frames in the animation. This causes problems for XNA as it says that the maximum filesize for Reach is 2048. I'd rather not change to hidef as I heard that means that your game is less compatible with some computers and systems so does anyone have any idea what the best thing I could do is? The only thing I could come up with is to have a list of textures to flick through but that's not ideal.


Generate and then rasterize vector shape in Monogame XNA I apologize if this is too broad, but I can't seem to find information on this anywhere (perhaps I am searching for the wrong thing?) Anyways, I'm making a simple game where the player visits different, small, circular planets. I've successfully made a simple circle texture directly with a for loop, but I've run into a few problems How can I easily add variation to the landscape (e.g. Perlin noise) How can I detect where the surface of the planet is? How can I easily add objects to the surface of the planet? I realized that all 3 of these problems could most likely be solved if the planet was generated with a vector polygon. Noise could be easily applied, and the normal of each edge could help with surface detection object placement. However, I could barely find any info on the subject. Let me be clear I don't want to directly render a vector shape I want to invisibly create a semi random polygon, and then create a filled in texture based on that convex shape. Is there any easy way to do this? Is there a better way to execute this idea in general?


How do I apply pixel shader to specific sprite in XNA 4.0 in a spritesort FrontToBack? I have a set of sprite drawn in FrontToBack sortmode. In XNA 4.0, the effect must be as an input argument of Begin() function of SpriteBatch. However, If I reinvoke the function, then the sprite sorting is lost. Therefore, I have to find a way to implement the pixel shader within the Begin() and End() for specific texture drawn. I tried to use effect.CurrentTechnique.Passes 0 .Apply(), but no pixel was shaded when I invoke this. On the other hand, if I put effect as an argument, then all of the sprites would be effected. Therefore, is there any convenient way to approach this? By the way, what I am trying to do is to provide an overlay on an isometric tile using some kind of masking. Therefore, I want to draw such masking and programmatically change it to optional color. Something like this (from final fantasy tactics) I am not sure if pixel shader is the right way to approach it, but then I have to tackle the fact that I want to be able to specify optional color dynamically. Other than that, I really want it to animate, which I might approach this by creating several grayscale animated masking and saturate it using pixel shader.


How would I go about implementing a globe like "ballish" map? I am new to 3D development and I have this idea of having the game world like our globe is a ball. So, there would be no corners in the map and the game is top down RTS game. I would like the camera to go on and on and never stop even though you are moving the camera to the same direction all the time. I am not sure if this is even possible, but I would really like to build a globe like map without borders. Can this be done, and how exactly? I am using XNA, C , and DirectX. Any tutorials or links or help is greatly appreciated!


At this point in time, avoid XNA? XNA seemed like a valid option a few years ago, but XNA was never a real success, and now it seems like a footnote, even Microsoft seems to treat it that way. Should I just go the DirectX route instead? Ideally, eventually, I'd like my games to be playable on all major platforms (Windows, Linux, Mac all consoles), but my primary focus is getting the games out the door on Windows XP, 7 and 8. EDIT This question and releated might already be answered here What is the future of XNA in Windows 8 or how will managed games be developed in Windows 8?


Accept keyboard input when game is not in focus? I want to be able to control the game via keyboard while the game does not have focus... How can I do this in XNA? EDIT I bought a tablet. I want to write a separate app to overly the screen with controls that will send keyboard input to the game. Although, it's not sending the input DIRECT to the game, it's using the method discussed in this SO question https stackoverflow.com questions 6446085 emulate held down key on keyboard To my understanding, my test app is working the way it should be but the game is not responding to this input. I originally thought that Keyboard.GetState() would get the state regardless that the game is not in focus, but that doesn't appear to be the case.


Where can I publish my Windows Indie game? I've just finished an XNA game for the Windows Phone 7 and XBLIG. At the moment, the game is a 'lite' version, so is free, but the next version will have a small price tag. I also did a Windows version. Where's the best place to publish it?


Is it better to track rotation with a vector or a float? In XNA, you can see that to draw a rotated sprite with SpriteBatch, you'll need a float describing the angle in radians. I'm used to making games in OpenGL. I just want a rapid prototyping environment in XNA, but I'm a little lost. It's my preference to always use Vectors to store my rotation, to do vector math, et cetera. So my question is in XNA, is better to keep a vector for your rotations, and each frame transform to a float angle, or just keep the float angle itself? If I prefer the vector, what would be my drawbacks compared to just using a float?


How to do smooth sprite movement on WP7 XNA What's the correct technique for getting smooth sprite translations with XNA? I've been developing the WP7 version of an app for a startup, so when we heard Angry Birds got ported today we wanted to check it out and compare. Angry Birds on WP7 had the sub pixel blur problem with the bird sprites, whereas iPhone, Android, and Chrome all had smooth movement.


Should I be using Reach or HiDef profile if I have large spritesheets? I'm working on a platformer in monogame, that I want to use a large number of sprites for making up items and objects in the background. The main spritesheet I've created is 4095x3734, when I tried to convert it into xmb using XNA Content Compiler, I received an error that Reach Profile only supports 2048x2048. I've read that I can use HiDef which will support 4096x4096, which will be sufficient for my requirements, but I am a bit concerned about what the potential pitfalls will be will less graphics cards support the game? What about Mac Linux? Does monogame fully support HiDef? In short, I would like to know if there are any cons of using HiDef and if using multiple 2048x2048 spritesheets would perhaps be better and how much of a performance hit it would be.


Voxel engine vertexes how to add more and more different textures during game runtime and change some of the blocks' faces? It's difficult to ask this, but I'll try. The thing is I asked before somethings about creating ramps and blocks with vertexes. I'm using C XNA. Explanation now I got a chunk that has blocks wherever I want, that automatically change "stairs" into ramps. And I love it and I thank all the people that helped me out! But I don't know how to texture it appropriately. I could add a Texture Atlas and set the coordinates of each texture (I found the example at a project called "TechCraft Engine"), but I'd like to create separate PNG files for each texture, 'cause I'll use transparency later and I'd like that textures can be loaded during game runtime. I'm newbie in programming, but I'm searching for solutions. All that I got for now is that I have a custom effect (FX file) created that changes colors for each time of the day. But it only has a slot for one texture file loaded. And I still can't implement it because of that. I can't add more texture samplers to the effect 'cause it can't be done at game runtime (or can it?) I'm using the VertexBuffers and IndexBuffers, with TriangleList primitive. For now, I can only draw with colors, without textures. Later in my game I would like that custom textures could be added and placed on some of the block's faces. A example for this can be found in The Sims 3. There you can add textures to the game and paint the walls and objects with it. It's something like that I'd like to create, but with a loader while playing. My question is should I create a VertexBuffer and a IndexBuffer for each texture and separate the vertexes with each texture between them, creating a List of VertexBuffer and IndexBuffer for placing each?... Then I could draw all the vertexes of one texture at a time, change the effect's texture parameter with a different one (call the pass technique again), and set the graphics device again with the next VertexBuffer and IndexBuffer of the list, for drawing it with the TriangleList primitive. I'd repeat it for each texture loaded. Does it work or is there any other way to do it? Should I forget about runtime loading for now, for finding a easier solution? I'm pretty messed with this, do you have any suggestions? Any information will help. Thank you!


Word in different color in middle of string XNA Is it possible to use different font colors for the same string, for example, when buying a weapon in CoD AW Exo Zombies How do I do this? Thanks.


XNA clip plane effect makes models black When using this effect file float4x4 World float4x4 View float4x4 Projection float4 ClipPlane0 void vs(inout float4 position POSITION0, out float4 clipDistances TEXCOORD0) clipDistances.x dot(position, ClipPlane0) clipDistances.y 0 clipDistances.z 0 clipDistances.w 0 position mul(mul(mul(position, World), View), Projection) float4 ps(float4 clipDistances TEXCOORD0) COLOR0 clip(clipDistances) return float4(0, 0, 0, 0) technique pass VertexShader compile vs 2 0 vs() PixelShader compile ps 2 0 ps() all models using this are rendered black. Is it possible to render them correctly?


Is C necessary to learn if I ever want to get a job in the game industry? Is C necessary to learn if I ever want to get a job in the game industry? I am extremely familiar with C and have a basic mastery of making 2D games in XNA 4.0. Right now I am only 13 years old and love making games, and hope to someday get a game programming job. I have heard a lot of people say that C is the 'industry standard' and that it will hurt your career not knowing it. I am also trying to target more platforms than just windows and i am aware of Monogame but for some reason i am having lots of trouble with the visual studio templates, and i find many bugs with monogame. Since i technically can't get a job yet, and probably couldnt get a programming job until i am like 22 or something (unless im self employed). And in that 9 year time span the game industry will most likely change a lot. So here is some questions Will not learning C hurt my chances at getting a programming job? By the time i can get a job will C still be the 'industry standard' programming language If i am an indie developer does it really matter whether i learn C or not, and stick with what i know? Should i even start learning it now seeing as i have many years before i can even get a job? I am also having a worry that even though i am familiar with object oriented programming, i may spend lots of time on C , and get very frustated and confused then just quit learning it, and by this time i've forgotten lots of XNA and i have to learn everything all over. So in short Should i learn C if i ever want a programming job? UPDATE Thank You All For Your Answers And Suggestions. Recently I Picked Up SFML and C and it is going pretty good. I am getting the hang of C , and starting to open my eyes to not worrying about learning new things because i was able to transfer all my C knowledge into making C easier to learn. Thank You All Once Again.


XNA Games running on Windows 8 Will Games developed on XNA work under a Windows 8 environment? I know the XNA project was killed off, and you can't develop it on Windows 8 (apparently), but will they still work under windows 8? I don't care about metro integration or whatever, even if they run in desktop mode that's fine. I've been looking around and finding a bunch of contradictory answers so maybe I can get a clear one from here.


Draw a never ending line in XNA I am drawing a line in XNA which I want to never end. I also have a tool that moves forward in X direction and a camera which is centered at this tool. However, when I reach the end of the viewport the lines are not drawn anymore. Here are some pictures to illustrate my problem At the start the line goes across the whole screen, but as my tool moves forward, we reach the end of the line. Here are the method which draws the lines private void DrawEvenlySpacedSprites (Texture2D texture, Vector2 point1, Vector2 point2, float increment) var distance Vector2.Distance (point1, point2) the distance between two points var iterations (int)(distance increment) how many sprites with be drawn var normalizedIncrement 1.0f iterations the Lerp method needs values between 0.0 and 1.0 var amount 0.0f if (iterations 0) iterations 1 for (int i 0 i lt iterations i ) var drawPoint Vector2.Lerp (point1, point2, amount) spriteBatch.Draw (texture, drawPoint, Color.White) amount normalizedIncrement Here are the draw method in Game. The dots are my lines protected override void Draw (GameTime gameTime) graphics.GraphicsDevice.Clear(Color.Black) nyVector nextVector (gammelVector) GraphicsDevice.SetRenderTarget (renderTarget) spriteBatch.Begin () DrawEvenlySpacedSprites (dot, gammelVector, nyVector, 0.9F) spriteBatch.End () GraphicsDevice.SetRenderTarget (null) spriteBatch.Begin (SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.transform) spriteBatch.Draw (renderTarget, new Vector2 (), Color.White) spriteBatch.Draw (tool, new Vector2(toolPos.X (tool.Width 2), toolPos.Y (tool.Height 2)), Color.White) spriteBatch.End () gammelVector new Vector2 (nyVector.X, nyVector.Y) base.Draw (gameTime) Here's the next vector method, It just finds me a new point where the line should be drawn with a new X coordinate between 100 and 200 pixels and a random Y coordinate between the old vector Y coordinate and the height of the viewport Vector2 nextVector (Vector2 vector) return new Vector2 (vector.X r.Next(100, 200), r.Next ((int)(vector.Y 100), viewport.Height)) Can anyone point me in the right direction here? I'm guessing it has to do with the viewport.width, but I'm not quite sure how to solve it. Thank you for reading!


Problem disposing content from a screen's content manager I have a problem with my game. I am using multiple classes for different screens, for exemple Main Menu is one screen, When playing is another, and so on... I decided to use multiple ContentManagers, different content for each screen, so the game won't consume very much RAM, and to load the screen's content when the user will navigate on that screen, and unload dispose the content when user navigates away. I have created different content managers for each screen that I had to, but for exemple if I navigate from main menu, to the playing screen, then back to the main menu (when the content from playing screen gets disposed), and then back to the playing screen, I get this error An exception of type 'System.ObjectDisposedException' occurred in MonoGame.Framework.DLL but was not handled in user code Additional information Cannot access a disposed object. I googled this problem, and the only answer that I found was not to dispose the Content Manager, but each texture on that screen. Is this the only way that I can handle this? To dispose each texture from the screen, when user navigates away? Thanks.


How long will it take to jump from point A to point B? I need to know how long it takes to jump from one point to another. Because if the jump time takes for example 2.0f(float jumptime 2.0f), a jump animation is played during a time interval of exactly 2.0f. The difficult thing is, I need to know the jump time before the jump was executed. Is it possible to calculate that right before the jump is executed or is it impossible to calculate that? I use the following formula to let an object(ball) jump from one platform to another platform impulse Vector2(distance.x time mass gravity.x 2 time mass, distance.y time mass gravity.y 2 time mass) Description of the jump Update My calculations float gravity 3, timetopeak, timetoground, totaljumptime, waytothetop, waytotheground timetopeak jumpForce.Y gravity waytothetop (float)(0 timetopeak 0.5 gravity timetopeak timetopeak) waytotheground Ball.Position.Y waytothetop (PlatformB.Position.Y PlatformBHeight 2.0f BallHeight 2.0f) timetoground (float)(Math.Sqrt(2 waytotheground gravity)) totaljumptime timetopeak timetoground Ball.ApplyLinearImpulse(ref jumpForce) I divide the totaljumptime because the animation has 5 frames. BallAnimation new Animation(totaljumptime 5, 32, 32, Animation.Sequences.forwards, 0, 5, false, true) Are my calculations correct? Because the totaljumptime is very small and my animation runs much too fast.


how to move the camera behind a model with the same angle? in XNA I'm having difficulty moving my camera behind an object in a 3D world. I'd like to have two view modes for fps (first person). external view behind the character (third person). I've searched the net for examples but they don't work in my project. Here is my code used to change the view when F2 is pressed Camera double X1 this.camera.PositionX double X2 this.player.Position.X double Z1 this.camera.PositionZ double Z2 this.player.Position.Z Verify that the user must not let the press F2 if (!this.camera.IsF2TurnedInBoucle) If the view mode is the second person if (this.camera.ViewCamera type CameraSimples.ChangeView.SecondPerson) this.camera.ViewCamera type CameraSimples.ChangeView.firstPerson Calcul position ?? Here my problem double direction Math.Atan2(X2 X1, Z2 Z1) 180.0 3.14159265 Calcul angle ?? Here my problem this.camera.position .. this.camera.rotation .. this.camera.MouseRadian LeftrightRot (float)direction IF mode view is first person else ....


How to implement input texture limited alphablending of 2 textures with HLSL? I try to implement a HLSL shader the does the normal Alphablend with premultiplied colors (just as XNA4 does) but depending on some existing colors. One can think of adding a glow to a 2D terrain where the glow should only be applied to the not fully transparent parts of the terrain. My current code is sampler TextureSampler1 register(s1) Addition (Terrain only particles) sampler TextureSampler2 register(s2) Existing (Terrain) float4 main(float4 color COLOR0, float2 texCoord TEXCOORD0) COLOR0 Look up color from partly transparent existing texture (premultipied colors) float4 existing tex2D(TextureSampler2, texCoord) For transparent pixels gt Color stays the same if ((existing.r existing.g existing.b existing.a) 0) return existing Look up color from partly transparent addition texture (e.g. glow) (using premultipied colors) that should be added to existing color float4 addition tex2D(TextureSampler1, texCoord) Rescale light that is added by existing alpha addition.rgb existing.a Use this color to blend existing.rgb (1 addition.a) addition.rgb return existing However, there still seems to be a problem with the alpha channel. Any ideas?


Rotating a sprite around its center I also use Farseer Physics and Artemis ECS. Here is RenderingSystem Process method public override void Process(Entity entity, TransformComponent transformComponent, RenderingComponent renderingComponent) Vector2 dimension transformComponent.Dimension camera.ScalingFactor Vector2 rotationOrigin new Vector2(dimension.X,dimension.Y) 2 Vector2 renderingPosition new Vector2(1, 1) transformComponent.RenderingPosition camera.ScalingFactor camera.BitmapPosition Rectangle rectangle new Rectangle((int)(renderingPosition.X), (int)(renderingPosition.Y), (int)dimension.X, (int)dimension.Y) spriteBatch.Draw(renderingComponent.Texture, rectangle, null, Color.Wheat, transformComponent.Rotation,rotationOrigin, SpriteEffects.None, 0f) That's what i get And that's what I get if Vector2 rotationOrigin new Vector2.Zero What's the reason for such a weird behavoir of rotationOrigin parameter and how to correctly rotate the sprite around its center?


How do I stop stretching during window re size in XNA? In my windowed mode XNA game when the user resizes the window the game stops updating the window and the last frame drawn is stretched and distorted until the user releases the mouse and the resize completes. Is there any way to have the game continue to run "normally", updating frames and redrawing the screen, during the resize event? I realize that keeping the render loop going while resizing may not be possible or recommended due do hardware managed resources getting continually created and destroyed, but is there any way to stop the ugly stretching? Ideally by leaving the existing frame unscaled in the top left, or with a black screen if that isn't possible.


AABB SAT code detects collision wrongly I've been having trouble getting my SAT code working using AABBs, and I've been trying to find a solution but, I'm scratching my head. For some reason, it detects collisions very wrongly, as shown by this desk check I did. (AABBvsAABB method at bottom.) Consider two AABB, A and B. A X 0, Y 0, W 102, H 19 B X 87, Y 6, W 1, H 1 These are colliding. First, calculate normal Normal (0,0) (87,6) ( 87, 6) Next, we get half widths aExtent 102 2 51 bExtent 1 2 .5 Now lets calculate the overlap of the two. xExtent 51 .5 87 51.5 87 35.5 xExtent is less than zero so it says its not colliding, obviously this is wrong. lt summary gt Compares bounding boxes using Seperating Axis Thereom. lt summary gt public static bool AABBvsAABB(AABB a, AABB b, ref Manifold manifold) manifold.Normal a.Position b.Position Calculate half widths float aExtent a.Width 2f float bExtent b.Width 2f Calculate the overlap. float xExtent aExtent bExtent Math.Abs(manifold.Normal.X) If the overlap is greater than 0 if (xExtent gt 0) Calculate half widths aExtent a.Height 2f bExtent b.Height 2f Calculate overlap float yExtent aExtent bExtent Math.Abs(manifold.Normal.Y) if (yExtent gt 0) Variable to multiply the normal by to make the collision resolve Vector2 faceNormal Check to see which axis has the biggest "penetration" D Collision is happening on Y axis if (xExtent gt yExtent) faceNormal manifold.Normal.X lt 0 ? Vector2.UnitX Vector2.UnitX manifold.PenetrationDepth xExtent manifold.Normal Physics.GetNormal(a.Position, b.Position) manifold.Normal.X faceNormal.X Collision happening on X axis else faceNormal manifold.Normal.Y lt 0 ? Vector2.UnitY Vector2.UnitY manifold.PenetrationDepth yExtent manifold.Normal Physics.GetNormal(a.Position, b.Position) manifold.Normal.Y faceNormal.Y manifold.AreColliding true return manifold.AreColliding Any idea what I am doing wrong here?


Camera movement constrained to pixel boundaries So a friend and me, we are currently making a game in C using XNA. We are trying to get the camera to move in full pixel motion, but we just don't get it right. This concept is hard to explain, but i'll try to make it as clear as possible with this gif. As you can see, on the left hand side the black pixel moving in full pixel motion, while the right pixel is moving in free motion. Full pixel motion is basic motion in native resolution, but when we scale things up, the second case occurs. We are trying to avoid this, while making the camera as smooth as possible, with acceleration, deceleration, etc. The Cave Story cameras is the perfect example for this. Any ideas? Thanks for the help in advance. P.D please forgive any spelling or gramatical errors, English is not my native language.


How to make a beam follow a path in xna I'm making a 2D shmup with XNA 4.0 and one of the weapons in the game that I want is a laser beam that follows a path or a series of points and will smoothly beam along the path. How would I go about achieving this?


What's the difference between XNA Game Services and glorified global variables? The Microsoft.Xna.Framework.Game class has a Services property that allows the programmer to add a service to their game by providing the type of the class and an instance of the class to the Add method. Now, instead of having to pass an AudioComponent to all classes and methods that require it, instead you just pass your Game instance and look up the service. (Service Locator) Now, because games have many services (GraphicsDevice, SceneGraph, AudioComponent, EffectsManager, et cetera), you will now basically be passing Game to everything. So why not just make these instances a Singleton? Well, because Singletons are bad because they have a global state, prevent testing, and make your design much more brittle. Service locators are equally considered to be an anti pattern to many because instead of just passing the dependency to an object, you pass a service locator (the Game) which couples that class with the rest of the services. So then why are Services recommended in XNA and game development? Is it because games are different from regular programs and are highly intertwined with their components and having to pass every component necessary for the functioning of a class would be highly cumbersome? Are Game Services just then a necessary evil in game design? Are there alternatives that don't involve lengthy parameter lists and coupling?


How to get smooth circular input from a thumbstick in XNA? I have a mouse based game that I'm trying to get to work nicely with the Xbox gamepad. My major issue is trying to get the cursor to move smoothly like it does with the mouse. Using GamePadDeadZone.IndependentAxes makes it hard to move at slight angles, so I switched to GamePadDeadZone.Circular. It turns out that the values that I'm getting from the controller are diamond shaped instead of being circular. Pushing all the way up gives me (0,1), and pushing right gives me (1,0), but pushing to the top right gives me (.7,.7). This leads to a quite noticeable slowdown when traveling at angles. My game requires the player to move carefully at times and quickly at others, but it's near impossible because you'll move faster or slower depending on the angle of the thumbstick. How can I get truly circular data back?


How does flocking algorithm work? I read and understand the basic of flocking algorithm. Basically, we need to have 3 behaviors 1. Cohesion 2. Separation 3. Alignment From my understanding, it's like a state machine. Every time we do an update (then draw), we check all the constraints on both three behaviors. And each behavior returns a Vector3 which is the "correct" orientation that an object should transform to. So my initial idea was lt summary gt Objects stick together lt summary gt lt returns gt lt returns gt private Vector3 Cohesion() Vector3 result new Vector3(0.0f, 0.0f, 0.0f) return result lt summary gt Object align lt summary gt lt returns gt lt returns gt private Vector3 Align() Vector3 result new Vector3(0.0f, 0.0f, 0.0f) return result lt summary gt Object separates from each others lt summary gt lt returns gt lt returns gt private Vector3 Separate() Vector3 result new Vector3(0.0f, 0.0f, 0.0f) return result Then I search online for pseudocode but many of them involve velocity and acceleration plus other stuffs. This part confused me. In my game, all objects move at constant speed, and they have one leader. So can anyone share me an idea how to start on implement this flocking algorithm? Also, did I understand it correctly? (I'm using XNA 4.0)


How to position a Weapons model in a first person shooter with XNA I am building a first person shooter and positioning the weapons is hard. I am trying to get the bat to look like you are holding it but I keep trying things and they don't appear in the positions I want them to be in. Here is what I did with one version of the function. void DrawModelModel(Model model, Matrix world) Vector3 modelPosition Vector3.Zero float modelRotation 0.0f Viewport viewport graphics.GraphicsDevice.Viewport float aspectRatio (float)viewport.Width (float)viewport.Height Set the position of the camera in world space, for our view matrix. Vector3 cameraPosition new Vector3(0.0f, 0.0f, 200.0f) Copy any parent transforms. Matrix transforms new Matrix model.Bones.Count model.CopyAbsoluteBoneTransformsTo(transforms) Draw the model. A model can have multiple meshes, so loop. foreach (ModelMesh mesh in model.Meshes) This is where the mesh orientation is set, as well as our camera and projection. foreach (BasicEffect effect in mesh.Effects) effect.World transforms mesh.ParentBone.Index Matrix.CreateRotationY(modelRotation) Matrix.CreateFromYawPitchRoll(0.0f, 1.0f, 1.0f) effect.View Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up) effect.Projection Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(35.0f), aspectRatio, 1.0f, 10000.0f) Draw the mesh, using the effects set above. mesh.Draw() Here is what I did with a different version of the function. void DrawModelModel(Model model, Matrix world) Vector3 modelPosition Vector3.Zero float modelRotation 0.0f Viewport viewport graphics.GraphicsDevice.Viewport float aspectRatio (float)viewport.Width (float)viewport.Height Set the position of the camera in world space, for our view matrix. Vector3 cameraPosition new Vector3(0.0f, 0.0f, 200.0f) Copy any parent transforms. Matrix transforms new Matrix model.Bones.Count model.CopyAbsoluteBoneTransformsTo(transforms) Draw the model. A model can have multiple meshes, so loop. foreach (ModelMesh mesh in model.Meshes) This is where the mesh orientation is set, as well as our camera and projection. foreach (BasicEffect effect in mesh.Effects) effect.World transforms mesh.ParentBone.Index Matrix.CreateRotationY(modelRotation) Matrix.CreateFromYawPitchRoll(0.0f, 1.0f, 1.0f) effect.View Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up) effect.Projection Matrix.CreatePerspectiveOffCenter( 2.0f,1.0f, 0.0f, 1.0f, 1.0f, 10000.0f) Draw the mesh, using the effects set above. mesh.Draw() What matrix can I use to get the bat model to appear realistically as if you are really holding it in a first person view. I am new to matrices so my knowledge of them is basic. What matrix should I use or what parameters with my current matrix should I be editing? I am thinking the projection matrix is what I need to be editing, but I am very confused at this point. Any help would be great.


How to play a video and run content at the same time Alright, so I have a video loaded, and other game content. Earlier this morning, when I was just learning how to actually play a video, I magically happened to get the video running in the background, and also keep everything else drawn above it. I was thrilled and thought I will easily manage to do the rest. Now that I'm almost done, I have several videos that I want to draw. I made a loop that will only run one time as an intro, and then after it stops, it sequences one of the other videos, but the thing is, this next video is drawn above everything else, while the rest of my game content, is "under" the Rectangle where the video Texture is running, can anyone help me on how to get a Rectangle variable "behind" everything? almost as a background? Thanks a lot!


Trouble with the State of things in XNA I'd decided to break the mold and make my first game based on RPG mechanics (note sarcasm). An RPG style action bar would be a reasonable and fun way to get started as it's limited in scope but still challenging. I have my spell bar and three targets. I click a target, cast a spell, start the cast, put the spell on recovery cooldown, set the global cooldown, the spell goes through a casting phase then casts, the effect is applied to the target, mana is spent, the spell goes on cooldown or is removed depending. Casting is animated, cooldowns are typical gray shading. Then the other rules start to come into play. When a spell is being the cast the target cannot be changed. When a spell is on cool down we want a standard global cool down effect. When a target has an effect we put a smaller version of the icon near it which also has the same cooldown effect based on remaining duration. When the effect expires we need to remove it. When something is on cooldown and another cooldown is triggered the cooldown must become the longer of the two. Each spell on a target has an effect such as damage or shield Some effects, like shield, mitigate other effects, like damage I've ended up with too many UI concerns checking the same pieces of data. So my buttons have states, I tried the State Pattern, but ended up with the same type of crappy code in determining what state to set my objects to. Take the example that a spell can't be cast if it's on cooldown. Pretty straight forward as that's information the spell has about itself. You can't cast if you have insufficient mana, getting more complicated because now I need to know about the state of the player to properly render the spell as shaded cause it's not available, can't cast on player if effect already exists, getting ugly now I need knowledge about the target and their effects as well. Every one of these new situations resulted in my code bloating or getting stringy. I'm event driven enough to detect clicks but should I go farther and be creating events for everything such as OnSpellCastBegin, OnSpellCastInProgress, OnSpellCastComplete, OnManaChanged, OnTargetChanged? I would think it's the spell classes responsibility to answer if it can be cast but this requires it have a reference to the Player, and the PlayersTarget, and whatever else in the game in the future can effect a spell cast. What kind of design approach would support future adjustments to if a spell could be cast that followed the open closed principal where I didn't have to modify the spell class every time? thanks!


Can't load model using ContentTypeReader I'm writing a game where I want to use ContentTypeReader. While loading my model like this terrain Content.Load lt Model gt ("Text terrain") I get following error Error loading "Text terrain". Cannot find ContentTypeReader AdventureGame.World.HeightMapInfoReader,AdventureGame,Version 1.0.0.0,Culture neutral. I've read that this kind of error can be caused by space's in assembly name so i've already removed them all but exception still occurs. This is my content class ContentTypeWriter public class HeightMapInfoWriter ContentTypeWriter lt HeightmapInfo gt protected override void Write(ContentWriter output, HeightmapInfo value) output.Write(value.getTerrainScale) output.Write(value.getHeight.GetLength(0)) output.Write(value.getHeight.GetLength(1)) foreach (float height in value.getHeight) output.Write(height) public override string GetRuntimeType(TargetPlatform targetPlatform) return "AdventureGame.World.Heightmap,AdventureGame,Version 1.0.0.0,Culture neutral" public override string GetRuntimeReader(TargetPlatform targetPlatform) return "AdventureGame.World.HeightMapInfoReader,AdventureGame,Version 1.0.0.0,Culture neutral" Does anyone meed that kind of error before?


Farseer Player Movement and Collision I have added a video link for any one who whats to see what the problems are by watching the game. I am trying to create a player movement system and there are small problems that I am running into. I want to find the most accurate way of knowing if player is colliding with another object. I tried using if (Player.Body.LinearVelocity.Y 0.0f) then player is not jumping and on ground. But if I add force to the X axis the y will fluctuate. I also tried to use OnCollision but am confused on how to use it. What is the best way to know if the player is colliding with the ground and can jump? The player slides across the ground like it's ice how do i fix this problem? How would I make it into quick and sudden stops with little sliding. Lets say I had a one color texture, and I wanted to use it on a rectangle and a circle but could not bother to make 2 textures and just want to do it in the coding. How could I make this texture go from a rectangle to any shape I want? If OnCollision is the best way for me to detected where the player is hit (left, right, top, or bottom) and then use for the best and quickest collision test, were can I learn how to use this thing properly? Here is the Video. How do you delete an object, I got the texture to go but not the object itself. The objects are spawned in and then stored on a list. How do you remove them from the list? How come the player on the top left is more clearer then the player being controlled?


HLSL texture not reading from register S1 I made a simple post processing shader, that draws scanlines. This all works perfectly. I wanted to make it a bit more interesting by applying a shadowmask instead so I wanted to pass a texture to the shader. From my understanding the Spritebatch sets Texture Register(S0), so I set my shadowmask texture to Texture Register(s1). When applying the shader is seems that both S0 and S1 contain the texture I plan to draw. I have tried to set parameters in different ways without succes. How can I pass the Texture? My HLSL code sampler ScreenTextureSampler register (s0) This is the texture that SpriteBatch will try to set before drawing sampler ShadowSampler register (s1) This is set in GraphicsDevice.Textures 1 int colorlines 2 int shadowlines 1 PIXEL SHADER float4 PixelShaderFunction(float4 pos SV POSITION, float4 color1 COLOR0, float2 texCoord TEXCOORD0) SV TARGET0 float4 color tex2D(ScreenTextureSampler, texCoord.xy) float4 maskcolor tex2D(ShadowSampler, texCoord.xy) float ypos pos.y float scanline (ypos) (colorlines shadowlines) float intensity scanline lt colorlines ? 1 0.20f comment out one of these two return statements... return maskcolor intensity note this return has the exact same result return color intensity as this one! even though the samplers point at different registers. technique Postprocessing pass Pass1 PixelShader compile ps 4 0 PixelShaderFunction() This shader is loaded in an Effect called Assets.GameArt.PostProcessor. I have a shadowmask Texture2D in Assets.GameArt.shadowTexture. My C , Monogame code looks like this gd.SetRenderTarget(null) sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, Assets.GameArt.PostProcessor, Resolution.getTransformationMatrix()) gd.Textures 1 Assets.GameArt.shadowTexture sb.Draw( gameRenderTarget, Vector2.Zero, camera.Viewport, Color.White) sb.End() gd points to the GraphicsDevice and sbis the spriteBatch. I first render my scene to a gameRenderTarget. Why isn't the Texture passed via the S1 register (or why do the texture samplers both return the same result?)


Playing Video In MonoGame I'm trying to play a video in a monogame project. I've done this in XNA in the past by including the Framework.Video directory and it's very simple. This cannot be done in monogame as Visual Studio 2012 wont accept the XNA directories. I've not been able to find any other way explained anywhere if you can actually put video in monogame yer and if you can how it's done. Any ideas?


What is the most efficient way to work with lip sync facial expressions in XNA? I've been searching for an answer forever, but I haven't found one. What options are there for lip sync facial expressions in video games made with XNA? I have a few models for a game I'm building, and I would like to know if it would be better to set up an animation for every dialogue, but that would be very time consuming and the whole collection of files would result in a massive sized program. I was thinking about an automated lip sync system, but I wouldn't know where to start! Any thoughts?


Rendering lighting only on specific objects I have done something similar to this in monogame My question is, what would I have to do to draw that lighting effect only on the pillar and not the background ? Is there something like ignoring certain sprites when using BlendState.Additive ? How would that work ? Here is how i'm drawing it now. draw background spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque) spriteBatch.Draw(Background, Vector2.Zero, Color.White) spriteBatch.End() draw pillar spriteBatch.Begin(SpriteSortMode.Deferred) spriteBatch.Draw(Texture, new Rectangle(PillarX, PillarY, Width, Height), Color.White) spriteBatch.End() draw lighting sprite in additive mode spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive) spriteBatch.Draw(LightTexture, pos, null, Color.OrangeRed, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f) spriteBatch.End() Edit Also, apart from the pillar I have as an example, I need to do that for 3D models as well, so would the Stencil Buffer work here ?


Is it OK to release the source code for your own Xbox Live indie game? Between not being sure how to phrase my question for Google and not being a lawyer, I thought it might be easier to ask you guys. Specifically, I want to know if it's OK to sell an Xbox Live indie game while simultaneously distributing the source code and other assets via GitHub or something. Edit The Communist Duck asked "why not?" One reason I can think of is that Microsoft has a small stake in a game's sales. They are hosting the demo full game, they might be dedicating an advertising slot to the game in their "latest" section, etc. It's true they get a cut of each sale, but they get nothing if everyone just goes and downloads the free version. Anyway, it's not a matter of what is reasonable and logical, it's a matter of what the terms and conditions allow. I'm going to read through them regardless, but I was hoping someone already knew.


Automating XNA Performance Testing? I was wondering what peoples approaches or thoughts were on automating performance testing in XNA. Currently I am looking at only working in 2d, but that poses many areas where performance can be improved with different implementations. An example would be if you had 2 different implementations of spatial partitioning, one may be faster than another but without doing some actual performance testing you wouldn't be able to tell which one for sure (unless you saw the code was blatantly slow in certain parts). You could write a unit test which for a given time frame kept adding updating removing entities for both implementations and see how many were made in each timeframe and the higher one would be the faster one (in this given example). Another higher level example would be if you wanted to see how many entities you can have on the screen roughly without going beneath 60fps. The problem with this is to automate it you would need to use the hidden form trick or some other thing to kick off a mock game and purely test which parts you care about and disable everything else. I know that this isnt a simple affair really as even if you can automate the tests, really it is up to a human to interpret if the results are performant enough, but as part of a build step you could have it run these tests and publish the results somewhere for comparison. This way if you go from version 1.1 to 1.2 but have changed a few underlying algorithms you may notice that generally the performance score would have gone up, meaning you have improved your overall performance of the application, and then from 1.2 to 1.3 you may notice that you have then dropped overall performance a bit. So has anyone automated this sort of thing in their projects, and if so how do you measure your performance comparisons at a high level and what frameworks do you use to test? As providing you have written your code so its testable mockable for most parts you can just use your tests as a mechanism for getting some performance results... Edit Just for clarity, I am more interested in the best way to make use of automated tests within XNA to track your performance, not play testing or guessing by manually running your game on a machine. This is completely different to seeing if your game is playable on X hardware, it is more about tracking the change in performance as your game engine framework changes. As mentioned in one of the comments you could easily test "how many nodes can I insert remove update within QuadTreeA within 2 seconds", but you have to physically look at these results every time to see if it has changed, which may be fine and is still better than just relying on playing it to see if you notice any difference between version. However if you were to put an Assert in to notify you of a fail if it goes lower than lets say 5000 in 2 seconds you have a brittle test as it is then contextual to the hardware, not just the implementation. Although that being said these sort of automated tests are only really any use if you are running your tests as some sort of build pipeline i.e Checkout Run Unit Tests Run Integration Tests Run Performance Tests Package So then you can easily compare the stats from one build to another on the CI server as a report of some sort, and again this may not mean much to anyone if you are not used to Continuous Integration. The main crux of this question is to see how people manage this between builds and how they find it best to report upon. As I said it can be subjective but as knowledge will be gained from the answers it seems a worthwhile question.


How can I improve the performance of handling many objects to draw in XNA? I have a 2D engine that uses XNA 4.0. I have an issue with handling many objects. In my engine, I only draw visible sprites, and ignore sprites outside of the current viewport. It works, so far. I also use a RenderTarget to minimize the amount of sprite batch being called, to draw the base. I also need to draw buildable objects, and the worst case is that there is a list with 10,000 20,000 objects. I need to iterate through them, to find the visible buildable objects, as well. This really affects my frame rate, especially when the viewport changes. I could decrease the zoom level, to minimize the amount of base tiles, but the list of objects keeps the same. Using smaller texture sizes could help, but then I m also losing detail. How could I improve the performance?


How can I get a list of sprites which are being drawn in the current viewport using XNA? Just starting out using XNA to draw 3D scenes and have a question about determining which objects are currently visible. If I load many thousands of sprites and shapes in a scene, then render the current view from a camera, is it possible to actually find (e.g. list to a text file) the IDs of those visible objects? I guess another way to ask this is to say how can I get a list of objects (e.g. sprites) which are being drawn in the current viewport?


How do I make a tile passable in one direction only? I want that my character can jump through some of the tiles, like Mario does in this video http www.youtube.com watch?v zIPYzbNrNhc In this video, Mario jumps up through orange platforms, but does not fall down through them. How can I do that with Farseer?


SpriteBatch passing textures to GPU How exactly (or, how often) are textures passed to the GPU shaders in MonoGame XNA? I am asking because I was profiling a MonoGame XNA application and noticed that the memory controller load (using GPU Z) was pretty high. After disabling pretty much everything except the background texture (a static 24 bit 1920x1080 image), my frame rate went up as expected ( 500fps) with GPU load peaking at 99 but what surprised me was that the GPU memory controller load remained at 50 . Setting the breakpoint inside TextureCollection.PlatformSetTextures confirmed that SpriteBatch is indeed passing this texture to the pixel shader on each call. Does this really mean that all textures are being passed to GPU on each frame over and over again? Am I misinterpreting these readings, or have a fundamentally wrong understanding of how the rendering process should work? Or did I mess something up with my Draw calls?


Drawing Farseer Fixtures Is there any way how to draw a Polygon Fixture from Farseer Physics with XNA? As I deform these polygons at runtime I can't take any texture from my Content folder, the texture must be generated at runtime too.


Going from using XMLSerializer to using the XNA Content Pipeline A well known limitation of using the XNA Content Pipeline is that it is not included in the XNA redistributable. So, if you want to create an editor for your game, the designer must download the whole deal your editor, your engine, XNA Game Studio and Visual Studio Express. Even then, I'm not sure you can compile your XML data into xnb outside of Visual Studio. So I decided to simply use XMLSerializer, which works fine. However, I'm thinking that, once all the content of my game is done, prior to release, it would be great if I could convert the whole system into using the XNA Content Pipeline. In my mind, I think that the compiled xnb files would load faster than deserializing XML into objects. Is the conversion possible? More importantly, is it worth it? Note my intention is to release the game as an XBOX Live Indie Game.


Tile Based Sprite Collision With Lots of Sprites I am running into lag when loading many sprites onto the screen. If I have less than 12 on the screen it runs smoothly until I add a couple more and then it bogs down. I currently have this as my detection code public void Collision(Sprite sprite, Rectangle newRectangle, bool passable, bool speedRestricted, int xOffset, int yOffset) Tile boundaries if (sprite.Bounds.Top(newRectangle) amp amp passable false) animation.Position new Vector2(sprite.Position.X, (newRectangle.Y sprite.Bounds.Height)) if (sprite.Bounds.Left(newRectangle) amp amp passable false) animation.Position new Vector2((newRectangle.X sprite.Bounds.Width), sprite.Position.Y) if (sprite.Bounds.Right(newRectangle) amp amp passable false) animation.Position new Vector2((newRectangle.X sprite.Bounds.Width), sprite.Position.Y) if (sprite.Bounds.Bottom(newRectangle) amp amp passable false) animation.Position new Vector2(sprite.Position.X, (newRectangle.Y sprite.Bounds.Height)) It is called in like this foreach (var tile in map.CollisionTiles) player.Collision(player, tile.Rectangle, tile.Passable, tile.SpeedRestricted, map.Width, map.Height) foreach (var sprite in sprites) sprite.Collision(sprite, tile.Rectangle, tile.Passable, tile.SpeedRestricted, map.Width, map.Height) Now collision detection works perfectly so I don't have an issue there it's just when there are lots of sprites in my List lt Sprite gt sprites does it lag. If I remove the collision detection from the code I can load thousands of sprites onto the map. Question How do I limit the detection area for the sprites so it only compares the tiles around the sprite instead of all the tiles on the map for each sprite. I have looked through the other questions and found none when it comes to multiple sprite detections for tile maps, just the main player's collision detection.


Farseer physics engine The name 'ConvertUnits' does not exist in the current context http digitalerr0r.wordpress.com 2012 03 11 farseer physics in xna 4 0 for windows phone 1 I tried this Farseer tutorial but I always get that error message in the following lines spriteBatch.Draw(rectangleSprite, ConvertUnits.ToDisplayUnits(rectangle.Position), null, Color.White, rectangle.Rotation, new Vector2(rectangleSprite.Width 2.0f, rectangleSprite.Height 2.0f), 1f, SpriteEffects.None, 0f) spriteBatch.Draw(rectangleSprite, ConvertUnits.ToDisplayUnits(rectangle2.Position), null, Color.White, rectangle2.Rotation, new Vector2(rectangleSprite.Width 2.0f, rectangleSprite.Height 2.0f), 1f, SpriteEffects.None, 0f) spriteBatch.Draw(rectangleSprite, ConvertUnits.ToDisplayUnits(rectangle3.Position), null, Color.White, rectangle3.Rotation, new Vector2(rectangleSprite.Width 2.0f, rectangleSprite.Height 2.0f), 1f, SpriteEffects.None, 0f) What is wrong? I added the two usings to my code but I always get this error message The name 'ConvertUnits' does not exist in the current context


Drawing simple geometric figures with DrawUserPrimitives? I'm trying to draw a simple triangle based on an array of vertex. I've been searching for a tutorial and I found a simple example on riemers but I couldn't get it to work. I think it was made for XNA 3 and it seems there were some changes to XNA 4? Using this example http www.riemers.net eng Tutorials XNA Csharp Series1 The first triangle.php I get this error Additional information The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing. I'm not english so I'm having some trouble to understand everything. For what I understand error is confusing because I'm trying to draw a triangle color based and not texture based and it shouldn't need a texture. Also I saw some articles about dynamic shadows and lights and I would like to know if this is the kind of code used to do it with some tweaks like culling because I'm wondering if its heavy code for performance in real time. public void LoadContent() effect Game.Content.Load lt Effect gt ("Effect1") playerVision new VertexPositionColor 3 playerVision 0 .Position new Vector3( 0.5f, 0.5f, 0f) playerVision 0 .Color Color.Red playerVision 1 .Position new Vector3(0, 0.5f, 0f) playerVision 1 .Color Color.Green playerVision 2 .Position new Vector3(0.5f, 0.5f, 0f) playerVision 2 .Color Color.Yellow comes from draw method private void drawPlayerVision(GameTime gameTime, SpriteBatch spriteBatch) effect.CurrentTechnique effect.Techniques "Pretransformed" Game.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, playerVision, 0, 1, VertexPositionColor.VertexDeclaration)


XNA Easy Storage XBOX 360 High Scores To followup from a previous query I need some help with the implementation of easystorage high scores, which is bringing up some errors on the xbox. I get the prompt screen, a savedevice is selected and a file are all created! However the file remains empty, (I've tried prepopulating but still get errors). The full portions of the scoring code can be found here http pastebin.com 74v897Yt The current issue in particular is in LoadHighScores() "There is an error in XML document (0, 0)." under line data (HighScoreData)serializer.Deserialize(stream) I'm not sure whether this line is correct either HighScoreData data new HighScoreData() public static HighScoreData LoadHighScores(string container, string filename) HighScoreData data new HighScoreData() if (Global.SaveDevice.FileExists(container, filename)) Global.SaveDevice.Load(container, filename, stream gt File.Open(Global.fileName options, FileMode.OpenOrCreate, FileAccess.Read) try Read the data from the file XmlSerializer serializer new XmlSerializer(typeof(HighScoreData)) data (HighScoreData)serializer.Deserialize(stream) finally Close the file stream.Close() stream.Dispose() ) return (data) I call PromptMe() when the Start button is pressed at the beginning. I call if (Global.SaveDevice.IsReady) entries LoadHighScores(HighScoresContainer, HighScoresFilename) during the menu screen to try and display the highscore screen. I call SaveHighScore() when game ends. I've tried altering the struct code to a class but still no luck. Any help greatly appreciated.


Breakout... Getting the ball reflection X angle when htitting paddle bricks 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 getting the ball to bounce off of the paddle and bricks correctly based off of where the ball touches the object. This is my forumala thus far if (paddleLocation.Intersects(ballLocation)) position.Y paddleLocation.Y texture.Height motion.Y 1 determine X motion.X 1 2 (ballLocation.X paddleLocation.X) (paddleLocation.Width 2) The problem is, the ball goes the opposite direction then its supposed to. When the ball hits the left side of the paddle, instead of bouncing back to the left, it bounces right, and vise versa. Does anyone know what the math equation is to fix this?


Looking for XNA patterns Hello mature game developers. Im just started with XNA, but i got solid expirence with C . I wonder is there any common code patterns for XNA games? Like should i make classes wich handle draw and update separatly, like draw model and world data model? Or should i try to put as much code as possible in Game1 ? Im totaly lost in project structure building. Thx for any answers.


Speed up content loading I am using WinForms Sample downloaded from microsoft website. The problem is, that the model loading time is quite long, using contentBuilder.Add(ModelPath, ModelName, null, "ModelProcessor") contentManager.Load lt Model gt (ModelName) even a simple model, such as a cube with no textures, takes 4 seconds to load. Now, I am no expert on this, but is there anyway to decrease loading time? EDIT I've gone thru the code and found out that calling contentBuilder.Build() ,which comes right after contentBuilder.Add() method takes up most of the time.


Problem drawing text in a for loop for (int i 5 i lt 5 i ) Rectangle screenRectangle new Rectangle(0, 0, screenWidth, screenHeight) spriteBatch.Draw(foregroundTexture, screenRectangle, Color.White) Rectangle backGroundRectangle new Rectangle(x screenWidth i, 0, screenWidth, screenHeight) spriteBatch.Draw(backgroundTexture, backGroundRectangle, Color.White) spriteBatch.DrawString(font, "Variable i " i, new Vector2(0, 0), Color.Brown) I want to show on the screen when I'm running the game the counting of i like 5 , 4 , 3...but not in a line, just like a timer. 5 then overwrite it and show 4 overwrite it and show 3 and so on...like seconds of a clock. The problem is I'm getting a strange painting near the numbers like its repeating and painting something there all the time.


How can I determine the contact point of a collision? I have two Farseer bodies. A static rectangle and a dynamic ball that is flying around. I want to determine where the ball touched the rectangle. I need the exact coordinates of the contact point. How can I do that? Is there a way to determine the contact point? bool BlueRectangle OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact) if (fixtureB.Body RedBall) Vector2 normal FixedArray2 lt Vector2 gt worldPoints contact.GetWorldManifold(out normal, out worldPoints) if(contact.Manifold.PointCount gt 1) Vector2 contactPoint worldPoints 0 return true It works with the following code.


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 jumps it will be moving on one of its side. There's not much code to show but I'll show you how I'm rotating if (jumped) roation 0.1f playerVel.Y gravity I haven't initialized rotation to anything. I've also tried using some Math functions but I just get the same result.


How do I take a screenshot and blur it? I want to take a screenshot of the game when it's running, blur it and draw it on the screen. Could you help me with taking a screenshot and blurring it?


Sketchup model renders wrong in XNA My XNA model renders wrong. It should render like that But it renders like that The background doesn't matter. It's just the model that renders wrong. Here is the drawing code protected override void Draw(GameTime gameTime) GraphicsDevice.Clear(Color.CornflowerBlue) DrawModel(model) base.Draw(gameTime) private void DrawModel(Model m) GraphicsDevice.RasterizerState RasterizerState.CullNone Matrix worldMatrix Matrix.CreateRotationY(MathHelper.ToRadians(rot)) Matrix.CreateTranslation(new Vector3(0,0,0)) foreach (ModelMesh mesh in m.Meshes) foreach (BasicEffect effect in mesh.Effects) effect.EnableDefaultLighting() effect.World worldMatrix effect.View viewMatrix effect.Projection projectionMatrix mesh.Draw()


Understanding how texCUBE works and writing cubemaps properly into a cube rendertarget My goal is to create accurate reflections, sampled from a dynamic cubemap, for specific 3d objects (mostly lights) in XNA 4.0. To sample the cubemap I compute the 3d reflection vector in a classic way half3 ReflectionVec reflect( directionToCamera, Normal.rgb) I then use the vector to get the actual reflected color half3 ReflectionCol texCUBElod(ReflectionSampler, float4(ReflectionVec, 0)) The cubemap I am sampling from is a RenderTarget with 6 flat faces. So my question is, given the 3d world position of an arbitrary 3d object, how can I make sure that I get accurate reflections of this object, when I re render the cubemap. Should I build the ViewProjection matrix in a specific way? Or is there any other approach?


Viewport.Unproject Checking if a model intersects a large sprite Let's say I have a sprite, drawn like this spriteBatch.Draw(levelCannons i .texture, levelCannons i .position, null, alpha, levelCannons i .rotation, Vector2.Zero, scale, SpriteEffects.None, 0) Picture levelCannon as being a laser beam that goes across the entire screen. I need to see if my 3d model intersects with the screen space inhabited by the sprite. I managed to dig up Viewport.Unproject, but that seems to only be useful when dealing with a single point in 2d space, rather than an area. What can I do in my case?


Downsides of using this integration formula for movement? So I read that Gaffron integration basics tutorial and noticed how the Euler integration method gives a small error over time. I implemented the RK4 and noticed that with constant acceleration, I could simplify the formula. Over the course of an hour with some use of wolframalpha, I noticed that the formula eventually just simplifies down to just this float dt (float)gameTime.ElapsedGameTime.TotalSeconds Position (0.5f Acceleration dt Velocity) dt Velocity Acceleration dt I ran it through a console and sure enough, it gives the proper values for each timestep and the correct final value. Will this formula always yield perfectly accurate answers? My acceleration will always be constant. Is there a name for this formula?


How to play a video and run content at the same time Alright, so I have a video loaded, and other game content. Earlier this morning, when I was just learning how to actually play a video, I magically happened to get the video running in the background, and also keep everything else drawn above it. I was thrilled and thought I will easily manage to do the rest. Now that I'm almost done, I have several videos that I want to draw. I made a loop that will only run one time as an intro, and then after it stops, it sequences one of the other videos, but the thing is, this next video is drawn above everything else, while the rest of my game content, is "under" the Rectangle where the video Texture is running, can anyone help me on how to get a Rectangle variable "behind" everything? almost as a background? Thanks a lot!


How can I implement view wobble when my player is running? I'm creating a FPS in XNA. So far its' going great. What I'm looking at doing is replicating the camera movements that you see in Modern Warfare. So, if you are walking the camera stays pretty still except for the slight weapon movement, but if you sprint then it shakes left and right. Here is a good example Modern Warfare 2 camera motion Has anyone achieved this? If so, can anyone give any pointers or articles that I can take a look at?


How can I export models from 3DX Max into XNA? I am looking for a way to import my 3D models (including materials and shaders) from 3D Studio Max to XNA. For example, if I have a model with diffuse, bump, reflection textures and values (through Max's basic shader), I want to be able to present it in real time using the XNA framework. I thought about doing it like this 3D Studio Max ASCII FBX export. Parse FBX and extract bump reflection et cetera textures. Set up a custom HLSL shader and pass the relevant parameters to it. Is this the correct way to do it?


How can I fade something to clear instead of white? I've got an XNA game which essentially has "floating combat text" short lived messages that display for a fraction of a second and then disappear. I've recently added a gradual "fade away" effect, like so public void Update() color.A 10 position.X 3 if (color.A lt 10) isDead true Where color is the Color int the message displays as. This works as expected, however, it fades the messages to white, which is very noticeable on my indigo background. Is there some way to fade it to transparent, rather than white? Lerp ing towards the background color isn't an option, as there's a possibility there will be something between the text and the background, which would simply be the inverse of the current problem.


using per pixel collision for an elastic response I realize this might be open ended ended but curious if I just did some over kill... I had this http xbox.create.msdn.com en US education catalog tutorial collision 2d perpixel and i reworked it to work with my animation code in XNA and what not. It works well, but now I want to use this to decide if there was a collision and to have the items (characters) bounce off eachother elastically. Was the per pixel too much and I could of just used a bounding box ? (in fact would that of been preferred for what needs to be calculated in the response for an elastic collision?) Looking for guidance really.


XNA GameDefaults Class Settings Are items such as the GameDifficulty enum, game settings, and other things in the GameDefaults class used for a lot? If so, is there a way to edit them or anything of the sorts?


fbx file asks for fbm file in xna? I downloaded a bat model from the internet and I went to Blender, used texture and shading as I want, then I exported it as a fbx file. Next I placed it into my content pipeline and ran it but it is asking me for the path of a .fbm file. It says Error Missing asset C .... Game obj x86 Debug FBX 387D35A3 bat.fbm wpn fps mel barbedwire df.dds What does this mean. How can I place these images in that file like that?


How can I use a filter to scale down my sprites? I want the best visual result on my Windows Phone if I scale down my sprites from 1920x1080 pixel resolution to 800x480 pixel resolution. How can I use a filter to scale down my sprites? Which filter is the best?


Spaceship Shield Flare I'm trying to implement a system whereby a "shield flare" will be shown whenever a projectile impacts the shield. The shield itself is one like in Star Wars, where it's more like a skin around the spaceship, rather than a simple bubble. The problem I'm having is determining how to draw a simple flare effect where the projectile impacted the shield. I can determine the Vector2 point where the shield was hit. Right now, I'm able to show the whole shield whenever it's hit just fine. The problem as I see it, is that I somehow need to mask out the shield, except for a few pixels around the point of impact. Either that, or I'm going about this the completely wrong way. What I can do so far is draw the whole shield What I need is to be able to draw a piece of the shield on the point of impact Any help would be appreciated.


How to circle a target at a constant distance I have an AI ship that stops approaching when it gets within firing range, and starts strafing around its target. The problem is that it doesn't circle its target very well. The following code attempts to do this, and for short periods of time, it's convincing, but as soon as you let it run for 5 10 seconds, the AI ship drifts out of range of the target and is forced into the approach state again. Vector2 tangent Vector2.Normalize(new Vector2(TargetVector.Y, TargetVector.X)) velocity 0.8f tangent accelerationMagnitude (float)gameTime.ElapsedGameTime.TotalSeconds velocity 0.2f TargetVector accelerationMagnitude (float)gameTime.ElapsedGameTime.TotalSeconds The above doesn't work for obvious reasons, so I attempted to bring the target into my frame of reference using the following Vector2 tangent new Vector2(TargetVector.Y, TargetVector.X) Vector2 asdf tangent (velocity (float)gameTime.ElapsedGameTime.TotalSeconds) velocity Vector2.Normalize(asdf) accelerationMagnitude (float)gameTime.ElapsedGameTime.TotalSeconds Here is a quick video on how it behaves using the second method while trying to maintain a firing distance of 350 https www.youtube.com watch?v 16Bc46ekJI0 The white line and number indicate the Ship Station vector and distance, and red circles are the weapon ranges. How do I make my AI ship circle its prey convincingly?


Problem with Update(GameTime) Methods and Pause implementation I have the pause function implemented and it works correctly in that it dims the player screen and stops updating the gameplay. The problem is that GameTime continues to increase while it is paused, so my method that checks gameTime versus previousSpawnTime before spawning another enemy gets messed up and if the game is paused too long it is noticeable that the next enemy draws far too early. Here is my code for the enemy update. private void UpdateEnemies(GameTime gameTime) Spawn a new enemy every 1.5 seconds if (gameTime.TotalGameTime previousSpawnTime gt enemySpawnTime) previousSpawnTime gameTime.TotalGameTime Add an Enemy AddEnemy() ... I also have other methods that depend on gameTime. I've tried getting the total pause time and subtracting that from the total game time, but I can't seem to get it to work correctly if that is the way I should go about solving this. If you need to see any other code let me know. Thank you.


Rotating a vector by a quaternion I am trying to rotate a direction vector (0,0,1,0) by a rotation quaternion in DirectX. From what understanding, to rotate the vector you must do NewVector rotQuaternion Vector inverse(rotQuaternion) In directX11, I am testing out the algorithm above using an identity quaternion. XMVECTOR qIdentity XMQuaternionIdentity() XMVECTOR inverse XMQuaternionInverse(qIdentity) XMVECTOR test qIdentity XMVectorSet(0.0f,0.0f,1.0f,0.0f) inverse My new test vector should just be (0,0,1,0), however it is completely zeroed out, and I am not exactly sure why or if I multiplied it correctly.


Creating Entities from Identifiers (C ) I am writing a game in C XNA. Often, it's useful to have a function like this in a game engine Entity CreateEntity(string id, Vector3 location) ... So that, for instance, you can do something like this List lt string gt entitiesToSpawn "Tree", "Bird", "Flower", ... foreach (string entity in entitiesToSpawn) CreateEntitiy(entity, location) Or else you can easily store the ids in data files, or populate generic GUI elements with them, for instance. What, in your opinion, is the best way to implement CreateEntity in such a way that is scalable and preserves this kind of interface? Right now, I have a gigantic static switch statement, which is obviously not sustainable. Perhaps I can create a big static map of strings to functions? Or is there an easier way to get this kind of functionality out of my engine?


Drag Gestures fractional delta values I have an issue with objects moving roughly twice as far as expected when dragging them. I am comparing my application to the standard TouchGestureSample sample from MSDN. For some reason in my application gesture samples have fractional positions and deltas. Both are using same Microsoft.Xna.Framework.Input.Touch.dll, v4.0.30319. I am running both apps using standard Windows Phone Emulator. I am setting my break point immediately after this line of code in a simple Update method GestureSample gesture TouchPanel.ReadGesture() Typical values in my app Delta X 13.56522 Y 4.166667 Position X 184.6956 Y 417.7083 Typical values in sample app Delta X 7 Y 16 Position X 497 Y 244 Have anyone seen this issue? Does anyone have any suggestions? Thank you.


Cleaner implementation of this draw call Simple static class that will write out a message that is passed in. The SpriteSheet is 256x256 and the A Z starts at line 240 and the 0 9 starts at 248. Each character is 8x8. I hate the if (ix gt 32) and wondered if there is a tidier way of doing this? I'm pleased it's only one Draw call, but it looks ugly. public static class Font private static String chars "" "ABCDEFGHIJKLMNOPQRSTUVWXYZ " "0123456789.,!?' " () lt gt " "" public static void Draw(string msg, SpriteSheet sprites, SpriteBatch spriteBatch, int x, int y, Color color) msg msg.ToUpper() for (int i 0 i lt msg.Length i ) int ix chars.IndexOf(msg i ) int w 0, h 240 if (ix gt 0) if (ix gt 32) w 32 h 248 spriteBatch.Draw(sprites.Sheet, new Rectangle(x i 8, y, 8, 8), new Rectangle((ix w) 8, h, 8, 8), color)


Reading messages from a certain client in Lidgren I'm setting up a game with Lidgren, and I was wondering if there was a way to read a message from a certain client instead of just from the server as a whole, such as Why doesn't this exist? NetIncomingMessage message server.Connections 0 .ReadMessage() This way I would be able to split up reading data from each client into it's own thread and have a separate thread for sending data to each client. Currently there is only one loop in my server, which reads packets and I fear is favoring one client more than others, as some movements made by players take a while to be received by other players. I believe reading messages separately from each client would solve this issue. With simple TcpClients, you can read from each client's stream instead of the server as a whole, and I like this functionality but also rely on the simplicity of sending packets through Lidgren and was wondering if there was a similar functionality with Lidgren.


Creating mesh at run time I've a set of voxel data and I want to create a mesh out of it at run time. I've looked into MeshBuilder and MeshHelper but I haven't found anything useful or a good tutorial how to use them. Can anyone tell me how to create a mesh at run time?


Particle System in XNA cannot draw particle I'm trying to implement a simple particle system in my XNA project. I'm going by RB Whitaker's tutorial, and it seems simple enough. I'm trying to draw particles within my menu screen. Below I've included the code which I think is applicable. I'm coming up with one error in my build, and it is stating that I need to create a new instance of the EmitterLocation from the particleEngine. When I hover over particleEngine.EmitterLocation new Vector2(Mouse.GetState().X, Mouse.GetState().Y) it states that particleEngine is returning a null value. What could be causing this? lt summary gt Base class for screens that contain a menu of options. The user can move up and down to select an entry, or cancel to back out of the screen. lt summary gt abstract class MenuScreen GameScreen ParticleEngine particleEngine public void LoadContent(ContentManager content) if (content null) content new ContentManager(ScreenManager.Game.Services, "Content") base.LoadContent() List lt Texture2D gt textures new List lt Texture2D gt () textures.Add(content.Load lt Texture2D gt ( "gfx circle")) textures.Add(content.Load lt Texture2D gt ( "gfx star")) textures.Add(content.Load lt Texture2D gt ( "gfx diamond")) particleEngine new ParticleEngine(textures, new Vector2(400, 240)) public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen) Update each nested MenuEntry object. for (int i 0 i lt menuEntries.Count i ) bool isSelected IsActive amp amp (i selectedEntry) menuEntries i .Update(this, isSelected, gameTime) particleEngine.EmitterLocation new Vector2(Mouse.GetState().X, Mouse.GetState().Y) particleEngine.Update() public override void Draw(GameTime gameTime) make sure our entries are in the right place before we draw them UpdateMenuEntryLocations() GraphicsDevice graphics ScreenManager.GraphicsDevice SpriteBatch spriteBatch ScreenManager.SpriteBatch SpriteFont font ScreenManager.Font spriteBatch.Begin() Draw stuff logic spriteBatch.End() particleEngine.Draw(spriteBatch)


What is a good way to store tilemap data? I'm developing a 2D platformer with some uni friends. We've based it upon the XNA Platformer Starter Kit which uses .txt files to store the tile map. While this is simple it does not give us enough control and flexibility with level design. Some examples for multiple layers of content multiple files are required, each object is fixed onto the grid, doesn't allow for rotation of objects, limited number of characters etc. So I'm doing some research into how to store the level data and map file. This concerns only the file system storage of the tile maps, not the data structure to be used by the game while it is running. The tile map is loaded into a 2D array, so this question is about which source to fill the array from. Reasoning for DB From my perspective I see less redundancy of data using a database to store the tile data. Tiles in the same x,y position with the same characteristics can be reused from level to level. It seems like it would simple enough to write a method to retrieve all the tiles that are used in a particular level from the database. Reasoning for JSON XML Visually editable files, changes can be tracked via SVN a lot easier. But there is repeated content. Do either have any drawbacks (load times, access times, memory etc) compared to the other? And what is commonly used in the industry? Currently the file looks like this .................... .................... .................... .................... .................... .................... .................... .........GGG........ ......... ........ .................... ....GGG.......GGG... .... ....... ... .................... .1................X. 1 Player start point, X Level Exit, . Empty space, Platform, G Gem


Why are triangle fans not supported in Direct3D 10 or later? As covered in the documentation, triangle fans not supported in Direct3D 10 or later. Why? Are there inherent drawbacks to working with triangle fans?


Determine arc length of a Catmull Rom spline to move at a constant speed 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. Not every spline in this path has the same length. This causes speed differences if I let the weight go at a constant speed for every spline while proceeding along the path. I can remedy this by letting the speed of the weight be dependent on the length of the spline. How can I determine the length of such a spline? Should I just approximate by cutting the spline into 10 straight lines and sum their lengths? I'm using this for dynamic texture mapping on a generated mesh defined by splines.