[QUOTE=sLysdal;27871048]WinInput.cpp in Lagrau
[cpp]
[/cpp]
[editline]5th February 2011[/editline]
And there are a lot of those functions
Sorry for making you scroll btw[/QUOTE]
why, why, why?
Put this poor source code out of its misery already
He also has this strange implementation of MD5
[cpp]long long Game::MD5_string (char *string){
char temp[256]="";
char temp2[256]="";
long long num=90814;
sprintf (temp, "%s",string);
int i=0;
while (i<256&&temp[i]!='\0'){
if(temp[i]%3==0)num+=temp[i]*124;
else if(temp[i]%3==1)num-=temp[i]*temp[i];
else num*=temp[i];
i++;
}
num=longlongabs(num);
if(num==0)num+=1452;
while(num<LONGLONGCONST(5000000000000000)){
num*=1.85421521;
}
while(num>LONGLONGCONST(9900000000000000)){
num/=1.235421521;
}
return num;
//return 1111111111111111;
}[/cpp]
[editline]5th February 2011[/editline]
[QUOTE=Jacko2007;27870828]Case statement[/QUOTE]
And in this case a switch would make the code less readable.
[QUOTE=Chris220;27869168]What's the difference between buying a "dev phone" and buying a normal android phone sim-free, and then rooting it?[/QUOTE]
Dev phones have supported usb drivers
[QUOTE=scizorownage;27871467]Dev phones have supported usb drivers[/QUOTE]
I plug in my HTC Desire HD, and I can run and debug on it fine, use ADB on it and all so that is not really a difference.
[QUOTE=nekosune;27871969]I plug in my HTC Desire HD, and I can run and debug on it fine, use ADB on it and all so that is not really a difference.[/QUOTE]
Pretty much this. I still can't see any advantage to having a developer phone over my current setup
[QUOTE=nekosune;27871969]I plug in my HTC Desire HD, and I can run and debug on it fine, use ADB on it and all so that is not really a difference.[/QUOTE]
Yeah I can run everything fine on my G2 with a simple edit of a usb driver file but some phones might work right away. It's really just that Google made drivers for those phones specifically. I agree though that there still isn't a point between a dev phone and regular.
[QUOTE=scizorownage;27872211]Yeah I can run everything fine on my G2 with a simple edit of a usb driver file but some phones might work right away. It's really just that Google made drivers for those phones specifically. I agree though that there still isn't a point between a dev phone and regular.[/QUOTE]
Didn't even need to edit any files for mine, I wonder why the G2 is different? also with the phones running the same OS, the drivers being made for that phone don't really matter, unless the vendor does some major changing, they all are identical to the driver.
[QUOTE=nekosune;27872227]Didn't even need to edit any files for mine, I wonder why the G2 is different? also with the phones running the same OS, the drivers being made for that phone don't really matter, unless the vendor does some major changing, they all are identical to the driver.[/QUOTE]
from [url=http://developer.android.com/guide/developing/device.html]here[/url] it looks like drivers are vendor specific
[QUOTE=scizorownage;27872298]from [url=http://developer.android.com/guide/developing/device.html]here[/url] it looks like drivers are vendor specific[/QUOTE]
Seems I was wrong, however it still seems to say that the drivers will include debugging ability, so the difference is negligible.
Brand spanking new 1TB Hard Drive...
I'm gonna miss you Hitachi 120gb :downs:
Found out that I can sell my XBLI Games now days, so I'm gonna set to work on a project... Finish it and get money, any game ideas?
[QUOTE=Overv;27871075]How do you even write [b]1018[/b] lines of that without realising at some point that there might be a better way to do it?[/QUOTE]
Fixed it, look in the WinInput.cpp i just posted a plug from it.
And MacInput.cpp is the same
I don't see how a dictionary would make it significantly better
You'd end up with a hundred lines of
[code]
dictionary.Add("A", KEY_A);
dictionary.Add("B", KEY_B);
[/code]
Which is almost as ugly as a hundred lines of
[code]
if (str == "A") { return KEY_A; }
else if (str == "B") { return KEY_B; }
[/code]
[editline]5th February 2011[/editline]
It's just as much manual work to add all the keys (copypaste has been invented you know - you just need to edit the string and the key) and it performs almost equally well.
[QUOTE=ThePuska;27873065]I don't see how a dictionary would make it significantly better
You'd end up with a hundred lines of
[code]
dictionary.Add("A", KEY_A);
dictionary.Add("B", KEY_B);
[/code]
Which is almost as ugly as a hundred lines of
[code]
if (str == "A") { return KEY_A; }
else if (str == "B") { return KEY_B; }
[/code]
[editline]5th February 2011[/editline]
It's just as much manual work to add all the keys (copypaste has been invented you know - you just need to edit the string and the key) and it performs almost equally well.[/QUOTE]
Well, performance based, what do you think is fastest? 250 if statements or one dictionary lookup? and the dictionary works both ways, define once then you can get the enum of a char or the char of a enum
[editline]5th February 2011[/editline]
Also, he didn't use if else, only ifs
[QUOTE=ThePuska;27873065]I don't see how a dictionary would make it significantly better
You'd end up with a hundred lines of
[code]
dictionary.Add("A", KEY_A);
dictionary.Add("B", KEY_B);
[/code]
Which is almost as ugly as a hundred lines of
[code]
if (str == "A") { return KEY_A; }
else if (str == "B") { return KEY_B; }
[/code]
[editline]5th February 2011[/editline]
It's just as much manual work to add all the keys (copypaste has been invented you know - you just need to edit the string and the key) and it performs almost equally well.[/QUOTE]
Yes but when it runs, it is less work for the computer, as it only has to add them all once, then do a lookup for each, rather then potentially 25 if/thens for each letter.
[QUOTE=sLysdal;27873221]Well, performance based, what do you think is fastest? 250 if statements or one dictionary lookup?
[editline]5th February 2011[/editline]
Also, he didn't use if else, only ifs[/QUOTE]
Not all of the ifs are evaluated. Evaluation terminates as soon as one of them is a match, because the enum is returned immediately. That's also why it doesn't matter whether one uses ifs or else ifs.
I don't know how a dictionary works internally but I already mentioned that I believe they're almost equally fast. I'd assume that the ifs are insignificantly faster in this case.
[QUOTE=sLysdal;27873221]and the dictionary works both ways, define once then you can get the enum of a char or the char of a enum[/QUOTE]
A valid point.
[QUOTE=nekosune;27873271]Yes but when it runs, it is less work for the computer, as it only has to add them all once, then do a lookup for each, rather then potentially 25 if/thens for each letter.[/QUOTE]
That doesn't make any sense.
[QUOTE=ThePuska;27873534]
That doesn't make any sense.[/QUOTE]
The work to add those 25 letters to the dictionary, is done once, then all it has to do is look up from the map on each key press.
With if/then or cases, it has to each key press do up to 25 comparisons.
How do you think it finds the right key in the map/dictionary without using comparisons?
[QUOTE=ThePuska;27873678]How do you think it finds the right key in the map/dictionary without using comparisons?[/QUOTE]
[url]http://en.wikipedia.org/wiki/Self-balancing_binary_search_tree[/url]
std::map has O(log n) complexity when searching for an element, whereas if-else... pile would have O(n), I think.
Edit: O(log n) is faster than O(n)
[QUOTE=ThePuska;27873678]How do you think it finds the right key in the map/dictionary without using comparisons?[/QUOTE]
But it optimises them using a tree structure.
[QUOTE=ThePuska;27873678]How do you think it finds the right key in the map/dictionary without using comparisons?[/QUOTE]
O(log n) not O(n)
It seems that in C# a dictionary is indeed faster than if-spam.
10 million searches from a dictionary with 120 string entries (strings consisted of three letters) took 1031 milliseconds, compared to 7547 milliseconds for the equivalent if-comparisons.
edit: source: [url]http://pastebin.com/hYT0i5QG[/url]
It may be faster (At runtime), but obviously it wasn't a problem or he would have changed it (or the game would run like shit).
I've said it before and I'll say it again, if it does the job and doesn't drastically reduce your project's maintainability, do whatever's easiest. You know I've actually given up on projects over stupid shit like this? Trying to find the elegant way to do something while the easy, fast way is just staring me in the face. It's complete vanity, and bullshit.
[QUOTE=esalaka;27857758]>Supermarket Assault Rifle
>Hamster Grenade Launcher
Make a game around these [B]now[/B][/QUOTE]
Do want
[QUOTE=RyanDv3;27874201]It may be faster (At runtime), but obviously it wasn't a problem or he would have changed it (or the game would run like shit).
I've said it before and I'll say it again, if it does the job and doesn't drastically reduce your project's maintainability, do whatever's easiest. You know I've actually given up on projects over stupid shit like this? Trying to find the elegant way to do something while the easy, fast way is just staring me in the face. It's complete vanity, and bullshit.[/QUOTE]
With that attitude you'll keep writing shit code forever. You're supposed to get stuck when learning - that's what makes you better.
[QUOTE=RyanDv3;27874201]It may be faster (At runtime), but obviously it wasn't a problem or he would have changed it (or the game would run like shit).
I've said it before and I'll say it again, if it does the job and doesn't drastically reduce your project's maintainability, do whatever's easiest. You know I've actually given up on projects over stupid shit like this? Trying to find the elegant way to do something while the easy, fast way is just staring me in the face. It's complete vanity, and bullshit.[/QUOTE]
never have i read such a cringe-worthy post in waywo.
[QUOTE=Loli;27872723]Found out that I can sell my XBLI Games now days, so I'm gonna set to work on a project... Finish it and get money, any game ideas?[/QUOTE]
Same, need to get money for uni FAST
[QUOTE=RyanDv3;27874201]It may be faster (At runtime), but obviously it wasn't a problem or he would have changed it (or the game would run like shit).
I've said it before and I'll say it again, if it does the job and doesn't drastically reduce your project's maintainability, do whatever's easiest. You know I've actually given up on projects over stupid shit like this? Trying to find the elegant way to do something while the easy, fast way is just staring me in the face. It's complete vanity, and bullshit.[/QUOTE]
I agree but only up to a point. The code above is way past that point.
[QUOTE=ThePuska;27874157]It seems that in C# a dictionary is indeed faster than if-spam.
[/QUOTE]
C#'s Dictionary is a hash map, which is closer to O(1) than O(log n). SortedDictionary is O(log n)
Learning to compile java with the command line.
Edited: That was easy.
[cpp]compress(buffer, length);
decompress();[/cpp]
compress takes memory and compresses it using zlib. It then writes the output to a file named 'z'. I'm working on getting to to write the output to memory.
decompress is my makeshift decompressor, it loads 'z', decompresses it and writes to 'zd'.
[QUOTE=Richy19;27875114]Same, need to get money for uni FAST[/QUOTE]
If you're good the uni will give you a scholarship, or if you come from low income house you can get bursaries.
Sorry, you need to Log In to post a reply to this thread.