Nokame

Members
  • Content count

    55
  • Joined

  • Last visited

Community Reputation

153 Neutral

About Nokame

  • Rank
    Member

Personal Information

  1. C# for 2D game

    I would just use XNA, unless there's some sort of reason you care that XNA is dead.  Given your desire to create a 2d game, using C#... it seems like xna would be a solid enough choice.  If you're worried about up-to-date libraries and such... open up that C++ book and... get used to it (he added gently).  If your just trying to learn a few things about game development, xna is simple... fun... and still serves that purpose well.   Either way, good luck :)   Nokame
  2. Hi there, I recently noticd that when I have my game minimized during initialization, it seems to fail in creating RenderTarget2D surfaces.  It has no error message and the game itself looks fine, but any draw call (using spritebatch) that explicitly draws RenderTarget2D objects created during initialization are not visible... as if the pixel data is completely wiped, or never actually initialized due to the application being minimized.  I'm not interested in better ways to draw or whatever... i'm interested in knowing if this specific situation is normal, perhaps it is the reason there are better ways of drawing and saving pixel data.  If anyone can shed light on this, i'd be grateful.   Thank you. https://sites.google.com/site/kingmxf/
  3. Well, this is what i'm talking about.  I'll use the following in my draw method   effect.Parameters["y"].SetValue(0);    // At y = 0 the rendertarget2d surface top row is altered using hlsl.   Not sure why it took me so long to find.  I haven't tried to implement yet, but I'm sure it'll work fine... I've also been toying around with another way to get the desired effect.  Thanks for the feedback.
  4. I apologize for not being clear.   The effect would be applied to a rendertarget2d surface, not the image itself.  So in the above "example" the y = 0  parameter would cause the surface's pixel-row 0 to be altered, not the image pixel-row 0.  Aurioch's method is something I want to avoid beacuse it seems like it has needless overhead to do it during runtime, whereas applying color effects using HLSL seems to be very easy... I just want to apply that color effect to a single row of pixels (given an updating value: y) on the surface, rather than the entire surfafce.    Thanks.
  5. Hi there, I was hoping to simply get some direction.I want independent images to have an effect applied to them, where a y value parameter (which will increase/decrease) determines where the effect should be applied to the image.  For example:   - Let's say the example image has a height of 100 pixels - We'll start the y value at 0   Because the y value is at 0 the effect should be applied along the first row of pixels in the image (row 0).  The game will update the y value, thus moving the effect up/down the image (like a scan animation, I suppose).   Now.. the effect I'm looking to do seems simple. I just want to replace a single color, a range of colors,or all the colors of the row, specified by y, with another single color.  I can figure this part out.   The main problem for me, is figuring out how to apply and updating value, like y, to the effect on a single image... among many images.  If anyone could point me in a good direction, I'd be grateful.  It's also probably worth mentioning that i'm using XNA 4.0, and this game is using 2D spritebatch. Thanks for reading.   Nokame
  6. Hi there, I'm using XNA 4.0 with C#... and am using XACT to play sound clips in my game.  I'm also using MediaPlayer to play mp3's in the background. What I want to do is show a visual audio spectrum of specific sounds which are .wav format.  I can get the visual data for the mp3's playing the background using:   VisualizationData visData = new VisualizationData(); MediaPlayer.GetVisualizationData(visData);   How do i get the same data from my XACT wave files?  I have no need for the visual spectrum of the background music, i want to show the visual data when certain sounds play.  Does XNA have an easy way to do this? If not, I'd like a suggestion as to what I would need to research in order to do this.   Nokame.
  7. Realistic Encouragement vs Trolling Tear-down

    I remember when I first wanted to create video games. It wasn't about programming them. It becomes obvious, once you begin down the road of a beginner that things become technical and, dare I say tedious, to people that want to "simply" create something visually exciting and/or tell a legendary story. I think all of us are here to do exactly this having persevered, feeling either obligation or excitement while learning how to write code. Because programming is a word that is linked to any beginner's favorite video game, it's an exciting venture (until slammed by a know-it-all that takes too much pride in their contribution). There is a bittersweet aftertaste to everything in life. I think perpetuating negativity towards a far-fetched goal in game development, because it happened to you... is worthless. Cheers to humility.
  8. 2D sprites and ambient light

    It looks like your drawing the lighting fx then the sprites on top of it. Play with the order of what you're drawing, if you haven't.
  9. Hi all, I'm not sure if this is the right forumn to post this question in, but here it is... I'm releasing a game demo in about a month, and I have a very limited amount of legit 2D sprites to use. I found some that were clearly ripped from old snes games and such. I realize this is a problem, but I'm not entirely sure if it is a problem for just a demo. Basically... Yay or Nay? Thank you. [i][b]Apologies, I found my answer.[/b][/i]
  10. I agree. It's time to go through it thoroughly. I've been thinking that since this code seems to be done correctly, it's increase in processing power is shedding light on another problem... which i'm excited about.... *sigh*. Anyways, thank you very much for helping me up to this point. Having another voice on the matter has put things into perspective. *closes post*
  11. I figured i'd give you the whole draw method as well... The following code is called during the draw function. The lightmap rendertarget is created (as discussed) and the map is all drawn onto a rendertarget then drawn to the screen... THEN the lightmap is drawn over the map. [CODE] this.DrawLightMapToRenderTarget(); // This is the function i first posted. this.GraphicsDevice.SetRenderTarget(0, this.region.regionSurface); this.GraphicsDevice.Clear(Color.Black); this.spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.FrontToBack, SaveStateMode.None); #region Draw Player, Character, and Map (The Map's Colored image) ////////////////////////////////////////////////////////// // Draw MAP this.DrawRegionTEST(this.region, this.player, this.region.characterList, gameTime); // Draw Region's Characters this.DrawCharacters(this.player, this.region.characterList, gameTime); // Draw Player this.DrawPlayer(this.player, gameTime); ////////////////////////////////////////////////////////// #endregion this.spriteBatch.End(); this.GraphicsDevice.SetRenderTarget(0, null); this.GraphicsDevice.Clear(Color.Black); // Draw the region and characters. this.spriteBatch.Begin(); this.spriteBatch.Draw(this.region.regionSurface.GetTexture(), new Vector2(), Color.White); this.spriteBatch.End(); // Draw lightmap over all the textures this.spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState); this.spriteBatch.GraphicsDevice.RenderState.SourceBlend = this.region.sourceBlendType; this.spriteBatch.GraphicsDevice.RenderState.DestinationBlend = this.region.destBlendType; this.spriteBatch.GraphicsDevice.RenderState.BlendFunction = this.region.blendFunction; this.spriteBatch.Draw(this.region.lightMap.GetTexture(), Vector2.Zero, Color.White); this.spriteBatch.End(); [/CODE]
  12. you're being very helpful, let me say that i appreciate this. At initialization spritebatch is loaded. [size="2"][color="#0000ff"][size="2"][color="#0000ff"]this[/color][/size][/color][/size][size="2"].spriteBatch = [/size][size="2"][color="#0000ff"][size="2"][color="#0000ff"]new[/color][/size][/color][/size] [size="2"][color="#2b91af"][size="2"][color="#2b91af"]SpriteBatch[/color][/size][/color][/size][size="2"]([/size][size="2"][color="#0000ff"][size="2"][color="#0000ff"]this[/color][/size][/color][/size][size="2"].GraphicsDevice);[/size] and during initialization the following is called when a map is loaded. [CODE] PresentationParameters pp = device.PresentationParameters; // This RenderTarget2D object holds the map (or region) and all sprites. region.regionSurface = new RenderTarget2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, SurfaceFormat.Color, pp.MultiSampleType, pp.MultiSampleQuality); // This RenderTarget2D object holdes the "lightmap". region.lightMap = new RenderTarget2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, SurfaceFormat.Color, pp.MultiSampleType, pp.MultiSampleQuality); [/CODE] then for the textures of all the lighting is loaded (also at initialization) is as follows: [CODE] // Get the light texture images int numberOfTextureObjects = Convert.ToInt32(temp[count]); count++; for (int i = 0; i < numberOfTextureObjects; i++) { // Create a list of textures and filenames region.regionLightSourceTextures.Add(Content.Load<Texture2D>("Lighting\\" + temp[count].Trim())); region.regionLightSourceTextureFileName.Add(temp[count].Trim()); count++; } // Get the number of LightSource instances on the map int numberOfLightInstances = Convert.ToInt32(temp[count]); count++; for (int i = 0; i < numberOfLightInstances; i++) { // Create a list of LightSources. // // Get the index of our texture list for the image to be used int imageIndex = Convert.ToInt32(temp[count]); count++; region.regionLightSourceInstanceTextureIndex.Add(imageIndex); // Get the color of the light Color color = Region.GetColor(temp[count]); count++; // Get the size of the light float range = (float)Convert.ToDouble(temp[count]); count++; // Get the location of the light on the map. int x = Convert.ToInt32(temp[count]); count++; int y = Convert.ToInt32(temp[count]); count++; Vector2 location = new Vector2(x, y); // Distance if (temp[count].ToUpper().Trim().Equals("DISTANCE")) { count++; // Get the distance float distance = (float)Convert.ToDouble(temp[count]); count++; // Add the light source region.regionLightSourceInstances.Add(new LightSource(region.regionLightSourceTextures[imageIndex], color, range, location, distance)); } else { region.regionLightSourceInstances.Add(new LightSource(region.regionLightSourceTextures[imageIndex], color, range, location)); } } [/CODE] the code above is part of a method that loads a map from a text file. As far as the lighting goes, it copies a Texture2D object from a list of possible textures to a new lighting instance, which is then added to a map's (or region's) list of light sources. The lighting textures aren't instanced, rather they are copied. Each lightsource has it's own texture2d object. I would think the non-instancing part as troubling, but some of the maps only have a few lights going, and still have the eventual reduction in FPS. These are all the assets i can think of. There are primitives on the map, but those work fine while the lighting is turned off. again, thanks for the back and forth.
  13. Well, I messed up. I actually do just reuse the RenderTarget2Ds by drawing on them every frame, i dont reinitialize them every frame, just redraw. Sorry about that.
  14. I create that lightmap (RenderTarget2D) every frame because the background scrolls and it moves the lights onto the screen. Should I find a way to create a large lightmap once and then pull portions from it every frame?
  15. First of all, thank you for the response. I'll look into those suggestions. Sorry if the post was a bit vague. The "[color="#660066"]DrawToRenderTarget()" [/color]method shown above renders a 'lightmap' to a RenderTarget2D object. It clears the surface to the "ambience" color, then all the lights, which are just images, are drawn onto the RenderTarget. So the line: light.Draw(this.spriteBatch); just means... [size="2"]spriteBatch.Draw(lightTexture, position, [/size][size="2"][color="#0000ff"][size="2"][color="#0000ff"]null[/color][/size][/color][/size][size="2"], color, 0, center, scale, [/size][size="2"][color="#2b91af"][size="2"][color="#2b91af"]SpriteEffects[/color][/size][/color][/size][size="2"].None, 1);[/size] Once the RenderTarget2D object is "filled" i use the following code to Draw it to the screen, after everything else has been drawn (that I want "light" to fall on): [CODE] // Draw lightmap over everything this.spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState); this.spriteBatch.GraphicsDevice.RenderState.SourceBlend = this.region.sourceBlendType; this.spriteBatch.GraphicsDevice.RenderState.DestinationBlend = this.region.destBlendType; this.spriteBatch.GraphicsDevice.RenderState.BlendFunction = this.region.blendFunction; this.spriteBatch.Draw(this.region.lightMap.GetTexture(), Vector2.Zero, Color.White); this.spriteBatch.End(); [/CODE] Note: this.region.lightMap is the RenderTarget2D object. I suppose it's also worth mentioning that I've messed around with the RenderStates, BlendModes, SaveStateModes and the lighting effect is either skewed too much to be useful, or still causes the game to run sluggishly. I hope this made the question more clear.