Jump to content
  • Advertisement

VizOne

Member
  • Content Count

    467
  • Joined

  • Last visited

Everything posted by VizOne

  1. Of course I don't know about your overall design. What's a component, what's a "game object"? Which components would a single projectile use? I'm under the impression that you are trying to create "the ultimate flexible design", which will probably collapse under its own weight. My suggestion: don't overdesign! Keep it simple, make it work first, refactor later. And of course measure/profile to find spots that need attention.
  2. Quote:What do ypou think? First of all I think that a class with an interface containing that many totally unrelated method is clearly violating both the Single Responsibility Principle (SRP) and the Interface Segregation Principle (ISP). You could split this interface into multiple interfaces like IUpdateable, IRenderable, IMouseListener etc. A component then only implements the interfaces it needs. Instead of having one large list of components you let the component register themselves at separate lists: one for IRenderables, one for IUpdateables etc.This will at least fix the ISP problem and the problem that most components do not require all methods (which in fact is strongly related to the ISP problem). As for the SRP problem: instead of having the component implement all interfaces you could split the functionality into separate classes, one that handles the rendering logic, one that deals with state updates etc. This should simplify your classes and improve the design. Regarding the performance "issue": virtual calls are not prohibitively expensive in general. So before you try to optimize those calls away: MEASURE! Regards, Andre
  3. VizOne

    which language I should chosen?

    Hi, I try to take the short route here as long as the thread stays objective: 1. Unless you have many years of experience in game development and project management, several dozens of professional game developers behind you, a multi-million budget to spend and a time frame of several years available, you are probably not going to make anything that resembles WOW any time soon. Developing something similar to WOW is far, far, FAR too difficult for any casual developer. Check out google on this topic. This is why oler1s states that choice of the programming language will not make any difference for the success or failure of the project. 2. The choice of programming language does not matter for practically any game made by a casual developer. Each programming language and environment has its unique performance pitfalls that you need to be aware of. Try to make a simple game (like Tetris) in both languages to see which one you like better. Regards, Andre
  4. VizOne

    World Cup 2010

    Congratulations Spain! The Spanish team played incredibly well, they totally deserved to win. Greetings, Andre (from Germany) P.S.: Being a German studying in the Netherlands, I had sooooo hoped for a final Germany - Netherlands :-(
  5. VizOne

    Dev-C++/DirectX Not compiling

    Two things: First, the error message is not complete as far as I can tell, maybe you can post everything the compiler outputs. Second, and more importantly, Dev-C++ is literally ancient, dating back to 2005. You should really(!) get an up-to-date compiler and IDE. I've only used Visual C++ (the Express Edition is free) and Eclipse for C++ development so far, but I've heard good things about Code::Blocks. Regards, Andre
  6. Hi, You will probably run into I/O problems that fall outside the .NET scope. 50 files, each 20MB in ten seconds, that's 1GB in ten seconds or on average 100MB/s, or 800mbit/s + overhead when transferred over a network. I don't know what the sources are and how you process the data, but a conventional PC will probably not handle this reliably. If the sources are connected via network, this will probably be the bottleneck. If there's harddisk activity involved at the sources or the service, than this will become difficult (especially on writes). But if you only generate data in memory and process it in memory and all happens on the same machine, the bandwidth is not so dramatic anymore (800mbit/s in memory is not much). In this case, processing speed/processor speed will play a role. But before I continue speculating: why don't you build a prototype and see how far it gets you? Regards, Andre
  7. VizOne

    [C#] Localized Ressources

    Hi, There are two problems you are facing: first you want to control where the resource assemblies are saved. Second, you need to tell the application from where to load the resources. The latter is easy to achieve: you can add an app.config file to your project and define in there which paths the .NET runtime should probe in order to find resource assemblies. For example, if you want to move the de-de, en-us etc. folders to a subfolder Content below the application directory, you would add the following configuration in app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="Content"/> <!-- also search Content folder for assemblies --> </assemblyBinding> </runtime> </configuration> You could add a post-build event to your project that moves the assemblies from the default directory (below the app directory) to your desired directory. Paired with the configuration above you'd be done. If you are familiar with MSBuild, the next paragraphs might be interesting for you. Technically, it is possible to control where the resource assemblies are created. I don't know of any switch in the Visual Studio user interface to modify this behavior. However, the .NET SDK itself support the necessary options. So, if you compile everything by hand or if you use the msbuild system (which is preferable) you can achieve what you want without copying files in the post build event. The next paragraphs describe where the necessary setting is buried in the standard msbuild system. The default build process is mainly defined in the .targets file in the framework directory. For C# projects, Microsoft.Common.targets and Microsoft.CSharp.targets are the files of interest. Resource compilation is controlled in Microsoft.Common.targets. Satellite assemblies (that is, localized resource assemblies) are generated by first compiling resx files into .resource files. This is done in the GenerateResource task of the CoreResGen target. The next step is to link the resource files into assemblies. This is done using the AL task in the GenerateSatelliteAssemblies target. The OutputAssembly attribute of the AL task defines where the satellite assemblies should be saved. Its default value is $(IntermediateOutputPath)%(Culture)\$(TargetName).resources.dll.
  8. VizOne

    [.net] C# Template

    The directory is controlled by the BaseIntermediateOutputPath property in your csproj file. Edit the .csproj file with an editor and add something like the following to the proper PropertyGroup (probably the one without the Condition attribute): <BaseIntermediateOutputPath>..\MyObjDir</BaseIntermediateOutputPath> More info on properties you can set: http://msdn.microsoft.com/en-us/library/bb629394.aspx To make this the default, yes, you need to modify the project template. It's not very difficult, though. For VS2010 it works like this: - Locate the project template zip file, for example at Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\ClassLibrary.zip - Unpack it somewhere - modify the files as needed, ie. for example change the classlibrary.csproj file to include the property I mentioned above - modify the vstemplate file to give the template a proper ID (<TemplateID>) and name (e.g. <Name>My Custom Project</Name>) - put the files into a new zip file (e.g. MyProject.zip) - add the new zip file to the template folder (see above) - reset visual studio by calling devenv /setup from Microsoft Visual Studio 10.0\Common7\IDE - you should now be able to select your new project type from the File=>New Project window Be sure to make backups etc. before messing with the files. But then again, I never found the obj folder to be a problem. If I really feel the need to clean up the working directory, I use the proper command from my versioning system (e.g. "git clean -xfd" or "git clean -Xfd") which wipes out anything that is not part of the repository. Still it's nice to now the properties, especially if you use msbuild for automated builds. [Edited by - VizOne on May 21, 2010 9:48:27 AM]
  9. Quote:Original post by Lio But as far as i could find it had no way to sort a linkedlist or keep the order of already sorted elements. That's probably because linked lists are not the best data structure to keep sorted. You might want to look into sorted trees, like binary search trees (red-black trees, avl trees, b-trees) or prefix trees aka tries (if the keys resemble strings). In .NET, SortedDictionary is a tree-based key-value data structure (a red-black tree in fact).
  10. VizOne

    [.net] C# - returning a ref?

    Add returns the value that was stored at this. Because E2D_Entity (strange naming btw) happens to be a class, this value is either null or a reference to an object of type E2D_Entity. Add will, however, not return a reference to the slot this itself.
  11. Regarding both of your problems: you should split the visuals from the logic. The rules of the game don't change, no matter if you're playing it as a win forms app or in a console window, right? Clearly, the logic and the visual representation are two concerns. As such, you should split them in your code as well. As a general guideline: split your solution into two projects, let's say Memory.Rules (a DLL) and Memory.UI (a winforms app). Memory.Rules should not have to reference System.Windows.Forms or System.Drawing at all, because those are related to visuals. Memory.UI on the other hand should only contain code related to visuals, that is forms and controls etc. Your Game certainly class goes into Memory.Rules. It could have methods such as void TurnOverCard(int x, int y) or bool IsTurnedOver(int x, int y) and these methods deal with all the rules related to memory as an abstract game concept. You could then add an event to Game such as public event EventHandler StateChanged; that you raise whenever something important changes (time, score, turned over cards etc.) Your win form (which is responsible for drawing the board) can subscribe to this event and react accordingly (redraw the affected parts etc.). This pattern is referred to as Observer Pattern. Of course, other ways of achieving this decoupling are possible, e.g. MVC Likewise, managing the bitmaps belongs to the UI. Maybe you can create a class Card in your Memory.Rules project that holds information about a card (position and e.g. a name such as "Cat", "Dog"). In your UI project, you could create a user control that represents a card/buttom. When you create the form with all the card buttons, pass each card button the Card object that it represents and have it load the bitmap based on the name of the card ("Cat"=> "Cat.jpg" or so). Of course that would cause all bitmaps to be loaded twice. So you could go a step further and create a "BitmapManager" class. You pass it the name of a card and it returns the appropriate bitmap (that it loads once the first time it is requested). This can be as simple as this: public class BitmapManager : IDisposable { private Dictionary<string, Bitmap> images = new Dictionary<string, Bitmap>(); public Bitmap GetBitmap(string name){ Bitmap bitmap; if(!images.TryGetValue(name, out bitmap)){ bitmap = LoadBitmap(name); images.Add(name, bitmap); } return bitmap; } Bitmap LoadBitmap(string name)[ string fileName = Path.Combine("images", string.Format("{0}.jpg", name)); return new Bitmap(fileName); } public void Dispose(){ foreach(var bmp in images.Values){ bmp.Dispose(); } images.Clear(); } } Now the BitmapManager is the owner of the bitmaps. So, in general don't try to combine completely different concerns in the same class. Have a look at the Single Responsibility Principle (and the other OOP principles). Hope that helps :-) Have fun!
  12. The most common way to consume managed code from within a native application is to use COM. You can create a COM callable wrapper for your managed DLLs and invoke that in your native app. See e.g. http://support.microsoft.com/kb/828736 Theoretically, you can host the .NET runtime explicitly in your application, but you probably don't want that: http://msdn.microsoft.com/en-us/library/9x0wh2z3.aspx
  13. Works fine here: if I click on the form, a message box shows up displaying "updatePosition". I used your code, added some fake implementation for the missing classes Shape and Ellipse and used the following code to start the app: using System; using System.Windows.Forms; namespace ClickTestApp { internal static class Program { [STAThread] private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new P3()); } } }
  14. VizOne

    C# pointers/references

    C++/CLI supports managed references (%), so you could do this: array<int> ^ data = {1,2,3,4}; int % intRef = data[2]; intRef = 123; // now, data[2] == 123 In C# you'd have to stick to unsafe+fixed+pointers to get this kind of indirection with value types, I guess, or a method with ref parameter as you showed in your post. But most importantly: you have to measure whether different approaches actually make a difference in practice. I wouldn't want to jump through loops for total 1% performance gain.
  15. It's ok that you're trying to minimize the pressure on the GC, but you won't probably be able to avoid dynamic allocations completely. However, I guess it won't hurt too much if you create your score strings once per frame. The GC is pretty fast for short-lived objects. You can of course just cache the score string as long as the score is the same. Depending on your game this could mean that you only have to allocate the string every few seconds or so. In general, you shouldn't go crazy with premature micro-optimizations like this. Get the thing working in the first place, then measure to find potential areas for optimizations. Have fun!
  16. The CLR (like the VM Java) does not only provide a class library, but a whole infrastructure consisting of many more services, such as garbage collection, code access security etc. It could not be compiled into the application without making each executable hugh(!). Therefore, it is required to be installed on the target machine. When comparing Java to .NET, I find that updates to the Java VM are much more frequent and less transparent, while update to .NET are more or less automatically deployed through windows update. On the other hand, most other languages require a certain runtime library (and version) to run as well (ever had trouble with a missing MSVC++ runtime library?), so I don't see the point in the first place. After all, it's a question of correctly deploying an application: build a proper installer and everything is fine. Deploy a single zip file or so and expect trouble with non-techies :D
  17. Hi, If you don't know what a memory pool is, why do you want to use one? Besides, you probably don't need a memory pool in C# anyway. Heap fragmentation isn't an issue under .NET because of the heap compaction done by the garbage collector. You might want to do pooling on a higher level, though. For example, if you have a particle system, you could reuse "dead" particle object instances, instead of constantly re-creating new instances. This puts less pressure on the garbage collector. However - and this is important - you should always measure before you do this kind of optimization. The garbage collector is pretty smart and quite fast for objects with a short life time. I'd say, first try to get the functionality working, then profile your app and see where problems are. For example, in games under .NET you will want to check the amount of per-frame allocation and the frequency of/time spent in garbage collections. BTW, this only counts for realtime-ish applications, such as games. For "conventional" applications, you generally don't need any optimization of this kind at all. Regards, Andre [edit]Sorry, a bit late, the gamedev.net DB had some trouble when I originally wrote the post
  18. VizOne

    Risk Clone - Can I do that?

    The common answer to that: read this
  19. Here is one very compact implementation of what you want: using System.Linq; ... List<double> type = File.ReadAllLines("data.txt") .Select(row => row.Split(' ')) .SelectMany(parts => parts, (parts, value) => double.Parse(value, CultureInfo.InvariantCulture)) .ToList(); - File.ReadAllLines reads all lines of text from a file (returns string[]) - Select(row => row.Split(' ')) invokes the Split method on each row and returns IEnumerable<string[]> in this case - SelectMany(parts => parts, (parts, value) => double.Parse(value, CultureInfo.InvariantCulture)) flattens all those string arrays into a single enumeration of strings and than invokes double.Parse to convert each item into a a double, this returns an IEnumerable<double> - finally, ToList transforms the IEnumerable<double> into a List<double> I highly recommend to try to understand the code above. Being able to use this kind of functional paradigm is one of the most outstanding features of C# and helps a lot to write compact code.
  20. Maybe the supportedRuntime element can be used. I don't know though, haven't used .NET 4 yet.
  21. To be more precise: Using con As SqlConnection = New SqlConnection("Server=aServer;Database=Web;User ID=aPerson;Password=aPWD") con.Open() End Using is more or less the same as Dim con As SqlConnection = New SqlConnection("Server=aServer;Database=Web;User ID=aPerson;Password=aPWD") Try con.Open() Finally con.Dispose() End Try Using therefore guarantees that Dispose is called if the connection instance was created even if an exception is thrown within the Using body.
  22. If you use field initializers, the C# compiler will effectively pull that initialization code into every(!) constructor. So this: class Foo { int x = 234; public Foo(){ } public Foo(string xyz){ } } will become this after compilation: class Foo { int x; public Foo(){ x = 234; } public Foo(string xyz){ x = 234; } } Therefore field initialization is useful to share the same initialization value for all constructors. You can of course still initialize a field in any or all of you selectors if you like. Generally I prefer member initialization for all variables whose value does not depend on the constructor variables. After all, whether you initialize instance variables at their declaration or the constructor is mostly a matter of taste. However, things are a bit different for static fields. The moment that the initialization takes places is different whether you have a static constructor or only static field initializations. The short story: classes with a static constructor have their static fields initialized as soon as any member of the class is about to be used (including the instance constructor). Classes without static constructors have their static fields initialized as soon as any static field is about to be use the first time. Read this if you need more details or this
  23. VizOne

    IndieGameVideos.com launched

    I like the site, but I think 30 seconds of gameplay is way too short. I'd prefer to see at least a few minutes of gameplay, maybe with some additional commentary. Also, a bit more information for each title would help. After all it's your goal to help your visitors getting insight into the titles. Also, you should include the title's price in the overview list. And don't forget to add free indie games as well, for example "Ben there, Dan that", which is the predecessor to Time Gentlemen, please. Of course it's your initial release and as I said, I like it. Keep up the good work!
  24. I haven't work a lot with the property grid, but I guess that if you assign X or Y the property grid will call the Foo.Vec getter and just assigns the field, so it won't assign a new value to Foo.Vec.
  25. The question is: does it really matter? What do you need to store in these files? If both formats are generally capable of storing what you need to store (and they probably are) go for the one that is easier for you to implement at the moment, abstract away the code that reads and writes the file and go on with more important stuff. If it becomes evident later that your totally won't cover your need, you can exchange the format pretty easily. If I had to choose, I'd go for XML in most situations. Not because it's en vogue or cool, but because I'm a .NET developer and there it is extremely easy to serialize whole object graphs to XML and load them back to memory. With no effort I can load e.g. a configuration from a file into a usable object graph.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!