Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - TheShyGuy

Pages: [1]
1
Coding / Re: Need some help: C#/XNA List Remove
« on: February 24, 2012, 01:38:46 pm »
Code: [Select]
  foreach (clBullet b in spriteList)
            {
                b.Update(gameTime, Game.Window.ClientBounds);
                if (b.position.X > 300)
                    spriteList.Remove(b);
            }
------------------------------
Code: [Select]
for(int i = spriteList.Count -1; i >= 0; i--)
{
    b = spriteList[i];
    b.Update(gameTime,Game.Window.ClientBounds);
    if(b.position.X > 300)
      {
         spriteList.Remove(b);//or spriteList.RemoveAt(i);
      }
}





its working its way backwards down the list.  Removing anything wont affect the current sprite and you wont skip any because it will remove from the back of the list.

2
Coding / Re: How to find memory leaks?(C# - XNA)
« on: February 01, 2012, 11:41:16 am »
It has nothing to do with creating a new Rectangle every time, its a struct-ValueType so its allocated on the stack every time and is cleaned up right afterwards. If it were to be a class-RefType every frame, then you have a problem. And then DarkJay would be right about the GC but the leak is somewhere else in your code.

edit:
The problem might not be creation of objects, but you might be making calls to the api that are "expensive" and causes garbage itself.  You should probably look over your code to check if your making any of those types of calls too much in one frame.

3
Coding / Re: {Build 1.2} XNA Zelda Engine - Link's Awakening Style
« on: February 01, 2012, 05:14:34 am »
Yes doing everything in "GameComponents" is bad, but I didnt mean "Game Components" from xna, did you read the article? Yes i have also read some c# and xna books too. Yes component based game design isnt OOP, its not supposed to be. Ive read a bit of articles on the design and it seems its better than doing strict OOP. Ofc you can have some kind of OOP design in the component design tho. My Game1.cs also has little code, only to add my component based engine to the components list - which imo isnt a good excuse for anything to be "good". It just means you put your code somewhere else. Im not saying to do anything in game components, im talking about a design pattern thats very different. I was just trying to give out some ideas, i mean ive also done a hierarchy designed engine, but component based design 'imo' is easier. 

Anyways, you can serialize/deserialize data into an xml. It does take some time to load up, but its user friendly and easy to read.  You can also load xml files as content into classes.

http://blogs.msdn.com/b/shawnhar/archive/2008/08/12/everything-you-ever-wanted-to-know-about-intermediateserializer.aspx

you can also just load in text files of your map. But then you'd have to parse it your self. There are other ways too, but ive only done txt files,xml, and multiple kinds of serializing. Xml being better, but slower.


An object would have an input,collision,physics, and render component. A player be an object, except with a "PlayerInputComponent" component. A npc would and an object, except with a "AIInputComponent".  No hierarchy, you get what you want and you can easily make complex objects.  They all are still controlled by the same sprite manager too if you want.

4
Coding / Re: {Build 1.2} XNA Zelda Engine - Link's Awakening Style
« on: January 31, 2012, 09:19:25 pm »
Id save the tiles as the bigger images, but also have another xml that defines the tiles. That way you can swap out tiles if you want without having to redo everything if you want to make changes to the tiles used. Also i don't think you should be making a level editor until you've got some more basic game elements in. Otherwise you'll be changing around your editor code every time you change your game engine code. Also you said that your going to make a class hierarchy, which imo is a tough choice to make. Id suggest a component based game engine design. basically you make objects out of components without giving objects unneeded baggage of their base classes. That way you can make some pretty complex enemies or something. It also allows you to hard code some components without much problem or bugs that you might get from making it hierarchy based.

http://gameprogrammingpatterns.com/component.html

Pages: [1]

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.044 seconds with 36 queries.