• What do you need help with? V. 3.0
    4,884 replies, posted
Can someone explain to me what the return function in python does? The guide I'm using didn't really describe it clearly.
[QUOTE=Themage;31384518]Can someone explain to me what the return function in python does? The guide I'm using didn't really describe it clearly.[/QUOTE] return is not a function. It's a built-in keyword that makes the current function you're in exit with a specific value. Example: [code]def some_function_that_adds(a, b): c = a + b return c # in math notation: f(a, b) = a + b value = some_function_that_adds(2, 3) print value # output: 5[/code]
Hi, I'm using SQL Server express with a VB.NET application, and whenever I restart the server, the data that was previously changed is reset, oddly enough. I've read through [url=http://msdn.microsoft.com/en-us/library/ms246989(VS.80).aspx]this article[/url] but changing the output to 'Copy if Newer' didn't fix the problem. Any help is appreciated, thanks.
what would be the best to hold a html file with unknown until program runtime size? a dynamic char or a string?
In which language? [editline]28th July 2011[/editline] For example, in C, char * [B]is[/B] a string so there is no difference. In C++ whether you want to use a string depends mostly on preference, I suppose. In general, if you are handling strings without a string class in C++ you're most likely doing it wrong, though.
[QUOTE=esalaka;31393488]In which language? [editline]28th July 2011[/editline] For example, in C, char * [B]is[/B] a string so there is no difference. In C++ whether you want to use a string depends mostly on preference, I suppose. In general, if you are handling strings without a string class in C++ you're most likely doing it wrong, though.[/QUOTE] I don't know, I much prefer using char* for strings in C++ because it's universal, powerful, and fast way to hold strings. A string class is fine, but there are a ton of gigantic projects that use char* as their main way to handle strings. The entire WinAPI is built using LPTCSTR which is a multifunctional typedef for a char array, and you can't say they were doing it wrong :v: [editline]28th July 2011[/editline] [QUOTE=marcin1337;31393419]what would be the best to hold a html file with unknown until program runtime size? a dynamic char or a string?[/QUOTE] You can use std::string or find a way to know its size beforehand so you can prepare an appropriate buffer.
[QUOTE=Gbps;31394794]The entire WinAPI is[/QUOTE] written in C [editline]29th July 2011[/editline] That said, char * is a perfectly valid way of handling strings. It just doesn't really make any sense when you could use the much more powerful std::string or invent your own wheel.
[QUOTE=esalaka;31394866]written in C [/QUOTE] I must be confusing it with something else, then. (the winapi isn't really my forte)
If they had only defined the C string functions to accept an integer length instead of using null-termination, the world would be a better place today. I wonder how many security exploits that one seemingly insignificant decision has caused over the years. [editline]28th July 2011[/editline] [QUOTE=Wyzard;31379631]What mark-and-sweep garbage-collecting smart pointer did you have in mind?[/QUOTE] An imaginary one that I just made up :(
[QUOTE=ROBO_DONUT;31395627]If they had only defined the C string functions to accept an integer length instead of using null-termination, the world would be a better place today.[/QUOTE] The problem is that we'd only have 255-byte strings :/ [editline]29th July 2011[/editline] Although most of the functions have counterparts that accept a length argument.
[QUOTE=esalaka;31395764]The problem is that we'd only have 255-byte strings :/[/QUOTE] I meant 32-bit integer, of course. [QUOTE=esalaka;31395764]Although most of the functions have counterparts that accept a length argument.[/QUOTE] It's kind of kludged on there. Mixing the functions that do accept integer stuff with the functions that don't just feels wrong. Everything about strings in C is gross. It's better just to bypass or hide that entire mess as much as possible.
Lots of the old stuff has been deprecated, at least as of C1x, I think. [editline]29th July 2011[/editline] [QUOTE=ROBO_DONUT;31395918]I meant 32-bit integer, of course.[/QUOTE] Back when they invented C? On PDP-11?
[QUOTE=esalaka;31395944]Lots of the old stuff has been deprecated, at least as of C1x, I think. [editline]29th July 2011[/editline] Back when they invented C? On PDP-11?[/QUOTE] However many bits a long is. 16-bits is still plenty.
This is a fairly general question for C# and XNA.. I'm going to write a little basic isometric engine just to learn some new things, but the only part I'm not yet sure how to do is handle the depth. Basically, when drawing with SpriteBatches how do you draw different sprites at certain depths depending on, in this case, their y position? At the moment in my main drawing loop the depth of all each type of object is just set by what order they're drawn in, so for example all my bullets are drawn first, then all the enemies, then the player. Is there a fairly simple way of drawing each individual thing at a different depth? Sorry I'm not being all that clear but I'm struggling to think it through myself. I've just noticed the drawing call in the classes for each object contains a "float depth" argument and so I've tried changing it about with a simple tds project I've been working on but it doesn't seem to be having any effect.. but seeing as that is what's called each time I draw whatever object this seems like the way to approach having each object on screen of the same class with different depths, just change that argument to "-Position.Y" or whatever. Should this work? And a final point, if that's how the float depth works, does the order in which I call the draws matter? Say for example I loop through my enemies to draw them all, then draw the player, if the enemies have a higher depth will they be drawn on top of the player, or because the player is drawn afterwards will it not work how I want it to? I really need to look into how SpriteBatches work properly, I think! Thanks for any help.
I've been meaning to learn a programming language for some time along with 3D modeling so I came up with the idea of making a game. I have the basic idea of the game I just need help with the programming. How would I go about making a game engine? (what language should I learn) But if making my own engine is too hard (which I presume it is since it should look pretty decent) what existing engines are good and what languages do I need to learn to make a simple game in them. Off the top of my head I can think of the source and unreal engine. If you guys could point me in the right direction i'll be very greatful (it's going to be a 3D FPS game by the way)
[QUOTE=Goodthief;31408089]How would I go about making a game engine? (what language should I learn) But if making my own engine is too hard (which I presume it is since it should look pretty decent) what existing engines are good and what languages do I need to learn to make a simple game in them. —— (it's going to be a 3D FPS game by the way)[/QUOTE] First of all: No, you can't make a 3D FPS when you barely can program. Secondly, don't make a goddamn engine. Make a game.
[QUOTE=esalaka;31408141]First of all: No, you can't make a 3D FPS when you barely can program. Secondly, don't make a goddamn engine. Make a game.[/QUOTE] Sorry let me rephrase that, I would like to work my way up to an FPS so to get started what language should I learn? [editline]29th July 2011[/editline] after reading up a bit, C# and python seem to be the most recommended. which seems to be better in your opinion? I've learned actionscript 2 for about a year if that helps
Look them up on the internet and choose whatever feels more comfortable to you. If you still can't decide, I think there are more people knowing C# in this forum, so if you wanna look for some help here C# might be a tip better. Though I don't know Python and I was still able to help some people by just taking a quick look at its documentation and transferring my knowledge from the languages I do know.
[QUOTE=ZeekyHBomb;31408520]Look them up on the internet and choose whatever feels more comfortable to you. If you still can't decide, I think there are more people knowing C# in this forum, so if you wanna look for some help here C# might be a tip better. Though I don't know Python and I was still able to help some people by just taking a quick look at its documentation and transferring my knowledge from the languages I do know.[/QUOTE] Ok thanks I'll try out c# since I'll get the most help. I'm sorry about the frustration I caused since a quick look into this section after I asked my question revealed hundreds of people wondering the same thing.
How would I make it so that the screen area always remains at 16:9? So if the user stretched the window thin but tall, black bits would appear at the top and bottom to keep it at 16:9 and not stretch it to the size of the window?
Like the thing dlaor made? PM him
Okay, I'm really confused about this one thing. I have a pretty good understanding of classes so far, but the tutorial I'm following is doing this weird thing that modifies I think the #include of <ostream> in order to make cout able to print several values at once? I'm not sure how it works exactly. Could someone give me a break down of the parts and such? [code] ostream &operator <<(ostream &stream, Point &p) { stream << p.getX() << " " << p.getY() << " " << p.getZ(); return stream; } void main() { Point john(1, 2, 3); cout << john << endl; } [/code] There's already a class called Point defined earlier in the code, but it's a lot of code and I don't want to stretch the page. How exactly does this work? Does it simply modify the cout operator/function thing in order to change the way it handles console output? And does &operator refer to something in the #include <ostream>? Same as &stream? Also, apparently it's known as overloading a functionality, if that helps anyone figure out what I'm talking about.
I have a problem. I'm programming OpenGL/C++/Windows 7/Code::Blocks, and I made a "Displacement" class, which generates a flat mesh and then applies perlin noise for vertex height so it becomes a landscape, and then calculates normals for itself. I can make it generate a mesh of 128x256 or smaller, but if I try say 256x256, the program crashes 9/10 times. Why does that happen? Is there a limit to memory allocated at a time, or is it because calculations take too long? tl;dr: When I generate a mesh of 65k verticles, program crashes with a generic memory access violation.
RiceWarrior, It's called operator overloading. When you overload the << operator, you need to pass it the stream it is using, along with whatever it is being operated on. So with your's, it is operating on a Point object. So when you use the operator with the point object, like the code "cout << john << endl;" does, then it uses the overloaded operator function to determine what to do with it. So in your case, it just prints out the X, Y, and Z of that point. [URL="http://www.cprogramming.com/tutorial/operator_overloading.html"]This[/URL] might help you out more.
[QUOTE=Nikita;31413010]I have a problem. I'm programming OpenGL/C++/Windows 7/Code::Blocks, and I made a "Displacement" class, which generates a flat mesh and then applies perlin noise for vertex height so it becomes a landscape, and then calculates normals for itself. I can make it generate a mesh of 128x256 or smaller, but if I try say 256x256, the program crashes 9/10 times. Why does that happen? Is there a limit to memory allocated at a time, or is it because calculations take too long? tl;dr: When I generate a mesh of 65k verticles, program crashes with a generic memory access violation.[/QUOTE] I'm assuming that you have a somewhat modern computer, so 65k * 3 * 32bit should not be a problem - it's not even 1MB. You should just debug it, to see where it fails. And also check at which address it fails; if it's very close to 0, then you're probably accessing a NULL-pointer somewhere.
Im trying to make a program so I can draw with my mouse, now, I am drawing the pixels with a 1x1 image, since drawing images is easier then creating a pixel in XNA, I worked out how to do something when the mousebutton is pressed. My problem is that when I click, and the image appears, it doesn't stay, it should keep putting the image on the screen, without removing it. Now it's just a pixel moving with my mouse. My code: [cpp] if (leftPressed) { spriteBatch.Draw(r1, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.White); }[/cpp]
[QUOTE=Staneh;31416165]Im trying to make a program so I can draw with my mouse, now, I am drawing the pixels with a 1x1 image, since drawing images is easier then creating a pixel in XNA, I worked out how to do something when the mousebutton is pressed. My problem is that when I click, and the image appears, it doesn't stay, it should keep putting the image on the screen, without removing it. Now it's just a pixel moving with my mouse. My code: [cpp] if (leftPressed) { spriteBatch.Draw(r1, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.White); }[/cpp][/QUOTE] Drawing an image for each pixel(i would think) is much less inefficient. Have an array of pixels.
I've never worked with arrays, and I have no idea how to work with them, any help perhaps?
Google <Language> array tutorial. Search one with fancy pictures of the memory.
What books can I read to learn Database programming with C++?
Sorry, you need to Log In to post a reply to this thread.