It's codeproject and vb.net, but you should be able to get some information out of it:
[url]http://www.codeproject.com/Articles/15280/Cryptography-for-the-NET-Framework[/url]
If this isn't the proper place for a post like this, I'm sorry.
I'd like to expand my coding knowledge away from just Lua bits that I know and head towards Java. From what I could gather, it seems like getting to know C++ is a great advantage before it, so my question is what resources I could use to help me accomplish this goal.
[editline]10th July 2014[/editline]
Also, I did plan to pickup a book on it, when I could afford it. Any suggestions on which one?
-figured it out-
I'm trying to write a very small program (I've just started learning) and I want a random number generator between 1 and 10 to use in an if-then statement. I'm using [B]C[/B]
I've tried
int foo = rand();
However every time I run the program, I only get 42. Every single time. Help would be greatly appreciated.
[QUOTE=TheClayMan;45354272]I'm trying to write a very small program (I've just started learning) and I want a random number generator between 1 and 10 to use in an if-then statement. I'm using [B]C[/B]
I've tried
int foo = rand();
However every time I run the program, I only get 42. Every single time. Help would be greatly appreciated.[/QUOTE]
Random numbers generated by a computer are not truly random. Instead, you are given a sequence of numbers that appear random and here's the thing; that sequence is the same every single time. The key is in a starting condition known as the 'seed.' If you seed the sequence with a different number every time your program starts up, the sequence of numbers that rand() returns will be different each time. A very common idea is to seed with the current time:
[code]srand(time(0));
int foo = rand();[/code]
[QUOTE=BackwardSpy;45354514]Random numbers generated by a computer are not truly random. Instead, you are given a sequence of numbers that appear random and here's the thing; that sequence is the same every single time. The key is in a starting condition known as the 'seed.' If you seed the sequence with a different number every time your program starts up, the sequence of numbers that rand() returns will be different each time. A very common idea is to seed with the current time:
[code]srand(time(0));
int foo = rand();[/code][/QUOTE]
Sweet thanks man! How do I limit it to certain ranges? Such as 1-100 or 1-10? (Hell, even 0 - 1)
Do I have to seed for each random variable or just once?
In C++, what macro names should I be checking for debug/release configurations?
I'm probably just going to check if DEBUG is defined, but I'm pretty sure I've seen #ifndef NDEBUG and other similar names being used elsewhere..
Is there a standard, or which is the most common?
[QUOTE=TheClayMan;45354557]Sweet thanks man! How do I limit it to certain ranges? Such as 1-100 or 1-10? (Hell, even 0 - 1)
Do I have to seed for each random variable or just once?[/QUOTE]
Seed once.
The common-but-somewhat-wrong approach is to do "int foo = rand() % RANGE", so if RANGE if 3 you'll get integers 0-3. However, a problem arises in that if RANGE is not a power of 2 (or otherwise is a factor of RAND_MAX+1), then the distribution is uneven. This doesn't matter for simple tests, but you will probably want to use a "proper" method at some point.
Complications arise if you want negative numbers out of it, but there's no real reason to want them. If necessary you can subtract from whatever result rand() gives you.
[editline]10th July 2014[/editline]
[QUOTE=mechanarchy;45355124]In C++, what macro names should I be checking for debug/release configurations?
I'm probably just going to check if DEBUG is defined, but I'm pretty sure I've seen #ifndef NDEBUG and other similar names being used elsewhere..
Is there a standard, or which is the most common?[/QUOTE]
NDEBUG is used in standard C and C++ to control whether assert() is active or not. What you do for your own debugging methods is up to you, though using NDEBUG is quite common.
[QUOTE=Hugg;45349677]I am making application where I am generating files that are later to be analyzed by me on my server. I also want these files that are generated to be encrypted so that the user cannot tamper with them. Anyone know what I can do?[/QUOTE]
It's impossible to do this securely and the use case for this is questionable at best (unless you have a good explanation on why you'd want to trust the client machine).
That said, you can prevent people from reading existing files with public key cryptography. [URL="http://msdn.microsoft.com/en-us/library/as0w18af%28v=vs.110%29.aspx"]It's built into .NET since version 1.1.[/URL]
ok so i need some advice with the last portion i need to compare the original to the reversed number. However i cannot compare strings to integer. What could i possibly do to get my palindrome checking portion working.
[code]
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
int numA;
int numB;
cout << "enter first number to multiply" << endl;
cin >> numA;
cout << "enter second number to multiply" << endl;
cin >> numB;
int Tnum;
Tnum = numA * numB;
cout << "the total number of " << numA << " and " << numB << " is: " << Tnum << endl;
string ItoS; // string which will contain the result
ostringstream convert;
convert << Tnum; // insert the textual representation of 'Number' in the characters in the stream
ItoS = convert.str();
for(string::reverse_iterator git = ItoS.rbegin(); git != ItoS.rend(); ++git)
{
cout << *git;
}
if( ItoS == Tnum)
{
cout << Tnum << " is a palindrome" << endl;
}
else
{
cout << Tnum << " is not a palindrome" << endl;
}
return 0;
}
[/code]
code updated
-snip- I'm dumb.
[B]C question[/B]
I recently learned how to change the value of a variable using a pointer, but instead of changing the value to a different number manually, can I set the program to subtract or add to the value depending on different if-then statements?
[QUOTE=TheClayMan;45358148][B]C question[/B]
I recently learned how to change the value of a variable using a pointer, but instead of changing the value to a different number manually, can I set the program to subtract or add to the value depending on different if-then statements?[/QUOTE]
[URL="http://www.cprogramming.com/tutorial/function-pointers.html"]You can take pointers of functions[/URL], so you can assign a function that does that to a value pointer, then execute it later by calling it with the value pointer you want it to work on.
[QUOTE=TheClayMan;45358148][B]C question[/B]
I recently learned how to change the value of a variable using a pointer, but instead of changing the value to a different number manually, can I set the program to subtract or add to the value depending on different if-then statements?[/QUOTE]
To me it sounds like you want to do[cpp]int i = 1337;
int* pi = &i;
if (...)
*pi += 3; // add 3
else
*pi -= 3; // subtract 3[/cpp]
But sure, applying different functions is another way.
[editline]11th July 2014[/editline]
[QUOTE=confinedUser;45355820]ok so i need some advice with the last portion i need to compare the original to the reversed number. However i cannot compare strings to integer. What could i possibly do to get my palindrome checking portion working.
[code]
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
int numA;
int numB;
cout << "enter first number to multiply" << endl;
cin >> numA;
cout << "enter second number to multiply" << endl;
cin >> numB;
int Tnum;
Tnum = numA * numB;
cout << "the total number of " << numA << " and " << numB << " is: " << Tnum << endl;
string ItoS; // string which will contain the result
ostringstream convert;
convert << Tnum; // insert the textual representation of 'Number' in the characters in the stream
ItoS = convert.str();
for(string::reverse_iterator git = ItoS.rbegin(); git != ItoS.rend(); ++git)
{
cout << *git;
}
if( ItoS == Tnum)
{
cout << Tnum << " is a palindrome" << endl;
}
else
{
cout << Tnum << " is not a palindrome" << endl;
}
return 0;
}
[/code]
code updated[/QUOTE]
Convert the number into a string, then reverse the string into a second string. Then you can compoare both strings.
Quick question.
I have written a node-webkit program, which is open source, currently under MIT license.
However, after reading node-webkit's [URL="https://github.com/rogerwang/node-webkit/wiki/Using-MP3-%26-MP4-%28H.264%29-using-the--video--%26--audio--tags."]wiki[/URL], I think I have to switch to GPL if I want to use MP3 codec.
Is this correct? Can I use MIT for code, and GPL for releases? Because this codec is only bundled with release distribution of my app.
[QUOTE=Deseteral;45360137]Quick question.
I have written a node-webkit program, which is open source, currently under MIT license.
However, after reading node-webkit's [URL="https://github.com/rogerwang/node-webkit/wiki/Using-MP3-%26-MP4-%28H.264%29-using-the--video--%26--audio--tags."]wiki[/URL], I think I have to switch to GPL if I want to use MP3 codec.
Is this correct? Can I use MIT for code, and GPL for releases? Because this codec is only bundled with release distribution of my app.[/QUOTE]
Yes, that works. You still have to distribute the code under GPL but not necessarily exclusively so.
However, if your code requires those libraries publishing it under the MIT license is useless at best and misleading (as in tricking others into violating the GPL) at worst.
So, switching to GPL is the best and simplest way, right?
[QUOTE=Deseteral;45360679]So, switching to GPL is the best and simplest way, right?[/QUOTE]
Yes, if your code needs the GPL version of node-webkit.
If it doesn't then it depends on how much freedom you want to give to developers using your library.
So it depends, but the simplest way (for you) is switching to GPL.
Ok, thanks for help :)
Anyone knows about a .NET api to access cyborg gaming mice? Specifically the mmo7. I find the profile selector to be a bit cumbersome and archaic. Rather roll my own (just for asigning profiles)
The only program that i could find that does profile things, is the [url="cyborgautoprofiler.com/"]Cyborg auto profiles[/url] but the program is obfuscated.
The application that comes with it (to configure the profiles) uses Saitek.devices.dll (which the auto profiler also uses). But i can't seem to make sense of how to access the devices. It either asks for a guid or a link (as string) and i have no idea where to get these values from.
Anyone has a clue? I put the dll file on my dropbox if anyone wants to take a look: [url]https://dl.dropboxusercontent.com/u/4211946/Saitek.Devices.dll[/url]
[QUOTE=Kozmic;45350453]If this isn't the proper place for a post like this, I'm sorry.
I'd like to expand my coding knowledge away from just Lua bits that I know and head towards Java. From what I could gather, it seems like getting to know C++ is a great advantage before it, so my question is what resources I could use to help me accomplish this goal.
[editline]10th July 2014[/editline]
Also, I did plan to pickup a book on it, when I could afford it. Any suggestions on which one?[/QUOTE]
First of all this is the right place, and before you start learning multiple languages you might want to get one down solid.
There's no reason to learn some of C++ just to learn Java better, no lanugage knowledge is mutally exclusive. Learning one language sufficiently enough will give you experience with all languages.
What I recommend you do is find a project you want to do and see what language fits its purpose the best.
For example if you want to build real-life robots or embedded programming stuff you should learn C++, and can learn it here: [URL]http://www.cplusplus.com/doc/tutorial/[/URL]
If you want to program cool web based applications or websites you'll want to learn Javascript, sql, html, css, and php, which is probably best learned here: [URL]http://www.htmldog.com/[/URL]
If you want to make functional and useful applications you'll want to use Python, Lua, or Ruby, which have their own respective learning websites.
If you want to make video games you should stick with Love2D, it's incredibly powerful as long as you're not trying to do 3D stuff. You can learn Love2D here: [URL]http://www.love2d.org/wiki/Main_Page[/URL]
[editline]12th July 2014[/editline]
[QUOTE=mechanarchy;45355124]In C++, what macro names should I be checking for debug/release configurations?
I'm probably just going to check if DEBUG is defined, but I'm pretty sure I've seen #ifndef NDEBUG and other similar names being used elsewhere..
Is there a standard, or which is the most common?[/QUOTE]
Use whatever your build system uses, more often than not you get to decide what is set in your build system.
So no there really isn't a standard, just make sure you distribute your build system with your source code if you want other people to be able to compile it in debug mode properly.
Anybody have examples of a programmers CV? I just got my results and received my degree in Computer Science but I'm really not sure how to make a CV tailored for a programmer. Also I really don't think I know enough stuff to put it on a CV.
I mean I know Java and C# quite well, but in college we dabbled in everything. C, C++, MySQL, X86. Project wise I only really made a guitar tuner android app and made a Unity game with the Oculus Rift. In college we did some things like creating a basic compiler and some OpenGL stuff. I'm just stuck as to what I should and shouldn't include on a CV. Would appreciate any pointers
I've been on this problem for days: how to sort objects in a 2.5d game?
Here's basic sorting based on each object's y position:
[IMG]http://puu.sh/a9sXM/6ded4f4f8e.png[/IMG]
[IMG]http://puu.sh/a9sYA/09c36acd6c.png[/IMG]
[IMG]http://puu.sh/a9t2G/1fe31ef84d.gif[/IMG]
It works well in general but as you can see in the gif, if you can stand on top of objects then it breaks. This is because if you're standing on the object and you go over its y position, as it happens in the gif, it will get sorted to behind it (because that's what the sort is based on) and look wrong.
Some solutions I've tried include sorting based on the sprite's bottom y position instead of the collision boxes y position, but this also has problems:
[IMG]http://puu.sh/a9ta7/06684294d5.png[/IMG]
Because the table's sprite bottom y position is lower than the boxes', it gets drawn last, which hides the boxes behind the table when it should be above it. Another issue that comes up is when you jump:
[IMG]http://puu.sh/a9ted/da577a28a6.gif[/IMG]
Because the y bottom is higher, it gets sorted behind when it totally shouldn't. Using the y bottom doesn't generally work for this reason. Even trying to fix the box situation by taking the z height into account doesn't fix this particular issue presented by this gif.
Another solution I've tried is go back to using the normal y position of the object but then also take z into account. If z is higher than it should be drawn on top. But this presents another problem:
[IMG]http://puu.sh/a9tnf/535d8b1cba.png[/IMG]
Here since the box is on top of the table its z height is higher than the player's, so its drawn last, but obviously it looks wrong.
... Does anyone know how to fix this problem in a generic and possibly reasonable way? One solution that I think would work would be to divide objects up into multiple pieces, but I'm trying to avoid this unless it's impossible to find something else because it'd make everything a lot more complex.
Have you tried a combination of y and z? As in something like y+z. I'm not sure if that would work, but it's worth a try.
It seems like you want to take the previous order into account. There should be like a buffer zone where if you are between the top of the sprite and the object's actual y position you should retain the order. So as you walk off the table you are still above it, and then when you walk back down you are below it. I'm not sure how well that would work in the other examples.
You would probably also have to adjust the collisions in that case if you try to walk back down before you are completely off the table. Since you are still on the table you shouldn't collide with it.
You're trying to do 3D with 2D images, so do it the same way 3D does it. Get the distance from the object to the camera and use that for sorting.
Someone on another forum found a solution. For each object define an offset value and add that value to its y when sorting. For instance, the vertical table has an offset of -24, so whenever the sorting function is called all tables will have y - 24 as their true sort value, which means that whenever something is on top of that table, it will have to get to y - 24 until it's sorted behind the table. Pretty simple solution not sure how I didn't see it before.
[QUOTE=adnzzzzZ;45376357]Someone on another forum found a solution. For each object define an offset value and add that value to its y when sorting. For instance, the vertical table has an offset of -24, so whenever the sorting function is called all tables will have y - 24 as their true sort value, which means that whenever something is on top of that table, it will have to get to y - 24 until it's sorted behind the table. Pretty simple solution not sure how I didn't see it before.[/QUOTE]
Isn't that basically the same as just putting the origin at the bottom hind corner?
It's not going to work if you have stuff hanging over at the back side (like pushing the boxes farther up) but you can't do it properly without counting the depth per pixel or at least separating the two faces of each box object.
[QUOTE=Tamschi;45376681]Isn't that basically the same as just putting the origin at the bottom hind corner?
It's not going to work if you have stuff hanging over at the back side (like pushing the boxes farther up) but you can't do it properly without counting the depth per pixel or at least separating the two faces of each box object.[/QUOTE]
Yes, except this can't be done automatically because it doesn't usually match up to the sprites height. It's some weird relation that I don't understand between the collision box and the sprite. As for the other thing you said it seems to work well with all objects that are behind/front and almost behind:
[IMG]http://puu.sh/a9Bnr/49d90c0ea2.png[/IMG]
Is there any difference between this:
[cpp]enum class Type{
MODEL, LINE
};
Type type;[/cpp]
and this:
[cpp]enum class Type{
MODEL, LINE
}type;[/cpp]
This is a nested enum class btw.
[QUOTE=WTF Nuke;45377679]Is there any difference between this:
[cpp]enum class Type{
MODEL, LINE
};
Type type;[/cpp]
and this:
[cpp]enum class Type{
MODEL, LINE
}type;[/cpp]
This is a nested enum class btw.[/QUOTE]
No difference at all, except that with the second version you could do[cpp]enum class { // No type name
MODEL, LINE
}type;[/cpp]to have an anonymous type.
Sorry, you need to Log In to post a reply to this thread.