• What do you need help with? Version 1
    5,001 replies, posted
[QUOTE=SupahVee;21188688]What do you mean? Having a List full of bullets, and when I need some I pick them from the List and change their X,Y,Graphic, etc?[/QUOTE] Pretty much. It's called a free-list, instead of deleting your bullets when finished with them, return them to the free-list for recycling. If you know you're gonna have a lot of them, adding an initial amount of bullets to the free-list is also a good idea.
I've implemented it, and it is considerably faster, but it still slows down. Is there anything else I can do?
[QUOTE=SupahVee;21189887]I've implemented it, and it is considerably faster, but it still slows down. Is there anything else I can do?[/QUOTE] When does it slow down? Show us the code in question.
I made a texture: textura = new Texture2D(graphicsDevice, aWidth, aHeight); I did this: textura.GetData<Color>(arr); Then this: arr[50 * width + 50] = color; // to set the pixel at 50, 50 to black Then did: textura.SetData<Color>(arr); Then passed the texture to spriteBatch but it simply doesn't draw it (or it does, but it's just not visible) Now, I know that the draw function is called, I know that the pixel at 50, 50 is indeed black. (I did getData on the texture and then checked that pixel). One reason this doesn't work could be that Content.Load does something else to a texture so that it can be drawn that I didn't do when I made the texture manually. Any ideas what it cold be? I think Wishfallen might know what I'm talking about.
[QUOTE=SupahVee;21189887]I've implemented it, and it is considerably faster, but it still slows down. Is there anything else I can do?[/QUOTE] Are you using a list? If you are, you would probably get a large speedup by using vectors instead. Vectors are a bit slower when inserting, but much faster at iterating. Might be a silly question, but you're compiling in release mode, right?
[QUOTE=noctune9;21190214]Are you using a list? If you are, you would probably get a large speedup by using vectors instead. Vectors are a bit slower when inserting, but much faster at iterating. Might be a silly question, but you're compiling in release mode, right?[/QUOTE] He's using C#, there is no vector class. The equivalent of a C++ vector is indeed a List.
[QUOTE=Darwin226;21190091]I made a texture: textura = new Texture2D(graphicsDevice, aWidth, aHeight); I did this: textura.GetData<Color>(arr); Then this: arr[50 * width + 50] = color; // to set the pixel at 50, 50 to black Then did: textura.SetData<Color>(arr); Then passed the texture to spriteBatch but it simply doesn't draw it (or it does, but it's just not visible) Now, I know that the draw function is called, I know that the pixel at 50, 50 is indeed black. (I did getData on the texture and then checked that pixel). One reason this doesn't work could be that Content.Load does something else to a texture so that it can be drawn that I didn't do when I made the texture manually. Any ideas what it cold be? I think Wishfallen might know what I'm talking about.[/QUOTE] What function are you making the texture in? If it's not LoadContent, I'd try that.
Well, it's I another class but that's not the problem since the DisplayObject loads an image outside of the loadcontent and it still works.
[QUOTE=Darwin226;21191514]Well, it's I another class but that's not the problem since the DisplayObject loads an image outside of the loadcontent and it still works.[/QUOTE] I'm not too sure what's going wrong here, I haven't dabbled a lot in editing textures at runtime. You're trying to write a drawline function, yeah? If so, you might be able to get away with scaling a 1x1 image and then rotating it into place.
Is SDL any good? I just might ditch XNA and try something else because this whole "drawing code in this function, updating in this one" thing is really starting to annoy me.
[QUOTE=noctune9;21190214]Might be a silly question, but you're compiling in release mode, right?[/QUOTE] Is there a big performance difference between debug and release? :/ Also, do you want the source code to take a look at my rendering?
[QUOTE=Darwin226;21194151]Is SDL any good? I just might ditch XNA and try something else because this whole "drawing code in this function, updating in this one" thing is really starting to annoy me.[/QUOTE] I've heard good things about it and SMFL, but I've never actually used them (currently debating whether to drop XNA for SMFL.Net at the moment myself infact)
[QUOTE=Wishfallen;21194244]I've heard good things about it and SMFL, but I've never actually used them (currently debating whether to drop XNA for SMFL.Net at the moment myself infact)[/QUOTE] Do it. SFML is easier and more straightforward.
I don't know, SFML is Simple and Fast Multimedia Library... The simple part tells me it has limited possibilities.
[QUOTE=Darwin226;21194455]I don't know, SFML is Simple and Fast Multimedia Library... The simple part tells me it has limited possibilities.[/QUOTE] What do you want to make?
I probably can handle everything I make but I don't want to make something and then realize I have to rewrite it because SFML is to slow.
[QUOTE=Darwin226;21194151]Is SDL any good? I just might ditch XNA and try something else because this whole "drawing code in this function, updating in this one" thing is really starting to annoy me.[/QUOTE] Combining drawing and updating code is baaaaad practice: ideally, for anything significant, your drawing code, and your simulation should be entirely separate. Also sfml is not limited in the slightest: it has a very able set of 2D functions, and will provide a cross platform OpenGl context should you want to go 3D. In addition to this, the whole library is hardware accelerated, so it runs a darn sight faster than SDL does normally.
[QUOTE=Darwin226;21194889]I probably can handle everything I make but I don't want to make something and then realize I have to rewrite it because SFML is to slow.[/QUOTE] Make it so that your drawing code goes through one renderer interface, and then just write classes so you can connect your renderer interface to SFML or XNA or whatever you end up using. You'll probably end up having to rewrite a lot less if you end up changing if you write it that way. [QUOTE=SupahVee;21194381]Do it. SFML is easier and more straightforward.[/QUOTE] Yeah, I'm going to give it a shot.
Ok, SFML it is then.
Did some random searching, found the "problem". [quote]void QDataStream::setFloatingPointPrecision ( FloatingPointPrecision precision ) ... If the floating point precision is DoublePrecision and the version of the data stream is Qt_4_6 or higher, all floating point numbers will be written and read with 64-bit precision. ... The default is DoublePrecision. ... This function was introduced in Qt 4.6.[/quote] Of course, the box with the problem is the only one with a version new enough to have this feature and without documentation at the ready.
Definitely go for SFML (Darwin), it's a great library. The "simple" part means it's simple to use, not simple as in limited ;)
[cpp] void FileHandle::ParseFile(std::string fileName, bool echoToConsole) { char data; std::stringstream dataC; std::fstream file2(fileName.c_str()); if(file2.is_open()) { std::cout << "File open"; while(!file2.eof()) { file2.getline(data, sizeof(data)); //file2.getline(&data, data->length()); if(echoToConsole) { std::cout << data; } } file2.close(); } else { std::cout << "ERROR OPENING FILE..."; } } [/cpp] why does this not print out what is in the file also doesn't say the file is open, although the file is in the directory
That shouldn't compile, getline doesn't contain an overload for 'char'.
[QUOTE=jA_cOp;21207616]That shouldn't compile, getline doesn't contain an overload for 'char'.[/QUOTE] yeah, changed the code but forgot to update my post
and by fixed I mean the issue ja_cop said
[QUOTE=raccoon12;21208146]and by fixed I mean the issue ja_cop said[/QUOTE] Show us the new code, tell us what you expected and tell us what it outputs. You're not being too clear in your initial post.
[code] Dim image1 As New Bitmap(PictureBox1.Image) Dim image2 As New Bitmap(PictureBox2.Image) Dim finalpicture As New Bitmap(image1.Width + image2.Width, image1.Width) Dim itemp As Integer Dim dtemp As Double For x = 0 To image2.Width - 1 For y = 0 To image2.Height - 1 finalpicture.SetPixel(x, y, image1.GetPixel(x, y)) Next Next For x = 0 To image1.Width - 1 For y = 0 To image1.Height - 1 finalpicture.SetPixel(x + image1.Height, y, image2.GetPixel(x, y)) Next Next For x = 1 To 5 For y = 1 To image1.Height - 1 dtemp = (finalpicture.GetPixel(image1.Width - x, y).R + finalpicture.GetPixel(image1.Width + x, y).R) / 2 'problem here itemp = Math.Floor(dtemp) finalpicture.SetPixel(image1.Width - x - 1, y, Color.FromArgb(itemp, itemp, itemp)) finalpicture.SetPixel(image1.Width + x - 1, y, Color.FromArgb(itemp, itemp, itemp)) Next Next finalpicture.Save("out.png") [/code] When i go to run the code after loading the 2 images I get an overflow on the marked line [code] System.OverflowException was unhandled Message=Arithmetic operation resulted in an overflow. Source=heightmap sew [/code]
[QUOTE=jA_cOp;21208171]Show us the new code, tell us what you expected and tell us what it outputs. You're not being too clear in your initial post.[/QUOTE] OK, here is my file.h file [cpp] #include <string> #include <fstream> #include <iostream> #include <sstream> class FileHandle { public: void WriteToFile(std::string name, std::string fileData); void ParseFile(std::string fileName, bool echoToConsole); }; void FileHandle::WriteToFile(std::string name, std::string fileData) { std::ofstream file(name.c_str()); if(file.is_open()) { file << fileData; std::cout << "File is open.."; } else { std::cout << "File isn't open..."; } file.close(); } void FileHandle::ParseFile(std::string fileName, bool echoToConsole) { char data[1024]; std::stringstream dataC; std::fstream file2(fileName.c_str()); if(file2.is_open()) { std::cout << "File open"; while(!file2.eof()) { file2.getline(data, sizeof(data)); //file2.getline(&data, data->length()); if(echoToConsole) { std::cout << data; } } file2.close(); } else { std::cout << "ERROR OPENING FILE..."; } } [/cpp] Here is my main.cpp file: [cpp] #include <iostream> #include "file.h" int main() { FileHandle file; //file.WriteToFile("R:\\TEST.rac", "ECHO -> 'HELLO'"); std::cin.get(); FileHandle f2; f2.ParseFile("R:\\TEST.rac", true); // f2.P return 0; } [/cpp] And the file I want to open has this in it: [code] ECHO -> 'HELLO' [/code] Everything compiles fine, but when i run the program, nothing shows on the console screen
Which should I use XML or SQL? I'm working on a 2D MMO in Java, and the server part is going to have a list of items. But I don't know if I should use XML or SQL. The login system is already in SQL so thats one pro for SQL, and XML parsing is just way over my head. "Select damage from items where name='bow';" makes a lot more sense to me dicking around with Elements, Nodes, Attributes, and NodesLists. What I'm worrying about is abusing SQL and using it for everything when I shouldn't. Also I don't know if it's possible to have "variable columns". Like how would I do effects? In XML I could do like: [code] <item> <type>melee</type> <effects> <strengh>+5</strength> <intelligence>-2</strength> </effects> </item> [/code] I don't know how to do the above in a SQL DB.
can you not just have the values like effect_str
Sorry, you need to Log In to post a reply to this thread.