• What are you working on? V7
    2,001 replies, posted
[IMG]http://i17.photobucket.com/albums/b93/tezzanator/OpenST-Soom.png[/IMG] Mixer :D Porting this thing to XNA from using SFML has been a big improvement in speed and code readability - the audio subsystem is great.
[QUOTE=ProboardslolV2;20005642]DNS Flusher [cpp]#include <stdio.h> int main() { char answer; ask: printf("This will reset your connection and flush your DNS cache. Continue?\n[Y or N])? "); scanf("%c",&answer); if (answer =='y' && answer == 'Y') { goto exec; } else if (answer == 'n' && answer == 'N') { return(0); } else if (answer != 'y' && answer != 'Y' && answer != 'n' && answer != 'N') { goto error; } error: printf("You must answer [Y or N]\n"); goto ask; exec: system("path = c:\\windows\\system32"); system("ipconfig/release"); system("ipconfig/flushdns"); system("ipconfig/renew"); return(0); } [/cpp][/QUOTE] (answer == 'a' && answer == 'A') will always be false, it can't be both a [i]and[/i] A.
[QUOTE=ThePuska;20007318](answer == 'a' && answer == 'A') will always be false, it can't be both a [i]and[/i] A.[/QUOTE] TBH the whole thing should probably be a Switch with cases for each possible answer and what he wants to do.
[QUOTE=Robber;20006521]You should never use goto if you don't absolutely have to (=never).[/QUOTE] That's a lie. In this case, you're right though.
[QUOTE=CarlBooth;20007399]TBH the whole thing should probably be a Switch with cases for each possible answer and what he wants to do.[/QUOTE] Switch with strings sounds like a bad idea to me edit: Re-read the code, yes the answer is a char, my bad
[QUOTE=gparent;20007482]That's a lie. In this case, you're right though.[/QUOTE] Not trying to argue, I'm just curious: When could you possibly need it?
I'm starting some work on a (really really) simple mechanics simulator. What I wanted to do is do a base class called something like physObj which has all the position, velocity and forces being applied, as well as methods to change the forces and to get velocity and position on the X and Y axis (this is all 2D for now for simplicity's sake). I have, however, I doubt as I'm quite new to C++, what would be the best practice, declaring the class and methods on physObj.hpp and them implementing them on physObj.cpp which is included by main.cpp? Or should I just delcare them in physObj.hpp and implement in main.cpp? Or am I way off? Thanks in advance.
Declare classes and methods in physObj.hpp, implement them in physObj.cpp and include physObj.hpp in main.cpp.
[QUOTE=NullPoint;20008304]Declare classes and methods in physObj.hpp, implement them in physObj.cpp and include physObj.hpp in main.cpp.[/QUOTE] Ok thank you :) I assume the compiler will automatically know that if something's delcared in X.hpp then X.cpp is to be included?
AFAIK the compiler doesn't know whether or not class/method decelerations have been implemented, this is the linkers job. I think the linker merges the object files that are generated by the compiler.
[QUOTE=NullPoint;20008551]AFAIK the compiler doesn't know whether or not class/method decelerations have been implemented, this is the linkers job. I think the linker merges the object files that are generated by the compiler.[/QUOTE] Ah ok. Compiler, linker, all mixed up in a fresh from interpreted languages person :P Anyway, this got off topic, sorry. Thanks again.
[QUOTE=Robber;20008140]Not trying to argue, I'm just curious: When could you possibly need it?[/QUOTE] You never "need" it. It just makes code a lot easier to read under the right circumstances. In this thread, though, it just made the code more confusing, so that's why I said that your sentence was incorrect, but that the general point was correct. :) [QUOTE=grlira;20008268]I have, however, I doubt as I'm quite new to C++, what would be the best practice, declaring the class and methods on physObj.hpp and them implementing them on physObj.cpp which is included by main.cpp?[/QUOTE] Don't take this wrongly, because I know it's not very obvious when you start C++, but those terms can get a bit confusing, so here are the right ones: class C; // This is a class DECLARATION class C { void foo(); } // This is a class DEFINITION, and "void foo();" is a function DECLARATION. void C::foo() { std::cout << "Hai!"; } // This is a function DEFINITION. "implement" isn't a word used in C++. This won't matter when you're talking casually ("I implemented foo() this way:"), but when you're asking specific questions about includes, it matters :P Now, I didn't define all of this for you just to prove you wrong, but simply to make the following more clear: Class definitions should be in a header file ("C.hpp"). That header file should also include any other file necessary for the [i]definition of the [b]class[/b][/i] to compile properly. This means that if we use the example above, in "C.hpp" you would have [b]no[/b] includes, only header guards. In [b]C.cpp[/b], you would #include "C.hpp", as well as <iostream>, because C::foo() uses std::cout. But you shouldn't include iostream in "C.hpp", because it's not needed there. [quote]Ok thank you :) I assume the compiler will automatically know that if something's delcared in X.hpp then X.cpp is to be included? [/quote] This is even more complicated. The compiler just compiles every .cpp file. It doesn't need to compile header files, as when you include them, they are basically copy pasted in the .cpp files. I explained why C++ needs headers here, as well as how C++ figures out how to call functions from different .cpp files: [url]http://www.facepunch.com/showpost.php?p=19899115&postcount=16[/url] If you have more questions, let me know.
hourly progress dump! [img]http://www.cubeupload.com/files/914400treenew3.png[/img] [img]http://www.cubeupload.com/files/ed1e00treenew32.png[/img] probably not going to add anything further to it, the code is getting really horrendous :p
Makes me wanna start coding a tree grower thing!
[QUOTE=garry;20009647]Makes me wanna start coding a tree grower thing![/QUOTE] That would be so cool.
A bunch of shit at the moment.
[QUOTE=BAZ;20009548]hourly progress dump! *trees* probably not going to add anything further to it, the code is getting really horrendous :p[/QUOTE] Now write a treehouse generator.
Those trees look mighty fancy. Any chance you'll do a fun little release for us so that we can grow our own trees? Also.. been having programming class at school for a few weeks now. We are still working with VB.. it's so boring but I guess I'll have to sit it through. It doesn't feel like programming, everything is already done for you. [code]Userform1.BackColor = vbRed[/code] To make the program change it's current window color. It feels like I'm just sitting with I/O's in Hammer where you also just use preset commands. [editline]10:20PM[/editline] [QUOTE=garry;20009647]Makes me wanna start coding a tree grower thing![/QUOTE] Add a tree grower to Botch! (Or whatever the name of your engine is, never really got the name I'm afraid.)
Wasted a good day getting shadow mapping using [URL="http://www.punkuser.net/vsm/"]VSM[/URL].. There's some artifacts but it's better than it was.. [img]http://dl.dropbox.com/u/3590255/Screenshots/Botch/03Feb2010_005.png[/img] [img]http://dl.dropbox.com/u/3590255/Screenshots/Botch/03Feb2010_004.png[/img]
How long have you been working on this engine now Garry? - It's shaping up to something quite incredible, makes me feel like crap. I try and I try but I'm just not good enough :D
That engine is looking great, hows the performance right now?
Performance is lowish in the editor - because of the font rendering, so it isn't unknown to go as low as 60fps. In game those scenes are 200fps+ (but I need to fix a bug with brush rendering that should double that)
[QUOTE=Robber;20008140]Not trying to argue, I'm just curious: When could you possibly need it?[/QUOTE] When you're programming in Fortran.
t garry make engine open (tools/api at least) please thanks in advance
Garry, I know this sounds like a dumb question, but on a scale of 1/10 how hard is it to code.
You're right, It did sound like a dumb question.
[QUOTE=gparent;20009099]You never "need" it. It just makes code a lot easier to read under the right circumstances. In this thread, though, it just made the code more confusing, so that's why I said that your sentence was incorrect, but that the general point was correct. :) Don't take this wrongly, because I know it's not very obvious when you start C++, but those terms can get a bit confusing, so here are the right ones: class C; // This is a class DECLARATION class C { void foo(); } // This is a class DEFINITION, and "void foo();" is a function DECLARATION. void C::foo() { std::cout << "Hai!"; } // This is a function DEFINITION. "implement" isn't a word used in C++. This won't matter when you're talking casually ("I implemented foo() this way:"), but when you're asking specific questions about includes, it matters :P Now, I didn't define all of this for you just to prove you wrong, but simply to make the following more clear: Class definitions should be in a header file ("C.hpp"). That header file should also include any other file necessary for the [I]definition of the [B]class[/B][/I] to compile properly. This means that if we use the example above, in "C.hpp" you would have [B]no[/B] includes, only header guards. In [B]C.cpp[/B], you would #include "C.hpp", as well as <iostream>, because C::foo() uses std::cout. But you shouldn't include iostream in "C.hpp", because it's not needed there. This is even more complicated. The compiler just compiles every .cpp file. It doesn't need to compile header files, as when you include them, they are basically copy pasted in the .cpp files. I explained why C++ needs headers here, as well as how C++ figures out how to call functions from different .cpp files: [URL]http://www.facepunch.com/showpost.php?p=19899115&postcount=16[/URL] If you have more questions, let me know.[/QUOTE] Hey thanks, that was very helpful :) So anyway, I got a little further, I can simulate a particle's movement when a force F(X,Y) is applied on it atm. Struggling with controls now, and going to get some way to input the initial velocity position and force trough the command line instead of hard coding it into the program.
[QUOTE=dechristian;20013014]Garry, I know this sounds like a dumb question, but on a scale of 1/10 how hard is it to code.[/QUOTE] 10 for the likes of you
[QUOTE=Robber;20008140]Not trying to argue, I'm just curious: When could you possibly need it?[/QUOTE] It's a common C idiom to use goto's for resource management. [cpp] Data** doFoo() { Data** data = getData(); Data* it; for(it = data[0]; it != NULL; it++) { if(doBar(it) != 0) goto doFoo_error; if(doFoobar(it) != 0) goto doFoo_otherError; } return data; doFoo_otherError: otherStuff(data); doFoo_error: freeData(data); return NULL; }[/cpp] (Don't ever do this in C++; use RAII patterns instead.) Without using goto, you'd end up repeating yourself a lot and the cleanup code wouldn't be separate from the rest of the logic.
Got some more stuff done, scrolling of the background and the level entities (like question boxes) are working now. [media]http://www.youtube.com/watch?v=allejx8Nl50[/media] (Of course it doesn't scroll from left to right, as that isn't allowed in the early SM either) Right now I'm not sure how to continue. By that I mean what to do next. I'd either do a level saving format, proably with XML, or starting to work on enemies. The first seems more important to me, so I probably do that.
Sorry, you need to Log In to post a reply to this thread.