I think I got the gist of it, thanks. I will check in with the TA tomorrow about the other bugs.
Does anyone know of any free VS addon that provides code snippet functionality for C++
Ok so after getting SFML working decently I decided to go out and use some basic tutorial code to load a sprite and modify it however it doesn't contain code to scale it, so I worked it out myself, and I've utilized it below:
[code]
if (App.GetInput().IsKeyDown(sf::Key::RBracket)) Sprite.Scale(1.001f, 1.001f);
if (App.GetInput().IsKeyDown(sf::Key::LBracket)) Sprite.Scale(1.001f, 1.001f);
[/code]
My problem is on the second line, I have no idea how I do a float backwards (so the image downscales, instead of upscaling).
Can someone provide me info on how to do this I want to learn about this before moving to the next part of the tutorial?
So, I'm working on a encryption program, the main problem was: Where should I store the salt if I need it to decrypt the file, I wasn't comfortable with it being store in plain text, so I figured I could encrypt it with the plain key only then use it to decrypt the rest of the file.
The problem is: Symmetric algorithms only support a specified key size, and most likely the key I provide won't be exactly that size, how can I ensure that the key is of a valid size? I could use the Rfc2898DeriveBytes class but I can only use it if I provide a 8 bytes or bigger salt, and even if I provide a array of 0's or 1's it stills doesn't return the value I want.
Using C#.
[QUOTE=cdlink14;31462722]Ok so after getting SFML working decently I decided to go out and use some basic tutorial code to load a sprite and modify it however it doesn't contain code to scale it, so I worked it out myself, and I've utilized it below:
[code]
if (App.GetInput().IsKeyDown(sf::Key::RBracket)) Sprite.Scale(1.001f, 1.001f);
if (App.GetInput().IsKeyDown(sf::Key::LBracket)) Sprite.Scale(1.001f, 1.001f);
[/code]
My problem is on the second line, I have no idea how I do a float backwards (so the image downscales, instead of upscaling).
Can someone provide me info on how to do this I want to learn about this before moving to the next part of the tutorial?[/QUOTE]
Wait what? You mean like this? 0.99f
That should downsize it.
[QUOTE=thf;31464489]Wait what? You mean like this? 0.99f
That should downsize it.[/QUOTE]
I've tried that, but it just stays the same size.
Ahh wait it's working now. However if I do 0.1f the image just dissapears, any idea why?
[QUOTE=cdlink14;31464734]I've tried that, but it just stays the same size.
Ahh wait it's working now. However if I do 0.1f the image just dissapears, any idea why?[/QUOTE]
You're making it 10 times smaller every frame, so in a few frames it's smaller than a single pixel :v:
How can I change the text of multiple Windows.Forms.Labels in a non-newbie manner? I have 10 labels and want to change the text of all of these to the same thing, but Writing [I]label1.Text = x; label2.Text = x; label4.Text = x; etc.[/I] doesn't look too good, is there an way around this?
C# by the way :)
[QUOTE=Chris220;31465354]You're making it 10 times smaller every frame, so in a few frames it's smaller than a single pixel :v:[/QUOTE]
This, you could either scale it before the main loop or use SetScale() which is absolute instead of the relative Scale().
[QUOTE=Chris220;31465354]You're making it 10 times smaller every frame, so in a few frames it's smaller than a single pixel :v:[/QUOTE]
Ahhh thanks, I must seem like a real idiot to you haha. I'm very new to float points (that's what they're called right?) so I'm just managing to grip them.
[QUOTE=cdlink14;31466077]Ahhh thanks, I must seem like a real idiot to you haha. I'm very new to float points (that's what they're called right?) so I'm just managing to grip them.[/QUOTE]
Nah, everyone has to start somewhere! And almost, they're calling floating point numbers :)
So the LORD God said to the programmer, "Cursed are you above all other data types! You will lack reliable arithmetic and boolean operations all the scope of your lifetime."
Programmers are a data type? :S
typedef struct programmer { ... } programmer_t; and all that
I need help with classes in general, I understand them, but for some reason I can't figure out how to write them, I don't know where to start while writing them. If anyone happens to know some decent class tutorials that describe what each step does that would be nice.
For some reason can't figure out how to write them out and use them decently.
[QUOTE=TH3_L33T;31482580]I need help with classes in general, I understand them, but for some reason I can't figure out how to write them, I don't know where to start while writing them. If anyone happens to know some decent class tutorials that describe what each step does that would be nice.
For some reason can't figure out how to write them out and use them decently.[/QUOTE]
You have to know what you're going to write before you write it. Before you type it out, think about what the class will represent, get a vague idea of what variables you'll need, and the type of things you want to do with those variables and ones that are passed in as parameters to those specific methods.
You'll get better at it with practice, as with almost anything else. After you stop worrying about the implementation of classes, you'll start looking at larger design and how classes interact with one another. I don't have any specific tutorial I can give you, but think about writing classes like that.
Does anybody know of any cross-platform MySQL wrappers for C++, something that works and is maintained well would be ideal.
What is the best way to make a passthough:
Eg
[code]
This is what happens:
Full program(TCP) > Server
That is what I want to happen
Full Prigram(TCP) > My Program > Server
[/code]
Whats the best way to relay data in c#
Let the program send its data to localhost, port X, let your program listen for incoming data on localhost, port X and send to server.
[QUOTE=ZeekyHBomb;31492737]Let the program send its data to localhost, port X, let your program listen for incoming data on localhost, port X and send to server.[/QUOTE]
I know that bit :v:
I mean whats the best way to do it in c#. Im guessing threading it is a good idea or will it not make a diffrence?
[QUOTE=robmaister12;31482777]You have to know what you're going to write before you write it. Before you type it out, think about what the class will represent, get a vague idea of what variables you'll need, and the type of things you want to do with those variables and ones that are passed in as parameters to those specific methods.
You'll get better at it with practice, as with almost anything else. After you stop worrying about the implementation of classes, you'll start looking at larger design and how classes interact with one another. I don't have any specific tutorial I can give you, but think about writing classes like that.[/QUOTE]
Yeah, I get my idea before I write it, but i don't know how to start it, problem with the practice is, that I don't know where to start in the first place.
Would you know any classes that are easy to use from like beginner classes to more advanced classes?
[QUOTE=benjojo;31492816]I know that bit :v:
I mean whats the best way to do it in c#. Im guessing threading it is a good idea or will it not make a diffrence?[/QUOTE]
Well, if you want the UI to be responsive at all times, then you should not make blocking calls in the same thread as the UI thread for example.
I don't think there's any wrong way to do it, just go ahead and write some code; if you encounter problems, rethink your current approach or ask more specific questions here.
[QUOTE=TH3_L33T;31492841]Yeah, I get my idea before I write it, but i don't know how to start it, problem with the practice is, that I don't know where to start in the first place.
Would you know any classes that are easy to use from like beginner classes to more advanced classes?[/QUOTE]
Anywhere really. Anything you can use without much dependencies.
For example, if you were to write a Pong-clone, you could begin with the player-paddle, first making it draw, then making it move.
Then you could isolate the player-only code, create a paddle base-class and create an enemy-paddle without movement so far.
Then you could make the ball, draw it, move it, detect collisions and then make the enemy move.
Or you could do the ball first and then the paddle.
Then you could make a menu.
You could also have done the menu first, then the actual game.
Doesn't matter.
If you were to create, say a top-down shooter, then you probably wouldn't start with the weapons. First you'd do the player, because without the player the weapons are practically useless. And before that you'd probably do level-stuff, because the player will be put inside the world, though it wouldn't be a problem to do the player first, then add levels and then take care about putting the player inside the world and doing collisions there.
[cpp]
while (true)
{
try
{
Console.WriteLine("1");
data = sr.Read();
Console.WriteLine("1#1");
swc.Write(data);
Console.WriteLine("1#2");
}
catch (IOException)
{
break;
}
try
{
Console.WriteLine("2");
datac = src.Read();
Console.WriteLine("2#1");
sw.Write(datac);
Console.WriteLine("2#2");
}
catch (IOException)
{
break;
}
// ##################################
}
[/cpp]
Is there some way to check if there is data in a stream? Or will I have to do some threading?
ns = Network Stream
nsc = Network Stream for the client part
sw = StreamWriter
sr = StreamReader
Does C# have an available thing for streams?
Well I screwed up my program big time and I have to re-start it unfortunately. I am going at it much slower this time. My question is, when a token matches a char (S, E), how do I allow it to grab the next token, knowing that the next value after it, is an int such as 10 or 51? That is if it is possible. Luckily, I found out my segmentation errors came from all the NULL errors since the last printf prints out NULL.
[code]
tokenPtr = strtok(string, " "); //begin tokenizing string
while (tokenPtr != NULL){ //while there are still tokens left
printf("%s\n", tokenPtr);
if (strcmp(tokenPtr, "S") == 0 ){
tokenPtr = strtok(NULL, " ");
printf("Test for integer: %s\n", tokenPtr);
[/code]
I would greatly appreciate the help. I have spent several hours working and testing on the code. I made much more progress but here is when it stops for me. The TA was pretty useless. I had a feeling he did not want to help at all, kept saying he couldn't grade because it doesn't run. Did some bug checking but was all "well I can't help you there".
[QUOTE=benjojo;31494153][cpp]
while (true)
{
try
{
Console.WriteLine("1");
data = sr.Read();
Console.WriteLine("1#1");
swc.Write(data);
Console.WriteLine("1#2");
}
catch (IOException)
{
break;
}
try
{
Console.WriteLine("2");
datac = src.Read();
Console.WriteLine("2#1");
sw.Write(datac);
Console.WriteLine("2#2");
}
catch (IOException)
{
break;
}
// ##################################
}
[/cpp]
Is there some way to check if there is data in a stream? Or will I have to do some threading?
ns = Network Stream
nsc = Network Stream for the client part
sw = StreamWriter
sr = StreamReader[/QUOTE]
You can set the ReadTimeout of a Stream, so that it won't block long (or 0 probably works, too). [url=http://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream.length.aspx]NetworkStream.Length is currently not implemented[/url], but with the [url=http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx]sockets Available property[/url] you can look how much you can read without blocking.
Alternatively you can also use a Socket andcallbacks or something.
[QUOTE=Map in a box;31495099]Does C# have an available thing for streams?[/QUOTE]
[url=http://msdn.microsoft.com/en-us/library/system.io.stream.aspx]System.IO.Stream[/url]?
[editline]3rd August 2011[/editline]
[QUOTE=Datsun;31495241]Well I screwed up my program big time and I have to re-start it unfortunately. I am going at it much slower this time. My question is, when a token matches a char (S, E), how do I allow it to grab the next token, knowing that the next value after it, is an int such as 10 or 51? That is if it is possible. Luckily, I found out my segmentation errors came from all the NULL errors since the last printf prints out NULL.
[code]
tokenPtr = strtok(string, " "); //begin tokenizing string
while (tokenPtr != NULL){ //while there are still tokens left
printf("%s\n", tokenPtr);
if (strcmp(tokenPtr, "S") == 0 ){
tokenPtr = strtok(NULL, " ");
printf("Test for integer: %s\n", tokenPtr);
[/code]
I would greatly appreciate the help. I have spent several hours working and testing on the code. I made much more progress but here is when it stops for me. The TA was pretty useless. I had a feeling he did not want to help at all, kept saying he couldn't grade because it doesn't run. Did some bug checking but was all "well I can't help you there".[/QUOTE]
Just move the pointer further along the string.
C-String are just a pointer to continuous memory. Say you have the string
[cpp]const char *str = "Hello there";[/cpp]
It's like this in memory:
[code]Hello there0
^[/code]
The string itself is anywhere, but the pointer, represented as '^' is that the variable [i]str[/i] actually represents. The 0 is not the numeral 0, but the null-character (\0 in C).
If you wanted to skip the "Hello ", then you would move the pointer 6 to the right:
[cpp]str = str + 6;[/cpp]
[code]Hello there0
^[/code]
It's still a valid C-String, and if you were to pass it to printf, it'd print "there".
-Snip-
I got it fixed. I just hope getting into the link list part works now.
[url]http://pastebin.com/ZdvBarCX[/url]
Right after solving one issue
A new one happens.
If anyone can see anything dumb here
Please say.
If you can pass MC via this then its working...
The closer I get, the further I move away... :suicide:
Ah yes indeed, I should have looked into the documentation of strtok.
Well then, I don't see the problem.
[url]http://codepad.org/RqmkriKx[/url]
Would a basic interpreter need a tokenizer? (unrelated to zeek)
Sorry, you need to Log In to post a reply to this thread.