• What Are You Working On? - December 2014
    1,204 replies, posted
[QUOTE=thrawn2787;46656316]fyi var is type safe. If it wasn't there wouldn't be a difference between var and object. var in C# is not the same var in JavaScript, which isn't type safe. The type of var is the compile time type of the right hand sideof the assignment. That is why you have to initialize a var when you declare it. AKA this is illegal: [code] var myVar; [/code] The purpose of var is this: [code] List<List<SomeVeryLongName<SomeGernic>>> GetLongNamedVar() { //... } void Foo() { // long line to declare a variable with this type List<List<SomeVeryLongName<SomeGernic>>> myThing = GetLongNamedVar(); // Declaring a variable with the SAME TYPE but saves space var myVar = GetLonNamedVar(); // the type of myVar is now List<List<SomeVeryLongName<SomeGernic>>>, so it is completely type safe and saved me some space } [/code] That being said I never use it. It is clearer to a programmer looking at the code what the type is if you explicitly state it.[/QUOTE] And if the type is really very long, you could always use a 'using' directive (though I think it only works within the scope of a source file).
[QUOTE=thrawn2787;46656316]That being said I never use it. It is clearer to a programmer looking at the code what the type is if you explicitly state it.[/QUOTE] Var is good for "Type t = new Type()" statements. Kills redundancy.
[QUOTE=Cold;46655959]Fuck no. Why would you prefix the gross of variables? And when is the last time you saw somebody do. [cpp] for(int _i = 0; _i < _length;_i++) [/cpp][/QUOTE] I use _ for stuff like iterators etc. [code] int _i; for(i = 0; i < something.length; i++) {}[/code]
[QUOTE=Mega1mpact;46656442]I use _ for stuff like iterators etc. [code] int _i; for(i = 0; i < something.length; i++) {}[/code][/QUOTE] You're so used to prefixing iterators with an _, that your second line straight up doesn't do it.
How is this whole variable naming argument any better than the tab vs. spaces debate? And isn't the answer the same, anyway? Be consistent and keep things readable. That's all that matters.
[QUOTE=Larikang;46656757]How is this whole variable naming argument any better than the tab vs. spaces debate? And isn't the answer the same, anyway? Be consistent and keep things readable. That's all that matters.[/QUOTE] Now, now, if we're ever going to get anywhere in productivity, we have to decide once and for all who is right about these totally not personal preferences.
[IMG]http://i.imgur.com/kh8VbAx.gif[/IMG]
[QUOTE=Eric95;46657008][IMG]http://i.imgur.com/kh8VbAx.gif[/IMG][/QUOTE] I don't even know what the game is about but this character is adorable as hell
Why so sad tho
[QUOTE=thrawn2787;46656316]That being said I never use it. It is clearer to a programmer looking at the code what the type is if you explicitly state it.[/QUOTE] It's basically equivalent to "auto" in C++11, but in C++ the recommended style is to use auto wherever possible. Especially anywhere the type is obvious (iterators) or irrelevant (size of an int, type of container, etc). And if you name your functions and variables properly then you should be able to know what the type is. But really in general C++ is moving to completely different style from C and most C-derived languages, so you shouldn't apply C++ style to them.
[QUOTE=ECrownofFire;46657405]It's basically equivalent to "auto" in C++11, but in C++ the recommended style is to use auto wherever possible. Especially anywhere the type is obvious (iterators) or irrelevant (size of an int, type of container, etc). And if you name your functions and variables properly then you should be able to know what the type is. But really in general C++ is moving to completely different style from C and most C-derived languages, so you shouldn't apply C++ style to them.[/QUOTE] I am lazy so i only use auto when the full name is soo long, that i can't be arsed to type it out.
[QUOTE=paul simon;46657237]Why so sad tho[/QUOTE] The name of the game is apparently "make babies" Maybe she don't want one
the name of the company is makebabi.es, not the game
of course, there's an exception to all rules. And for identifier cases, that exception is most dialects of BASIC, which aren't case sensitive, so those of us BASIC hobbyists (known as BASIC Bitches) normally write everything in all caps, so: CONST SOMEVARIABLE = 22 DIM ANOTHERVARIABLE AS INTEGER = 22 DIM AS INTEGER SOMETIMES_YOU_USE_UNDERSCORES = 50; DIM AS INTEGER SOMETIMESTHOUGHYOUDONTIDK DIM AS STRING CAPS DIM AS STRING CAAAAAAAAPS DIM AS STRING CAAAAA_AAAAAPS
Whipped up a basic RTS scene today in unity [url]https://dl.dropboxusercontent.com/u/96502721/S/2014-12-06-2131-55.mp4[/url] Might keep working on it, kinda fun.
[QUOTE=proboardslol;46658073]of course, there's an exception to all rules. And for identifier cases, that exception is most dialects of BASIC, which aren't case sensitive, so those of us [B]BASIC hobbyists[/B] (known as BASIC Bitches) normally write everything in all caps, so:[/QUOTE] But isn't a hobby something you do for fun?
[img]http://i.hizliresim.com/Q4glMV.png[/img] :) [editline]7th December 2014[/editline] also slack is fantastic for group chats! [editline]7th December 2014[/editline] weve gained 100 stars on the rant repo since we put it on hn
[QUOTE=/dev/sda1;46658701] also slack is fantastic for group chats![/QUOTE] you should tell blk this
[QUOTE=Cold;46656677]You're so used to prefixing iterators with an _, that your second line straight up doesn't do it.[/QUOTE] It's was 2 am. It's something I only started doing a couple of weeks ago due to coding standards at work. I like it tho.
Coding convention standards change depending on the language and company - or even projects sometimes. It's kinda hard finding a common ground, the most important thing is consistency (even though there might be an actual convention format, like in Java, many companies still do their own for various reasons, e.g. Google)
I am still working on how to get the .exe directory in C++ Fuck, this is insanely difficult to me, I keep getting violations and shit and I have no idea why. In C# there was just environement.currentdirectory or something like that, here you have to convert from LPWSTR and use modeuls that crash your program because the instructions and code examples i find give me compiler errors (even though i include the libraries they do and copy the code wholly unedited) I think I will go insane.
[QUOTE=Contron;46635369][code] public string Property { get; set; } [/code] [code] public string Property { get { return this.property; } set { this.property = value; } } private string property; [/code][/QUOTE] Late by centuries, but there is a little neat thing: [code]public string Property { get; private set; }[/code]
[QUOTE=ichiman94;46659825]Late by centuries, but there is a little neat thing: [code]public string Property { get; private set; }[/code][/QUOTE] I also use this :)
I'm still improving the A.I I added the ability to jump to the pathfinding. It is now my standart movement script, so my enemies won't navigate with the old one anymore. When enemies hear a sound, now the one closest to it will walk to it and currently he stays there for 10 seconds and returns to his spawn location. (I still need to add a search behaviour.) [video=youtube;_1H9Kk3heAg]http://www.youtube.com/watch?v=_1H9Kk3heAg[/video]
[QUOTE=ichiman94;46659825]Late by centuries, but there is a little neat thing: [code]public string Property { get; private set; }[/code][/QUOTE] I'd only found this out very recently too, because I was wondering how you'd do read-only properties but still able to modify them within the class itself. Thanks though!
[QUOTE=Fatfatfatty;46659761]I am still working on how to get the .exe directory in C++Fuck, this is insanely difficult to me, I keep getting violations and shit and I have no idea why. In C# there was just environement.currentdirectory or something like that, here you have to convert from LPWSTR and use modeuls that crash your program because the instructions and code examples i find give me compiler errors (even though i include the libraries they do and copy the code wholly unedited)I think I will go insane.[/QUOTE] The first argument of main will be your executable.[code]#include int main(int argc, char** argv){ std::cout
[URL="http://facepunch.com/showthread.php?t=1440738"]This should be good, heh.[/URL]
[img]http://i.imgur.com/ySvO4an.png[/img] Finally! (this time without using freetype, but with C#'s built in Graphics) Now if only when i made the window fullscreen borderless, OpenTK didn't make the viewport a bit smaller than the client size.
[QUOTE=Fatfatfatty;46659761]I am still working on how to get the .exe directory in C++ Fuck, this is insanely difficult to me, I keep getting violations and shit and I have no idea why. In C# there was just environement.currentdirectory or something like that, here you have to convert from LPWSTR and use modeuls that crash your program because the instructions and code examples i find give me compiler errors (even though i include the libraries they do and copy the code wholly unedited) I think I will go insane.[/QUOTE] [cpp] int main(int argc, char** argv) { std::string exe = argv[0]; std::string path = exe.substr(0, exe.rfind('\')); } [/cpp] Obviously you'll want to use / instead of \ on any non-Windows platform.
[QUOTE=ECrownofFire;46660628][cpp] int main(int argc, char** argv) { std::string exe = argv[0]; std::string path = exe.substr(0, exe.rfind('\')); } [/cpp] Obviously you'll want to use / instead of \ on any non-Windows platform.[/QUOTE] If I recall correctly, that won't always work. To get the directory for the exe you have to use some platform specific code, for example I have the following for Win32. [CODE] std::string GetParentDirectory(const std::string& path) { size_t pos = path.find_last_of("\\/"); return (std::string::npos == pos) ? "" : path.substr(0, pos); } std::string GetApplicationDirectory() { TCHAR buffer[MAX_PATH]; GetModuleFileName(nullptr, buffer, MAX_PATH); return GetParentDirectory(std::string(buffer)); } [/CODE] [url]http://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe/1024937#1024937[/url] covers most platforms.
Sorry, you need to Log In to post a reply to this thread.