Hey everyone, As my first project with C#, DirectX, and object oriented programming begins to take form, I'm finding myself with a real problem. I only get to actually 'test' my game online once every few days because I don't know many people who will try it out with me. On my LAN, the game runs perfectly fine. I can launch as many game clients as I want and everything appears smooth. Once I actually test it over the internet, it's a different story. When two clients connect, there appears to be some serious lag between them for a few minutes, but then it clears up and plays great - with a short lag between shooting someone and having them explode (depending on the players' ping). When a third person joins, everything goes to hell and never syncs up again. I've tried using the DirectX network simulator but changing my game around using that has a guide is extremely frustrating. My last innovation (or desperate attempt) crashes my application under the sim, but a seems to work fine otherwise. I'm getting nowhere without being able to test the game over the internet (or at least better simulated lagged environment). I guess what I'm asking then, is there a .NET chatroom online where I could just pop in and try to round up a person or two? Or is there some kind of utility that I can use to simulate higher than 0 ping? EvilDingo
EvilDingo
Posts
-
The need to test my game online. -
Memory leak woes.Hey everyone, I'm still chugging away on my little game. Right now you can connect to a server and play across the internet. The 'game' works, but I'm having some serious issues with memory leaks. I don't know when I should implement the IDisposable interface. Even when I implement it, it doesn't seem to make any difference at all. It seems the source of my problem are arrays and their values. For example: I had an array of bullets. Whenever one bullet was spent and no longer being used, I would just simply call: bulletArray[i] = new Bullet(); and replace the old version of the object with a new one. This caused a very unwelcome memory leak that took me hours to track down. I thought I could just overwrite the old object but it turns out the system holds on to it indefinitely. My next problem. I've recently started using ArrayLists. Whenever something was no longer needed, I would .Remove(ObjectNoLongerNeeded). Wouldn't removing the object also set it up for garbage collection? It doesn't seem to. What do I need to do to get rid of the old object and reclaim the memory? This is my first C# program and the first time using a OO language. It's wonderful to see my program working, but whenever anyone shoots while connected their program's memory requirement permanently increases. Whenever anyone explodes, memory requirement goes up. I know this has to do with my arrays, but damn, there are so many of them. How can I get around this? If I have a class called MyClass() that implements IDisposable, what do I need in the Dispose function to actually 'dispose' it? How do you dispose integers, floats, and other primatives? Thanks, EvilDingo
-
Distributing C# .NET programs... major headache.It looks like that did the trick! Is this something they're going to fix in the near future? Adding a few extra small files is definitely something I can live with, but even so, we shouldn't have to. :) Thanks for your reply! EvilDingo
-
Distributing C# .NET programs... major headache.I have a problem. I can't get my programs (or the examples on this website) to run on other computers without a major headache. I've been writing a program using C# and DirectX. I thought that the target computer would need: .NET Runtimes and the latest vesion of DirectX (9). But, my programs don't (nor the examples on this site) work in that configuration. I had to download the DirectX 9 SDK runtime to get my program to work. That is a HUGE file! I got my friend to download the same thing so I could show him my progress and it fubar'ed his computer. This is not good. What do you need to do to make your programs distributable? Is there something I'm doing wrong? EvilDingo
-
Animation appears to studder? How do you set a frame rate?Hey again, I'm animating an image across the screen. My problem is, it seems to studder as it moves across the screen. This gets more pronounced the faster I move the image. Is there any way to get nice smooth animation? I'm using the DirectX animation example as my guide but it doesn't seem to be fixing the problem. Should I create a separate thread for setting the frame rate? That's really what I'm looking for. Some way to syncronize the framerate. Thanks, EvilDingo
-
C# and Managed DirectX Invalid RectangleDoes it matter how large the .exe file gets? I used to program in DOS and the eventual .exe size was a big consideration. If it doesn't matter with Windows and .NET then embedding them is the way to go. For ease of use. EvilDingo
-
C# and Managed DirectX Invalid RectangleJames, I really appreciate you repling to me because you tipped me off to my Rectangle Exception. There was no clipper associated with the back surface and that is what ended up causing all the trouble. I had been working on this problem longer than any programming problem I've had in many moons. I guess that's to be expected when learning a new language... :~ I read your excellent resource article and I have one question. When using embedded resources, does that actually include the image file in the executable? Or does there still need to be an external file distributed? Since I just worked out the drawing problem, I haven't tried loading a resource yet, but to answer your question, I did have it marked as an Embedded Resource in VS.net. Is there any benefit to using it as an embedded resource as opposed to just loading the image file with the filename string constructor? Thanks, EvilDingo
-
C# and Managed DirectX Invalid RectangleHello, I am an utter newbie with C# and DirectX. None the less, I'm determined to learn C# using Managed DirectX. I'm developing a stupid game to increase my nearly non-existant knowledge and I've hit a snag. Okay, two snags. I create a surface for a plane image, my background, back, and front. Since this is a windowed program, I can't just use normal coordinates for drawing and have to create a rectangle at the window's location (the picturebox I'm drawing to). So I create a rectangle for my plane and background and draw them to the back surface then finally to the front surface which is displayed. This works pretty well, except, when I move the window part-way off my monitor's screen, I get an Invalid Rectangle exception. I figure when my rectangles I'm drawing to extend off screen it throws that exception. Unfortunately, I have no idea what to do about it. I can catch the exception, but then what do I do with it? Surely windowed games don't all throw Invalid Rectangle exceptions when they're moved off the screen. There has to be something I'm doing wrong. My next problem is totally baffling to me. I decided I wanted to use System.Drawing.Bitmap's along side with DirectX since DirectX's Surface class supports that object. In my non-DirectX program I can simply load the image with myBitmap = Bitmap(GetType(), "bitmap.png"). No worries. But in my DirectX program, using the EXACT same settings, files, and resources it says it can't find "bitmap.png" resource in that class. This is driving me up the wall. The resouce is there! It works in my other program! There is -nothing- different. In my DirectX program I have to load the file with a different constructor: myBitmap = Bitmap("c:\bitmap.png") works. But... why?! Why won't it work the other way? Anyone out there that can help me? Especially evil today, EvilDingo