xna

Render a section of an image to a Bitmap C# Winforms

I'm working on a Map Editor for an XNA game I'm designing in my free time. The pieces of art used in the map are stored on a single texture and rectangles are stored with coordinates and widths etc. In the winforms application I can add segments by selecting the segment I want from a listbox, which is populated from the array of possib...

How do games handle saved content?

I don't see an answer to this question here on SO which makes me afraid that it's incredibly simple and I'm just missing something but here goes. Background, feel free to skip: I need a single course for my bachelor's degree that I skipped out on years ago. Theoretically it's Computer Graphics, but since I left it has become more Game...

Basic pathfinding with obstacle avoidance in a continuous 2D space

I'm writing a simulation in which a creature object should be able to move towards some other arbitrary object in the environment, sliding around obstacles rather than doing any intelligent pathfinding. I'm not trying to have it plan a path -- just to move in one general direction, and bounce around obstacles. It's a 2D environment (ove...

XNA: Applying SpriteBatch.Draw(...) color only to non-transparent pixels

I have a sprite loaded from a PNG that has an alpha channel. The image contains an opaque disk, and the rest of it is transparent. I want to use the color argument of SpriteBatch.Draw(...) to change the tint of the disk. However, the default blending behavior applies the color to the entire sprite, so I end up with an opaque square outl...

How to slow down or stop key presses in XNA

Hi, I've begun writing a game using XNA Framework and have hit some simple problem I do not know how to solve correctly. I'm displaying a menu using Texture2D and using the keyboard (or gamepad) I change the menu item that is selected. My problem is that the current function used to toggle between menu items is way too fast. I might cl...

XNA/DirectX: Should you always use indices?

I'm implementing billboards for vegetation where a billboard is of course a single quad consisting of two triangles. The vertex data is stored in a vertex buffer, but should I bother with indices? I understand that the savings on things like terrain can be huge in terms of vertices sent to the graphics card when you use indices, but usin...

UI library for XNA

I'm working on a small and simple XNA game and I'm noticing I'm spending way too much time implementing basic UI functionality like menus, (rich) text rendering including wrapping and basic UI lay-out such as alignment of elements. This is a fairly common problem, and I was wondering whether anyone knows of a library to handle these th...

XNA collision detection

I have a ball moving inside a cube, and I detect when it goes outside of the cube (with a bounding sphere and a bounding box). Now I would like to detect from which side the ball goes out. Then I could redirect the ball in the correct direction. How can I do this with the ball's “world” matrix? Should I keep track of the ball's coordina...

When to use multiple sprite batches in XNA?

In XNA, when is it appropriate to render your game content using more than one spritebatch? So far I've never used more than one, and have never noticed any downsides to this approach. In what situations would using multiple spritebatches be recommended or even necessary? ...

XNA Text Drawing from a DLL

I am planning on building a 2D game library for XNA, and one of the components I want to include is a simple text drawer for debug purposes. Now, to draw text with SpriteBatch you need a .spritefont file, which is an xml format file, and these seem to need to compile into a separate folder. I would prefer not to have to copy that around ...

XNA Content Pipeline Tutorial

I want to use the content pipeline for building objects in my level, and I tried to use the microsoft tutorial for writing a content importer and all the rest, but IIRC it didnt work. Anyone know where a decent tutorial or two is? ...

How To Draw a Model in XNA with the BasicEffect

I want to draw a Model in XNA. I've gona ahead and produced it in Blender and Exported it to fbx File Format so the Content Pipeline can work with it. What code should I add to the Draw() method of my WindowsGame() ? I've tried the Following but All I get is a gray screen (Gray not Blue, which is the clear color, mind you) The Model is I...

XNA Width and Height to Vector2

I use XNA, and one of the things i do a lot is pass around data as Vector2s. Now, a lot of the objects in XNA (such as a graphics device and such), inste3ad of containing a Vector2 that tells you the size of the viewport, they offer separate Width and Height methods. Is there some way to add a Vector2 property to them so i can get that d...

XNA Graphics Device Extension

I have a class that derives from XNA's GraphicsDevice, and i want to use it in my game. However, i can't quite figure out what i'm supposed to do to make this new graphics device replace the old one. Any suggestions? ...

XML XNA Object Deserialization

I'm building a game in XNA 3 and I have the levels stored in XML format. What solution would you recommend for deserializing those XML files into level objects? it needs to be able to work on the Xbox. ...

FileNotFound exception when attempting to run an XNA F# project

I managed to cobble together a suitable implementation of a sample game in F# with xna. However when i try to instantiate my derived game class, the code throws a FileNotFound exception trying to access the Microsoft.Xna.Framework assembly. Why does this happen? Code: #light open System open Microsoft.Xna.Framework open Microsoft.Xna.F...

Render multiple images to a bitmap in C# Winforms

I'm developing a set of applications for use creating games in XNA. Using Graphics.drawImage I can easily draw a preview image from an XNA texture2D object. Each object, eg Character, Map etc, is made up of a List of parts, each part storing information such as position rotation and texture source. The next step is to render a preview o...

Projecting a sphere onto a cube

I'm currently working on building a game which is on a planet, the way in which I'm planning to store the data is in 6 2dimensional arrays, which are heightmaps around the sphere (on the faces of a cube). The problem I have is this, given a normalised vector which points outwards from the centre of the sphere how can I determine these tw...

Serializing a DrawableGameComponent as XML using XNA's ContentTypeWriter class

I'm writing a small 2D shooter game in XNA, and I've decided that, so that one could implement custom made content in the game, it loads definitions of the game objects from XML files. When I found out that XNA has an easy to use XML serializer, it made it extra easy. The problem is, my objects that I want to serialize are DrawableGameCo...

Generic Way to Track a Variable

I have a camera class and i want it to be able to track a physics object. However in my game engine (which is what the camera class will be part of), you can use different physics engines (even some i did not develop). How can i make my camera capable of tracking an object regardless of the physics engine i am using? if it helps, i will ...