Questions tagged [xna-4.0]

XNA Game Studio 4.0 is a programming environment that allows you to use Visual Studio to create games for Windows Phone, the Xbox 360 console, and Windows-based computers.

Filter by
Sorted by
Tagged with
58 votes
3 answers
16k views

Optimizing an XNA 2D game

Does it make sense to implement the logic to skip rendering objects outside the viewport or should I not care about it and let the Framework do it?
smnbss's user avatar
  • 701
46 votes
8 answers
54k views

How'd they do it: Millions of tiles in Terraria

I've been working up a game engine similar to Terraria, mostly as a challenge, and while I've figured out most of it, I can't really seem to wrap my head around how they handle the millions of ...
William's user avatar
  • 2,724
21 votes
2 answers
17k views

How do I disable texture filtering for sprite scaling in XNA 4.0?

I have a sprite that I'm trying to scale up in XNA, but XNA is applying some sort of texture filtering that smooths it and makes it look ugly. I'd like it to just do pixel doubling instead of ...
Daniel T.'s user avatar
  • 537
5 votes
3 answers
5k views

Alpha blending not rendering properly XNA 4.0

I'm trying to render a tree made out of 2 rectangles intersecting in the center at a 90degree angle. The texture has an alpha channel but which ever rectangle gets rendered second causes a weird ...
fizzlesticks's user avatar
10 votes
5 answers
3k views

How can I simulate shattering glass?

I need to make a simulation with stone thrown through a glass window. How can I accomplish that? I mean, I was thinking about making a 3D model of a stone and glass in 3D Studio Max 2012, shatter the ...
toomek308's user avatar
  • 111
4 votes
2 answers
6k views

Loading and unloading "chunks" of tiles in a 2d tile engine with 2d camera

I am making a 2d tile based game in C# and XNA 4.0. I am having trouble loading and unloading "chunks" of tiles(blocks). The whole world is randomly generated and is infinate on both axis. How would I ...
ceriosNerd's user avatar
13 votes
1 answer
4k views

Disposing only certain resources in XNA?

The ContentManager in XNA 4.0 only has one Unload() method that Unloads all Assets. I want to have some "global" Assets that are always loaded, but then I want per-Level Assets which should ...
Michael Stum's user avatar
  • 2,543
12 votes
5 answers
10k views

45° Slopes in a Tile based 2D platformer

I want to have simple 45° slopes in my tile based platformer, however I just cant seem to get the algorithm down. Please take a look at the code and video, maybe I'm missing the obvious? ...
xNidhogg's user avatar
  • 135
7 votes
1 answer
4k views

Sidescroller variable terrain heightmap for walking/collision

I've been fooling around with moving on sloped tiles in XNA and it is semi-working but not completely satisfactory. I also have been thinking that having sets of predetermined slopes might not give me ...
JiminyCricket's user avatar
6 votes
1 answer
8k views

Friction in 2D game

I'm developing a 2D platformer, although this question could probably apply to just about any 2D type physics; What is the equation for friction? I have sort of a hacky type of friction set up in my ...
TheBroodian's user avatar
4 votes
1 answer
3k views

XNA Platformer Sample: Supporting multiple resolutions?

I have been looking at the XNA Platformer Sample and noticed that, when you change the resolution, the game world still renders at 800x480 and not the new width and height of the display. Can anyone ...
Jonathan Ogle-Barrington's user avatar
4 votes
2 answers
3k views

Depth buffer and render target

When I use this RenderTarget: ...
Vodáček's user avatar
  • 852
15 votes
2 answers
4k views

Creating an electricity/lighting/tesla coil effect in a 2D XNA game?

I'd like to create beams of electricity between two points very similar to this video: http://www.youtube.com/watch?v=eMJ8-56L3Lc. The effect is so dynamic, with varying lengths and pseudo-random ...
Christopher Horenstein's user avatar
8 votes
1 answer
4k views

How can I draw a perspective-correct quad?

I'm trying to draw a quad in 2D (in SharpDX, but that is basically XNA). But texture correction is not working, and I'm getting only an affine textured quad. I'm using ...
SmartK8's user avatar
  • 614
8 votes
1 answer
1k views

How To Approach 360 Degree Snake

I've recently gotten into XNA and must say I love it. As sort of a hello world game I decided to create the classic game "Snake". The 90 degree version was very simple and easy to implement. But as I ...
Austin Brunkhorst's user avatar
7 votes
2 answers
11k views

How do I enable higher FPS in XNA 4.0?

I created a FpsCounter DrawableGameComponent (linked to code, it's longish). It works great: It displays 60.0 fps normally. If I ...
Matthew Scharley's user avatar
3 votes
2 answers
2k views

Using 2D sprites and 3D models together

I have gone through a few posts that talks about changing the GraphicsDevice.BlendState and GraphicsDevice.DepthStencilState (SpriteBatch & Render states). . however even after changing the states ...
Sweta Dwivedi's user avatar
0 votes
2 answers
2k views

XNA change a specific color of a model to another

Is it possible to change a specific color of a model to another? Example: Everything that's blue should be red or something like that. And is it possible to do this without the use of effects? I ...
user1990950's user avatar
16 votes
2 answers
27k views

Error on new XNA 4.0 game project - No suitable graphics card found

Any ideas on how to fix this? According to what I remember about XNA 3 was that when running the application from scratch, I would get a blue colored windows with nothing rendered. Any suggestions? ...
user avatar
14 votes
1 answer
4k views

How do you add equipment to a 3D character model using XNA/Blender?

I've watched quite a few Blender tutorials, but I have yet to see examples of how to swap out sub-models. So my question is, how do you swap out equipment on a character model? Specifically I’d like ...
JoshNaro's user avatar
  • 243
14 votes
1 answer
5k views

How can I create gradiented Fog of War?

I'm creating a top down 2D RTS game for educational purposes. Currently, I'm really just copying Starcraft's design/ideas. I've decided I should probably implement Fog Of War too. My expectations: ...
Freesnöw's user avatar
  • 787
14 votes
1 answer
3k views

How do I prevent XNA from pausing Updates while the window is being resized/moved?

XNA stops calling Update and Draw while the game window is being resized or moved. Why? Is there a way to prevent this ...
Andrew Russell's user avatar
8 votes
3 answers
2k views

How do I make a moving object stop smoothly at the end of a path?

There are a dozen ways I could word this question, but to keep my thoughts in line, I'm phrasing it in line with my problem at hand. So I'm creating a floating platform that I would like to be able ...
TheBroodian's user avatar
7 votes
5 answers
4k views

2D Procedural Terrain Generation - Guaranteeing connectedness?

I'm working on a 2D platformer in XNA. One of things I'd like to be a main design characteristic is procedural content generation. The first step of that is to procedurally generate the terrain. So, I'...
SpaDusA's user avatar
  • 73
7 votes
4 answers
2k views

How do I target a tank turret with an offset barrel?

I have a tank model consisting of multiple parts, a body, a turret and the barrel of the gun. The turret is offset from the body origin and can rotate around the Y axis(up). The barrel is connected to ...
Jkh2's user avatar
  • 574
7 votes
3 answers
6k views

A cool way of doing Z-index for XNA components?

I am trying to render some elements in my game. First, I render the textures (the textures of the textboxes themselves etc). Then I render the primitives (borders around controls etc). Then I render ...
Mathias Lykkegaard Lorenzen's user avatar
7 votes
1 answer
5k views

Resolution Independent 2D Rendering in XNA

I am trying to figure out the best way to render a 2d game at any resolution. I am currently rendering the game at 1920x1200. I am trying scale the game to any user selected resolution without ...
AttackingHobo's user avatar
7 votes
1 answer
717 views

2D Magnet-like repelling behavior

If somebody wanted to develop a system between two intersecting rectangles so that the rectangles would, in a gradual process, push eachother away from one another until no longer intersecting, with ...
TheBroodian's user avatar
7 votes
2 answers
4k views

The true cost to get my XNA game on XBox?

There seem to be many hurdles to get ones game onto Xbox, so far I have uncovered: You need Visual Studio (once your game becomes commercial you cannot use Express - but have to pay for professional)....
markmnl's user avatar
  • 619
6 votes
2 answers
622 views

How does one specify raster operations in XNA?

I'm looking for a way to add a sprite using a particular logic operation (like XOR). I can't find anything on Google and I'm not sure where to look in the documentation. I've looked into ...
Corey Ogburn's user avatar
  • 1,135
6 votes
3 answers
3k views

'Spring' physics

I'm trying to put together a struct or a method of some sort that will allow me to check the relative position between two objects, and if they're too far apart, apply a force that will draw them ...
TheBroodian's user avatar
5 votes
1 answer
650 views

How to attach two XNA models together?

I go back on unsolved question I asked about attaching two models together, could you give me some help on this ? For example, If I want to attach together Model1 (= Main model) & Model2 ? I ...
jeangil's user avatar
  • 81
5 votes
1 answer
544 views

How can I remove Magic Pink from an image at runtime using GraphicsDevice?

In XNA 4.0, I want to load all my textures at runtime, which means I will not be able to take advantage of the content processor. (This is fine because it would allow people to change graphics and ...
Kyle Baran's user avatar
5 votes
2 answers
5k views

Drawing a texture line between two vectors in XNA WP7

I want to create a simple graph maker in WP7. The goal is to draw a texture line between two vectors what the user defines with touch. I already made the rotation, and it is working, but not ...
Krav's user avatar
  • 71
5 votes
2 answers
5k views

Is there a simpler way to create a borderless window with XNA 4.0?

When looking into making my XNA game's window border-less, I found no properties or methods under Game.Window that would provide this, but I did find a window ...
Cypher's user avatar
  • 1,326
4 votes
1 answer
6k views

Adding SpriteFont in Monogame

My question is probably something you guys have heard before - "How do you add SpriteFont's in Monogame's content manager?" The simple answer to this is, right click the 'Content' folder, go on 'Add ...
JimmyK's user avatar
  • 153
4 votes
2 answers
499 views

Does XNA support 1 dimensional textures

Does XNA support 1 dimensional textures. And by 1 dimension texture I mean something like Texture1d not a Texture2d where one dimension is 1 (because of the 4096 limit)
Mr Bell's user avatar
  • 405
4 votes
1 answer
298 views

Creating rectangles from the inner part of a texture2D

This may be hard to understand, but I'll do my best. You will see that the first image is a normal Mario, and the other is the result I am looking for. I'm trying to find a way to extract rectangles ...
RustyGearGames's user avatar
4 votes
1 answer
155 views

Why does CameraZ=0 result in no render?

I am trying to draw simple model, but I am experiencing strange error. When I use this View matrix: ...
Vodáček's user avatar
  • 852
4 votes
2 answers
6k views

Flip sprite vertically AND horizontally?

In Microsoft.Xna.Framework.Graphics.SpriteEffects there is the possibility to flip a texture horizontally or vertically before rendering. But can one do both at the ...
ares_games's user avatar
3 votes
2 answers
3k views

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 ...
roxrook's user avatar
  • 321
3 votes
2 answers
9k views

Weird behavior with XNA SpriteBatch.Draw origin

I have a texture with 256x256 pixels. Consider this piece of code: ...
luiscubal's user avatar
  • 484
3 votes
2 answers
1k views

Applying Angular Acceleration in a Basic Physics Model

I'm attempting to use a basic physics system to create an arcade flight model. So far I have managed to get the aircraft moving forward, apply gravity, etc. However, after trying to implement torque I ...
Stephen Locke's user avatar
3 votes
1 answer
450 views

How to access the nth element in a 2d texture from a pixel shader in XNA

How can I access the nth element in a texture2d from a pixel shader? For example if I wanted to get the 5th vector4 from 10 x 10 texture2d
Mr Bell's user avatar
  • 405
3 votes
1 answer
2k views

XNA mouse position in windows forms

I am using this code in Update method in XNA RenderControl in Windows Forms: ... Mouse.WindowHandle = renderControl1.Handle; MouseState stat=Mouse.GetState(); ... ...
Vodáček's user avatar
  • 852
3 votes
2 answers
823 views

Cutting out smaller rectangles from a larger rectangle

The world is initially a rectangle. The player can move on the world border and then "cut" the world via orthogonal paths (not oblique). When the player reaches the border again I have a list of path ...
Mauro Destro's user avatar
2 votes
2 answers
2k views

What's efficient way to draw a lot of textured cubes in XNA4?

Title says it all. What's efficient way to draw a lot of textured cubes in XNA4?
jM2.me's user avatar
  • 137
2 votes
3 answers
4k views

Depth Buffer not working in XNA?

I'm stumped. I have been fighting this for about 2 hours now. Here are the interesting parts of my code: ...
John Gietzen's user avatar
2 votes
1 answer
1k views

XNA GUI: Creating a 'scroll pane' widget

I'm trying to create a simple GUI system and am currently stuck on how to implement a textarea with a scrollbar. In other words, the text is too large to fit into the view area. I want to learn how to ...
Keith Myers's user avatar
2 votes
1 answer
1k views

Combine 3D objects in XNA 4

Currently I am writing on my thesis for university, the theme I am working on is 3D Visualization of hierarchical structures using cone trees. I want to do is to draw a cone and arrange a number of ...
Christoph's user avatar
  • 173