• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=Dj-J3;31095599]That's because it is the same :v: I'm borrowing it until i start focusing on the visuals. [/QUOTE] Glad that I could help :v:
[QUOTE=Chris220;31095389]Because if you did that to every function (and the compiler didn't override your choice to do so), you'd fill up your executable with tons and tons of redundant code from massive functions and stuff. Basically your exe would be much, much larger than it would be without. You should only inline the smallest of functions really.[/QUOTE] ...Not to even mention that in a lot of cases the compiler inlines a function when the benefit of inlining is determined to be large enough. Usually you should still mark them inline just in case.
[QUOTE=frankie penis;31087206]i'm looking to get into c# programming and eventually making games in XNA. i've scoured google all over but i can't find any good tutorials. i'm using visual c# 2010 if that helps.[/QUOTE] sorry to repost but i don't think anyone saw it cause it was the last post of the page :v:
How is "C++ Primer Plus Fifth Edition" for learning C++?
Hi, my sprite class has a 2D vector like this: std::vector < std::vector <Vector3*> > coll_box; I don't know how can I properly delete the objects that those pointers point to, and then clear the vector so it is empty. Should I go trough the vector elements and delete them, and then call vector::clear ? Is that the right approach? I am still new with this.
How do bullet hell games manage their collisions and bullets? I have this: [img]http://img268.imageshack.us/img268/3368/unledat.png[/img] Which is already starting to lag at times and that is without any collision checking or anything, just drawing the object and updating it.
[QUOTE=Richy19;31107468]How do bullet hell games manage their collisions and bullets? I have this: [img]http://img268.imageshack.us/img268/3368/unledat.png[/img] Which is already starting to lag at times and that is without any collision checking or anything, just drawing the object and updating it.[/QUOTE] I don't know if this is how it's done, but you can use something like a quadtree or spatial hashing to restrict the number of collisions being checked per frame (i.e, bullets out of range are not even considered in the collision checking, which can greatly save on speed).
But he already has problems even without collision checking.
Oops, I misread the post. Well, how much logic are you doing per bullet? Can any of it be inlined? It definitely shouldn't be slow with that few bullets unless you have a rather weak computer. Edit: Also, are you in debug or release mode? Debug mode has extra bounds checking on arrays and stuff so it can be a hell of a lot slower than release mode.
Well its not really a problem atm, just a small lag spike every now and then. But once i have some enemies and some collisions going it will be
Anyone with some XNA 3d knowledge mind giving me a hand? Im trying to draw a grid along the 3 axis's but all it draws is: [img]http://img268.imageshack.us/img268/3871/unledanj.png[/img] this is my 3d code: [csharp] Matrix worldMatrix; Matrix viewMatrix; Matrix projectionMatrix; BasicEffect basicEffect; VertexDeclaration vertexDeclaration; VertexPositionColor[] pointListX; VertexPositionColor[] pointListY; VertexPositionColor[] pointListZ; VertexBuffer vertexBuffer; int points = 2601; short[] lineListIndices; void init3Dstuff() { pointListX = new VertexPositionColor[points]; pointListY = new VertexPositionColor[points]; pointListZ = new VertexPositionColor[points]; for (int x = 0; x < 51; x++) { for (int y = 0; y < 51; y++) { pointListX[x + y] = new VertexPositionColor( new Vector3(0, x*5, y*5), Color.White); } } for (int x = 0; x < 51; x++) { for (int y = 0; y < 51; y++) { pointListY[x + y] = new VertexPositionColor( new Vector3(x * 5, 0, y * 5), Color.White); } } for (int x = 0; x < 51; x++) { for (int y = 0; y < 51; y++) { pointListZ[x + y] = new VertexPositionColor( new Vector3(x * 5, y * 5,0), Color.White); } } viewMatrix = Matrix.CreateLookAt( new Vector3(500.0f, 500.0f, 500.0f), Vector3.Zero, Vector3.Up ); projectionMatrix = Matrix.CreateOrthographicOffCenter( 0, (float)GraphicsDevice.Viewport.Width, (float)GraphicsDevice.Viewport.Height, 0, 1.0f, 1000.0f); // Initialize an array of indices of type short. lineListIndices = new short[(points * 2) - 2]; // Populate the array with references to indices in the vertex buffer for (int i = 0; i < points - 1; i++) { lineListIndices[i * 2] = (short)(i); lineListIndices[(i * 2) + 1] = (short)(i + 1); } vertexDeclaration = new VertexDeclaration(new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0) } ); basicEffect = new BasicEffect(GraphicsDevice); basicEffect.VertexColorEnabled = true; worldMatrix = Matrix.CreateTranslation(renderArea.Width / 2f - 150, renderArea.Height / 2f - 50, 0); basicEffect.World = worldMatrix; basicEffect.View = viewMatrix; basicEffect.Projection = projectionMatrix; } void draw3D() { foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.LineList, pointListX, 0, // vertex buffer offset to add to each element of the index buffer 51, // number of vertices in pointList lineListIndices, // the index buffer 0, // first index element to read 50 // number of primitives to draw ); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.LineList, pointListY, 0, // vertex buffer offset to add to each element of the index buffer 51, // number of vertices in pointList lineListIndices, // the index buffer 0, // first index element to read 50 // number of primitives to draw ); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.LineList, pointListZ, 0, // vertex buffer offset to add to each element of the index buffer 51, // number of vertices in pointList lineListIndices, // the index buffer 0, // first index element to read 50 // number of primitives to draw ); } } [/csharp]
cornflower blue
How would I multithread a recursive function with C++ using boost.thread ? Because it's recursive it's not possible to know how much work one thread should do. If I split the work into multiple parts for the first calls then some threads could finish faster than others when they complete and the program could wait for 1 thread to do massive work when all others have terminated. Is there a more efficient way?
[QUOTE=Richy19;31109976]Anyone with some XNA 3d knowledge mind giving me a hand? Im trying to draw a grid along the 3 axis's but all it draws is: [img]http://img268.imageshack.us/img268/3871/unledanj.png[/img] this is my 3d code: [csharp] Matrix worldMatrix; Matrix viewMatrix; Matrix projectionMatrix; BasicEffect basicEffect; VertexDeclaration vertexDeclaration; VertexPositionColor[] pointListX; VertexPositionColor[] pointListY; VertexPositionColor[] pointListZ; VertexBuffer vertexBuffer; int points = 2601; short[] lineListIndices; void init3Dstuff() { pointListX = new VertexPositionColor[points]; pointListY = new VertexPositionColor[points]; pointListZ = new VertexPositionColor[points]; for (int x = 0; x < 51; x++) { for (int y = 0; y < 51; y++) { pointListX[x + y] = new VertexPositionColor( new Vector3(0, x*5, y*5), Color.White); } } for (int x = 0; x < 51; x++) { for (int y = 0; y < 51; y++) { pointListY[x + y] = new VertexPositionColor( new Vector3(x * 5, 0, y * 5), Color.White); } } for (int x = 0; x < 51; x++) { for (int y = 0; y < 51; y++) { pointListZ[x + y] = new VertexPositionColor( new Vector3(x * 5, y * 5,0), Color.White); } } viewMatrix = Matrix.CreateLookAt( new Vector3(500.0f, 500.0f, 500.0f), Vector3.Zero, Vector3.Up ); projectionMatrix = Matrix.CreateOrthographicOffCenter( 0, (float)GraphicsDevice.Viewport.Width, (float)GraphicsDevice.Viewport.Height, 0, 1.0f, 1000.0f); // Initialize an array of indices of type short. lineListIndices = new short[(points * 2) - 2]; // Populate the array with references to indices in the vertex buffer for (int i = 0; i < points - 1; i++) { lineListIndices[i * 2] = (short)(i); lineListIndices[(i * 2) + 1] = (short)(i + 1); } vertexDeclaration = new VertexDeclaration(new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0) } ); basicEffect = new BasicEffect(GraphicsDevice); basicEffect.VertexColorEnabled = true; worldMatrix = Matrix.CreateTranslation(renderArea.Width / 2f - 150, renderArea.Height / 2f - 50, 0); basicEffect.World = worldMatrix; basicEffect.View = viewMatrix; basicEffect.Projection = projectionMatrix; } void draw3D() { foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.LineList, pointListX, 0, // vertex buffer offset to add to each element of the index buffer 51, // number of vertices in pointList lineListIndices, // the index buffer 0, // first index element to read 50 // number of primitives to draw ); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.LineList, pointListY, 0, // vertex buffer offset to add to each element of the index buffer 51, // number of vertices in pointList lineListIndices, // the index buffer 0, // first index element to read 50 // number of primitives to draw ); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.LineList, pointListZ, 0, // vertex buffer offset to add to each element of the index buffer 51, // number of vertices in pointList lineListIndices, // the index buffer 0, // first index element to read 50 // number of primitives to draw ); } } [/csharp][/QUOTE] new page repost
i can't get my content to load for some reason. i'm using XNA and this tutorial [url]http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Drawing_fullscreen_images.php[/url] that guy seems to have a content project to put his files in but i however do not: [img]http://i.imgur.com/XEccL.png[/img] every time i try to run my game i get the error that it cannot find the background or foreground file.
I'm (still fucking) trying to create a runnable .jar from my Slick2D game. All I ever get when I run it is either: [quote]no lwjgl found in java.library.path[/quote] or: [quote]could not find the main class system.DefendoGame[/quote] Slick is a library that uses LWJGL, if you don't know it. I've tried everything, and the only thing that ever worked was using some weird -Djava.library.path command line argument, but I shouldn't have to do that every time I want to run it. If anyone can help please please please get in touch before I put my laptop through the wall. Thanks.
[QUOTE=frankie penis;31111944]i can't get my content to load for some reason. i'm using XNA and this tutorial [url]http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Drawing_fullscreen_images.php[/url] that guy seems to have a content project to put his files in but i however do not: [img]http://i.imgur.com/XEccL.png[/img] every time i try to run my game i get the error that it cannot find the background or foreground file.[/QUOTE] You want to add your images to "2d gameContent (Content)"
[QUOTE=AgentBoomstick;31112046]You want to add your images to "2d gameContent (Content)"[/QUOTE] i tried that but it still says the same thing
[QUOTE=frankie penis;31112082]i tried that but it still says the same thing[/QUOTE] Post your code.
[QUOTE=AgentBoomstick;31112143]Post your code.[/QUOTE] [code]using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace _2d_game { /// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; GraphicsDevice device; Texture2D backgroundTexture; Texture2D foregroundTexture; int screenWidth; int screenHeight; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } /// <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 graphics.PreferredBackBufferWidth = 500; graphics.PreferredBackBufferHeight = 500; graphics.IsFullScreen = false; graphics.ApplyChanges(); Window.Title = "XNA Game #1"; base.Initialize(); } /// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); device = graphics.GraphicsDevice; backgroundTexture = Content.Load<Texture2D>("background"); screenWidth = device.PresentationParameters.BackBufferWidth; screenHeight = device.PresentationParameters.BackBufferHeight; foregroundTexture = Content.Load<Texture2D>("foreground"); // TODO: use this.Content to load your game content here } /// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here } /// <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) { // Allows the game to exit 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) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); DrawScenery(); spriteBatch.End(); // TODO: Add your drawing code here base.Draw(gameTime); } private void DrawScenery() { Rectangle screenRectangle = new Rectangle(0, 0, screenWidth, screenHeight); spriteBatch.Draw(backgroundTexture, screenRectangle, Color.White); spriteBatch.Draw(foregroundTexture, screenRectangle, Color.White); } } } [/code]
I don't see anything that stands out after looking over it just really quickly. I don't have a lot of time but what is your error that you're getting? [editline]1[/editline] Also make sure your content section looks like this [img]http://dl.dropbox.com/u/8181473/content.png[/img] The "image" folder is not required. If you add it then you have to change your texture loading filename string to foregroundTexture = Content.Load<Texture2D>(@"image/foreground");
Yeah, post your error log
[thumb]http://i.imgur.com/UF0XB.png[/thumb]
[QUOTE=Felheart;31093707]In games or applications that don't need to be very secure that period is big enough. When you have to deal with cryptography you won't use rand() or the likes from a standard library anyway (unless you are retarded). In some games (warcraft3 as an example) RNGs aren't even directly used to calculate proc chances or damage. Instead shuffling bags are used so the game can only be "unfair" towards a player to a certain degree. rand() / System.Random and all the like are good enough for everything in games (except network encryption). But one might consider to use one of the countless implementations of the MersenneTwister on the internet because of the possible speed benefits. Speed of the code and "getting it done" are your biggest concern when working on a game. Still I'd be interested in how you'd implement shifting the numbers in the correct range or hashing them into the result range. (especially the hashing) :)[/QUOTE] If your standard rand() uses a linear congruential generator and gives you 32 random bits (I think Visual Studio gives 23 or so), and you wish to get a modulus of some power of two, it's just a simple bit shift. E.g. if you wish to get a number between 0-15, you could do rand() >> (32 - 4) instead of rand() % 16. The point with hashing would be that it would utilize every bit of the input (which is a random number) to give you a random number. Generating the hash out of 32 bits would generally make it more random than generating it from just 4, but now that I think about it, it might not be necessary with linear congruential generators - since in those, the high-order bits are generated using the low-order bits, so when you get the high-order bits, it already takes into account every low-order bit. I don't know about the case when you use some integer that's not a power of two with the modulus. I don't have the time to do the math, but I think it might be a lot safer than with powers of two.
What does your project explorer thing currently look like? Also can you upload your project in a zip to dropbox or something
First of all move your textures down to Content. Secondly, make sure the image is being put in the directory that the code is trying to load it from (for instance my example should have the images in C:\Users\Sonny\Documents\Visual Studio 2010\Projects\Collision\etc etc) [editline]1[/editline] If your images are in the right place and they aren't loading from Content, make sure in your project that "ContentReferences" is referring to "2d gameContent". You changed a few names and it might be causing the project file to reference the wrong things, rendering it unable to find files in a location that doesn't exist.
[QUOTE=AgentBoomstick;31112575]First of all move your textures down to Content. Secondly, make sure the image is being put in the directory that the code is trying to load it from (for instance my example should have the images in C:\Users\Sonny\Documents\Visual Studio 2010\Projects\Collision\etc etc) [editline]1[/editline] If your images are in the right place and they aren't loading from Content, make sure in your project that "ContentReferences" is referring to "2d gameContent". You changed a few names and it might be causing the project file to reference the wrong things, rendering it unable to find files in a location that doesn't exist.[/QUOTE] ah thanks, forgot to add the ContentReferences bit.
[QUOTE=frankie penis;31112722]ah thanks, forgot to add the ContentReferences bit.[/QUOTE] Glad to help. XNA is fun and easy, so keep at it.
Well, fuck this I'm gonna start using XNA. [editline]14th July 2011[/editline] Ooh, this is nice.
[QUOTE=Nigey Nige;31112816]Well, fuck this I'm gonna start using XNA. [editline]14th July 2011[/editline] Ooh, this is nice.[/QUOTE] I told you how in waywo. You should of followed the get started guide, or atleast googled it first.
Sorry, you need to Log In to post a reply to this thread.