Projectile collision within arraylists Hello everyone I am currently writing a game in xna and I am having some problems detecting collision between vector2's within an arraylist. Here is the code I am using thanks in advance for helping me out. for (ii = 0;ii < projectiles2.Count; ii++) { currentsprite2 = (spritestruct)projectiles2[ii]; currentsprite2.position.X += +((float)Math.Sin(currentsprite2.rotation)) * 4; currentsprite2.position.Y += -((float)Math.Cos(currentsprite2.rotation)) * 4; projectiles2[ii] = currentsprite2; // detect if two bullets collide...... this is the part that is giving me troubles.. currently does not work for (int a = 0; a <= i; a++) { projectiles[ a ] = currentsprite; if (currentsprite2.bulletbb.Intersects(currentsprite.bulletbb)) { projectiles2.Remove(currentsprite2); projectiles.Remove(currentsprite); } } } Tag: Semi transparencey
Joypad problems If you don't have the latest DirectX SDK you might want to download it and take a look at the DirectInput samples. They'll show you exactly what you need to do to get it running in your game. There's also a ton of resources available on the various game dev sites (you might start at GameDev.net). Tag: Semi transparencey
Error when getting started im trying to launch the starter kit and i keep getting this error
what do i need to do to get the games to deploy and run on the 360, so i can start learning this Tag: Semi transparencey
GC Related Crash? Running into a really odd bug here. It seems that some parts of the XNA framework stop working right after a GC collection. I've found two cases:
Instances of ShaderConstant break after a collection on PC. By break, I mean that the first SetValue following a collection throws an AccesViolationException. I've thrown a simple repro case at the bottom of this post that calls GC.Collect, but note that the same thing happens if you allocate objects each frame and leave them around for the GC to collect at some point (it just takes a while).
On the XBOX I get a different crash: I get an InternalDriverException (or whatever it's called - typing from memory here) on the first DrawUserIndexedPrimitives call following a collection (I believe I used to see a similar bug in VertexBuffer.SetData before I switched to user primitives).
This doesn't really seem like a bug that should have gotten past QA (I honestly can't see all of XNA history up until now go by without a single garbage collection), so I'm guessing I did something wrong when I installed/downloaded the launcher onto my XBOX - can anyone give me a hint
Thanks,
Phill
#region Using Statements
using System;
using System . Collections . Generic;
using Microsoft . Xna . Framework;
using Microsoft . Xna . Framework . Audio;
using Microsoft . Xna . Framework . Content;
using Microsoft . Xna . Framework . Graphics;
using Microsoft . Xna . Framework . Input;
using Microsoft . Xna . Framework . Storage;
#endregion
namespace GCCrashTest
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft . Xna . Framework . Game
{
GraphicsDeviceManager graphics;
ContentManager content;
public Game1()
{
graphics = new GraphicsDeviceManager ( this );
content = new ContentManager ( Services );
}
string testShader = "float4 val; float4 main() : COLOR0 { return val; }" ;
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base . Initialize();
}
private PixelShader psh;
private ShaderConstant psh_val;
/// <summary>
/// Load your graphics content. If loadAllContent is true, you should
/// load content from both ResourceManagementMode pools. Otherwise, just
/// load ResourceManagementMode.Manual content.
/// </summary>
/// <param name="loadAllContent"> Which type of content to load. </param>
protected override void LoadGraphicsContent( bool loadAllContent )
{
if ( loadAllContent )
{
CompiledShader comp_sh = ShaderCompiler . CompileFromSource( testShader, null , null , CompilerOptions . None, "main" , ShaderProfile . PS_2_0, TargetPlatform . Windows );
psh = new PixelShader ( graphics . GraphicsDevice, comp_sh . GetShaderCode() );
ShaderConstantTable table = new ShaderConstantTable ( comp_sh . GetShaderCode() );
psh_val = table . Constants[ "val" ];
}
// TODO: Load any ResourceManagementMode.Manual content
}
/// <summary>
/// Unload your graphics content. If unloadAllContent is true, you should
/// unload content from both ResourceManagementMode pools. Otherwise, just
/// unload ResourceManagementMode.Manual content. Manual content will get
/// Disposed by the GraphicsDevice during a Reset.
/// </summary>
/// <param name="unloadAllContent"> Which type of content to unload. </param>
protected override void UnloadGraphicsContent( bool unloadAllContent )
{
if ( unloadAllContent == true )
{
content . Unload();
}
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input and playing audio.
/// </summary>
/// <param name="gameTime"> Provides a snapshot of timing values. </param>
protected override void Update( GameTime gameTime )
{
GC . Collect(); //comment this out and it works
// Allows the default game to exit on Xbox 360 and Windows
if ( GamePad . GetState( PlayerIndex . One ) . Buttons . Back == ButtonState . Pressed )
this . Exit();
// TODO: Add your update logic here
base . Update( gameTime );
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime"> Provides a snapshot of timing values. </param>
protected override void Draw( GameTime gameTime )
{
graphics . GraphicsDevice . Clear( Color . CornflowerBlue );
graphics . GraphicsDevice . PixelShader = psh;
psh_val . SetValue( graphics . GraphicsDevice, new Vector4 ( 0 , 0 , 0 , 0 ) );
// TODO: Add your drawing code here
base . Draw( gameTime );
}
}
} Tag: Semi transparencey
missing Direct3D device??? JeffTxxx123 wrote:
The next obvious question: Is there a list of approved cards that support this functionality A list of cards that will NOT support this
Wikipedia knows everything. Tag: Semi transparencey
Texturing problem Have you checked the values of your texture coordinates Is it possible
these are all zero, or perhaps too large (anything much greater than
1.0 is probably an error). Tag: Semi transparencey
How to apply an effect to a mesh rendering? Lostlogic wrote:
//This is where the mesh orientation is set, as well as our camera and projection foreach (BasicEffect effect in mesh.Effects) {
I think I understand the issue... Simply change it from foreach( BasicEffect effect... ) to foreach( Effect effect ... ). If you know all effects are of the same type (like MyCustomEffect, if you wrote your own wrapper), then you can use that type instead. For my test projects, where I may have a mix of effect types on each model, I often use something like this:
foreach( Effect effect in mesh.Effects ) { if( effect is BasicEffect ) { ...basic effect stuff... } else if( effect is MyCustomEffect ) { ....my custom stuff... } }
Hope that helps! Tag: Semi transparencey
3D picking with the mouse combined with a moving camera... You'll need to set the World Matrix to something else. Right now, I think you're just detected when the camera is centered at 0,0,0. From the MSDN article:
Using Viewport.Unproject determine points in world space on the near and far clip plane. For the point on the near plane pass a source vector with x and y set to the mouse position and z set to 0. For the point on the far plane pass a source vector with x and y set to the mouse position and z set to 1. For both points pass Unproject the current projection matrix and view matrix and a translation matrix for the point (0,0,0).
I can't be sure, because i haven't actually tried it. I swear there used to be a different method to do this on the article. I wonder what happened to it; I know that method worked. Tag: Semi transparencey
Driving Game Download??? Possibly. There's been nothing official at this time. And the 360 has nothing to do with it since you use your PC to write the games. You won't be downloading starter kits on your 360, you'll be downloading them from the internet to your PC. Tag: Semi transparencey
Subscription not available on my Xbox! Hmmm, you're in Live Marketplace | Games | All Game Downloads XNA Creator's Club is on my list. The XNA Game Launcher is what's used to deploy games from your PC to your 360, it's not the Creator's Club. Maybe an MS person will chime in here. Tag: Semi transparencey
Generating Grid With Loops Nope. I wanted to leave Y 0 so I can have a plane grid. I am in 3D space for the grid. The variables represent a few things. size is simply the number of lines to draw in each direction from the origin. That is why I have to double it (one for each side of the axis) and square it (because I have both the X and Z axis to use). The numVerts is simply this value. I have the numVertsRoot which is the number of vertices in each row/column of the grid. I then try to go through and place all the vertices in the proper places on the plane. Hope that helps somebody help me. Tag: Semi transparencey
Global lighting This might seem silly but here goes..
is there a way to set the default lighting for all objects
This is what im doing now..(taken after spacewars)
Matrix m_view = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
Matrix m_proj = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 20000.0f);
for (int i = 1; i < MAX_MODELS; i++)
{
foreach (ModelMesh mesh in Enemy .C_Model_m.Meshes)
{
//This is where the mesh orientation is set, as well as our camera and
projection
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
//effect.LightingEnabled = false;
effect.World = Enemy .C_Actor_m;
effect.View = m_view;
effect.Projection = m_proj;
}
//Draw the mesh, will use the effects set above.
mesh.Draw();
}
}
When i do this my Frame rate takes a big hit... I narrowed the problem
down to the line of code effect.EnableDefaultLighting();....... Its not
so much the lighting, because if i shut the lighting off after this
call i still get a crazy slow FPS. Is there anyway i can
just EnableDefault lighting through out my game... so its not enableing
it for every effect in every mesh of every model
Thanks,
-Wes Tag: Semi transparencey
Collision He said he was using spheres... anyways since no one has answered maybe
I can point you in the right direction. Pretty much when an
Intersect() between the 2 objects happens you take the speed and angle
of each and do stuff with them. If a ball hits a wall on the pool
table head on its going to lose a bit of speed and reverse
direction. If it hits at an angle its going to bounce off in the
other direction and lose a little bit of speed. You just do some
math on the X and Y to achieve this effect. Maybe if you draw it
out on paper or go play a game of pool you can visualize how the X and
Y's change when things hit other things. If you are allowing for
english in your pool game then when a ball hits another ball (cue ball
on target ball), you would stop the cue ball and send the target ball
in the same direction as the cue ball (if the cue ball hits to the side
of the other ball then angle it some) and if the cue ball had no
english stop the cue ball. If you put top spin on the cue ball,
make the cue ball keep rolling and so on. I know this isn't going
to help programmatically, but if you think of the pool table as an X,Y
plane then you can visualize these things happening. Hope I
helped!
EDIT: Posted this before seeing Matt's last message. :-/ Tag: Semi transparencey
click and move Just poll the mouse state and position your graphic to the current mouse position when the mouse button is pressed:
http://msdn2.microsoft.com/en-us/library/bb197572.aspx Tag: Semi transparencey
Alpha Blending (deferred)? Here is an example of what I want to pull off. Note that the green box absorbs the color from the red frame, but not from the blue frame that contains the green box. It's a parent/child relationship. Where the green box is a child of the blue frame, so it ignores the blended color of its parent since they should be rendered as a single entity.
http://img235.imageshack.us/img235/5136/alphaexamplemc5.png Tag: Semi transparencey
My Graphic card stuck got a graphic card of Nvidia Geforce MX400.
Now it says my driver file is very and require to update, but i am unable to update.
Can anybody help me in this Tag: Semi transparencey
Managed DirectX Many graphics cards have control panels that let you override application behavior, and always turn off vblank. You can also set the presentation interval to "Default" when creating the device (as opposed to One). However, I've seen devices where "Default" still means vblank, so the control panel is your best bet. Tag: Semi transparencey
Terrain & Terrain-Physics (intersection, dynamic slicing) Thanks very much, over the last days i build out my own version based on your, it boosts dramaticly up the rendering, i can render huge terrain course of the great vertex cache and also render small parts at very high frame rate, brilliant work While reading & writing i found some very small things that could be fixed up: ->Quadtree --->Create() Can never be reached, was just assigned above to the same value, so it can't be larger. if (height > heightData.GetLength(0)) m_valid = false; if (width > heightData.GetLength(1)) m_valid = false; ->Quadtreenode --->Buildout() Both situations can't be reached, if the first is valid the second is impossible. if (data > m_maxHeight) m_maxHeight = data; if (data < m_minHeight) m_minHeight = data; ->Quadtree --->Create() Unused variable. SurfaceFormat fmt = heightMap.Format; Just wanted to mention when i already spend so much time on it Tag: Semi transparencey
Gamekit developming I think Lotierm is looking for something like "Shooter Zero"
http://gameylittlehacker.blogspot.com/2007/01/shooter-zero-data-driven-sample.html
Where everything is data driven, and someone can toss an editor on top of the xml data, and voila, a complete new game. Tag: Semi transparencey
texture moving on a vertext shader Hello
Noobie question here for you. I'm copying the example from the help files in GSE (the example titled: How to create custom texture effects), and have managed to successfully port the cube into my game world (which is a hacked version of the top-down spaceship example that is right at the begining of the help files).
I have changed the spaceship example to always keep the spaceship in the middle of the screen, so I can fly around asteroids that I have put into the game, and I've also managed to set a boundary to stop the spaceship flying off in one direction for ever.
Now I want to adapt the custom texture effects code to stay in one place while my spaceship flies around it. I did this by updating the custom texture effect "world-view-projection" data with the view of the spaceship during the draw() function.
This makes the cube stay in one place, but the texture on the cube moves with the spaceship. What I think is happening is that the tex2D part of the code is using the spaceship view to position the texture on the cube. So when the spaceship moves the texture moves around on the cube.
Any idea how I can edit the custom texture "fx" file to seperate cube coords from texture coords
Many thanks, SuperArmySoldier
Here is the ReallySimpleTexture.fx code... uniform extern float4x4 WorldViewProj : WORLDVIEWPROJECTION;
uniform extern texture UserTexture;
struct VS_OUTPUT
{
float4 position : POSITION;
float4 textureCoordinate : TEXCOORD0;
};
sampler textureSampler = sampler_state
{
Texture = <UserTexture>;
mipfilter = LINEAR;
};
VS_OUTPUT Transform(
float4 Position : POSITION,
float4 TextureCoordinate : TEXCOORD0 )
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.position = mul(Position, WorldViewProj);
Out.textureCoordinate = TextureCoordinate;
return Out;
}
float4 ApplyTexture(VS_OUTPUT vsout) : COLOR
{
return tex2D(textureSampler, vsout.textureCoordinate).rgba;
}
technique TransformAndTexture
{
pass P0
{
vertexShader = compile vs_2_0 Transform();
pixelShader = compile ps_2_0 ApplyTexture();
}
} Tag: Semi transparencey
Pixel Shader 1.1 You can run with the reference rasteriser today if you want, but the framerate will be way too slow for this to be useful (typically only one or two frames a second). XNA is fundamentally built on shader technology. I'm sorry if that's not a good answer for you, but that's just the way it is. This is extremely unlikely ever to change. Tag: Semi transparencey
Textured Quad Does the debug DirectX runtime have anything useful to say about this
http://blogs.msdn.com/shawnhar/archive/2007/01/31/debugging-xna-graphics-problems.aspx Tag: Semi transparencey
getting started thanks for the advise. but im still a little confused. how dose directx sdk work with visual studio c# do u develope the games in visual c# studio or do you use directx sdk
im just wondering what all i need to download
thanks Tag: Semi transparencey
Why does my displayed mesh dim when rotating on an LCD TV? Doesn't matter what resolution I choose -- have tried 800x600, 1024x768 and 1360x768, windowed and full-screen. My TV supports all of these, it's in the specs. Can't be the brightness of a single-pixel line -- I'ev set up the mesh to rotate left or right if I hold down the arrow keys. Whenever rotating, it's dim -- as soon as I stop it's back to normal brightness. The mesh is identical rotating or not so it's nothing to do with line thickness. If it were some kind of scaling artifact, that shouldn't happen. I still suspect it's something to do with the reaction time of a single pixel for an LCD --- IE how long it takes a pixel to light up ... Has anyone else seen this I suspect it will probably apply for ANY fast moving objects on a 3d screen ... Strangely, i have never noticed it in any of my games ... Gothic 3, Civ4, they all look fine ... can it be something specific to XNA Tag: Semi transparencey
Need info about .X files I am searching for more info about .x files I mean not those mesh (model) files but files which can be created with help of templates
template my_struct
{
<xxxxxx-xxxx-xxx-xxxxxxxxxx>
STRING some_str;
}
For me most intresting thing is f.e can I use data types like bool int float or maybe even class data types
I gues I could findout this if have some articles to read. Now I have only one book which talks about it but unfortunately I assume that threre is much more about X files then just in that book.
I tryed google but no useful links.
SDK mhhh only methods/interfaces/structures etc. again not what i want :(
Does anyone know some tutorials/articles about it
Tag: Semi transparencey
Content Pipeline check out this post http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1048537&SiteID=1 it might help, you will need something like this if you are going to be using ContentManager and loading dynamic content. Tag: Semi transparencey
RenderTarget2D rendered with garbage all over it And as if I haven't been annoying enough yet, here's a good screenie from the laptop: http://skasoftware.com/pics/zcorrect.jpg Tag: Semi transparencey
GeoffNin
Does anyone know why my models turn semi transparent when I use the SpriteBatch.Begin