Well, you could easily put them in a different scope :)
I'd interpret the question like "Is it possible to make these a valid declaration?", since this is what tests usually ask for, but it is not wise to leave it to interpretation.
[QUOTE=ZeekyHBomb;23055042]Well, you could easily put them in a different scope :)
I'd interpret the question like "Is it possible to make these a valid declaration?", since this is what tests usually ask for, but it is not wise to leave it to interpretation.[/QUOTE]
Yeah but I really loathe interpreting questions. If there's even the slightest ambiguity I refuse to answer it, because if I answer it and the desired answer is different, then I have to waste time proving myself :v:
If i was doing particles I'd do this:
Emitter class
{
2 vectors of particles;
think(); // simply loops through each active particle and calls the corresponding functions.
}
Now looping through each particle from the bottom, assuming each of them has the same lifetime you can do something pretty simple here, you pop from the bottom of vector 1 when that particle is dead, and push it onto vector2. Now when you want to spawn a new particle you could keep a simple var holding how many inactive particles, but there's no looping whatsoever. You just pop the back particle off vector 2.
[QUOTE=ZeekyHBomb;23053447]Why don't you set the properties when spawning or keep a reference/pointer/something to that particle to set its properties right after spawning?
1) Lookup/Google sequential search.
2) Lookup/Google bubble search and check each possibility.
3) Lookup/Google sequential search (unless you already did due to question No. 1).
4) Lookup/Google the worst-case complexity of binary search and calculate the outcome.
5) Lookup/Google the average-case complexity of sequential search and calculate the outcome.
6) Why can you not answer that? (Tip: 2 are right)[/QUOTE]
thx man, especially for 4 and 5
What's the easiest way to render a teapot in OpenGL, it just struck me that a cube might not be ideal for playing with shaders :P
I found this [URL="http://www.opengl.org/resources/code/samples/redbook/teapots.c"]code in C[/URL] and translated it to OpenTK but I don't know how to duplicate
glutSolidTeapot(1.0);
since OpenTK doesn't wrap glut.
[quote=zeekyhbomb;23053707]wait, i just understood what you meant.
If you use a doubly linked list, then you could put the inactive ones at the end or something, so you just check if the last member is inactive, if so put him on the front and set its properties.[/quote]
[quote=jawalt;23055506]if i was doing particles i'd do this:
Emitter class
{
2 vectors of particles;
think(); // simply loops through each active particle and calls the corresponding functions.
}
now looping through each particle from the bottom, assuming each of them has the same lifetime you can do something pretty simple here, you pop from the bottom of vector 1 when that particle is dead, and push it onto vector2. Now when you want to spawn a new particle you could keep a simple var holding how many inactive particles, but there's no looping whatsoever. You just pop the back particle off vector 2.[/quote]
I'll try both of those methods. Thanks!
[QUOTE=Darwin226;23055964]What's the easiest way to render a teapot in OpenGL, it just struck me that a cube might not be ideal for playing with shaders :P
I found this [URL="http://www.opengl.org/resources/code/samples/redbook/teapots.c"]code in C[/URL] and translated it to OpenTK but I don't know how to duplicate
glutSolidTeapot(1.0);
since OpenTK doesn't wrap glut.[/QUOTE]
I think the easiest thing to do would be to implement a simple model loader (of something like Doom's .mdl format) and find a model of it: I expect they'll be free versions in pretty much any format you care to name.
I want to secure the connection from my client to the server using rsa but I can't figure out how to stop packets from being resent.
I was thinking about adding a timestamp but isn't that really easy to bypass?
In c++ Do you guys think it is wise to use universal or global variables? Or Should I just use pointers to do the same job?
[QUOTE=high;23058090]I want to secure the connection from my client to the server using rsa but I can't figure out how to stop packets from being resent.
I was thinking about adding a timestamp but isn't that really easy to bypass?[/QUOTE]
My knowledge about protocols is not extensive, however I think that UDP is a non-reliable protocol (packets are not automatically resent).
[QUOTE=Helpful stalker;23062962]In c++ Do you guys think it is wise to use universal or global variables? Or Should I just use pointers to do the same job?[/QUOTE]
Pointers do not in any way replace global variables.
It depends on the situation how you can work around that. If you post a small explanation on what you intend to do, then we can probably give you a more specific answer.
For now: Why can't you pass it to where you need it via function parameters and possibly a reference to that stored in the class?
what's a good online tut for C++ that's not cplusplus.com
God damn I can't for the life of me figure out how to install SFML with Code::Blocks. I might just do a complete reinstall of Code::Blocks and SFML to try and get things to work.
Is there some kind of download somewhere that has Code::Blocks pre-packaged with SFML?
[QUOTE=slayer20;23068381]God damn I can't for the life of me figure out how to install SFML with Code::Blocks. I might just do a complete reinstall of Code::Blocks and SFML to try and get things to work.
Is there some kind of download somewhere that has Code::Blocks pre-packaged with SFML?[/QUOTE]
Did you try following the Code::Blocks tutorial on the SFML website?
How do I make the pong paddle not stop for a second when I hit the other movement key?
code for movement:
[cpp]
// Movement to the right
if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::D))
{
player.SetX(player.GetPosition().x + 2 * SPEED_MUL);
}
// Movement to the left
if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::A))
{
player.SetX(player.GetPosition().x - 2 * SPEED_MUL);
}
[/cpp]
Video:
[media]http://www.youtube.com/watch?v=d-t-4veX4t0&fmt=22[/media]
[QUOTE=Meatmuppet;23066563]what's a good online tut for C++ that's not cplusplus.com[/QUOTE]
cplusplus.com is one of the best on the web, but [url=http://en.wikibooks.org/wiki/Subject:C%2B%2B_programming_language]Wikibooks[/url] has a couple.
-snip-
Learned about invokation and delegates. It works now. Thanks anyway
[QUOTE=raccoon12;23071898]How do I make the pong paddle not stop for a second when I hit the other movement key?
code for movement:
[cpp]
// Movement to the right
if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::D))
{
player.SetX(player.GetPosition().x + 2 * SPEED_MUL);
}
// Movement to the left
if((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::A))
{
player.SetX(player.GetPosition().x - 2 * SPEED_MUL);
}
[/cpp]
Video:
[media]http://www.youtube.com/watch?v=d-t-4veX4t0&fmt=22[/media][/QUOTE]
Firstly, don't do anything [B]except[/B] handling events in the event loop. It runs more than once per frame, hence why it's an event [I]loop[/I].
That [I]if(player.GetPosition.x[/I] stuff shouldn't be there.
Secondly, your movement is jerky and crappy (and does the pause thing) because you are using the wrong sort of key down input. The sf::Event::KeyPressed is like when you hold down a key in notepad. It will do that letter every x small amount of time. This is bad. You want to use the sf::Input class.
Go to the Getting real-time inputs section here.
[url]http://sfml-dev.org/tutorials/1.6/window-events.php[/url]
Then you can do this anywhere (do NOT put it in the event loop, your event loop should only check for sf::Event::Closed)
[code]if(Input.IsKeyDown(sf::Key::Up))
movePaddleUp();[/code]
As well as this, I see in your code that you aren't taking frame time into account. Because of this you will need to either implement it (and use the frametime to work out how far stuff should go this frame) or set the framerate to a fixed value like so.
[code]surface.SetFramerateLimit(60);[/code]
Actually, the keypressed event is only triggered when the key is pressed for the first time afaik.
To get movement whilst the key is pressed, I tend to have a variable called direction, which I set as either 1, 0 or -1, which I multiply by the movement speed in the appropriate part. So, in Racoon's case, if you the D button is pressed direction is set to 1, if the A button is pressed it's set to -1 and if either of them are released it is set to 0. I'm not sure how that works if both buttons are pressed at the same time, but it's that sort of idea.
With my current project I have all my movement code on keypress but using Input instead of Key::Code like so...
[code]
case Event::KeyPressed:
switch (event.Key.Code)
{
case Key::Escape:
render.Close( );
break;
case '1':
spells.CastSpell( 0, 0, 0 );
break;
}
bool upKeyDown = GInput.IsKeyDown( Key::Up );
bool downKeyDown = GInput.IsKeyDown( Key::Down );
bool leftKeyDown = GInput.IsKeyDown( Key::Left );
bool rightKeyDown = GInput.IsKeyDown( Key::Right );
if (upKeyDown == true)
GameWorld.Move(0,-speed);
if (downKeyDown == true)
GameWorld.Move(0,speed);
if (leftKeyDown == true)
GameWorld.Move(-speed,0);
if (rightKeyDown == true)
GameWorld.Move(speed,0);
break;
[/code]
Is this a good way of doing it or can i improve it?
[QUOTE=Chris220;23050666]I'm making a little particle system (you may have seen the video over in WAYWO), and I want to know how I can build it to be as efficient as possible.
At the moment, I simply have a Particle class, and a BaseEmitter class, which contains an array of Particle objects
When spawning particles, I just loop through the array until I find an inactive particle, and then set its position/velocity ETC
Obviously, this means it gets quite slow when there are lots of particles on the screen. How can I improve this?[/QUOTE]
If you haven't already figured it out, Garry wrote something on his blog about pretty much exactly what you are trying to do, I suggest you [url=http://www.garry.tv/?p=1397]take a look at his blog post[/url].
Basically, have two threads scanning every other position in the array. That or have one thread scanning the array, but pass the calculations on to a thread pool so that the scan thread doesn't have to stop and run a calculation, it just passes it on to the thread pool.
[QUOTE=robmaister12;23077627]If you haven't already figured it out, Garry wrote something on his blog about pretty much exactly what you are trying to do, I suggest you [url=http://www.garry.tv/?p=1397]take a look at his blog post[/url].
Basically, have two threads scanning every other position in the array. That or have one thread scanning the array, but pass the calculations on to a thread pool so that the scan thread doesn't have to stop and run a calculation, it just passes it on to the thread pool.[/QUOTE]
Thank you for pointing that out to me, I'll definitely look into making it threaded.
[QUOTE=TheBoff;23076519][B]Actually, the keypressed event is only triggered when the key is pressed for the first time afaik.
[/B]
To get movement whilst the key is pressed, I tend to have a variable called direction, which I set as either 1, 0 or -1, which I multiply by the movement speed in the appropriate part. So, in Racoon's case, if you the D button is pressed direction is set to 1, if the A button is pressed it's set to -1 and if either of them are released it is set to 0. I'm not sure how that works if both buttons are pressed at the same time, but it's that sort of idea.[/QUOTE]
No, otherwise his paddle would move a step then stop completely. It works just like a keypress in a text editor.
The sf::Input class is the way to do it. It is designed for this kind of thing.
[QUOTE=ZeekyHBomb;23064923]My knowledge about protocols is not extensive, however I think that UDP is a non-reliable protocol (packets are not automatically resent).
[/QUOTE]
Thought I was clear enough with 'man in the midddle'. I mean someone can just take the 'Login Success' packet and have it receive that over the 'Login Failed' packet.
It doesn't matter if the client thinks he is logged in, as long as the server knows whether or not he is.
Not sure where you stated any 'man in the middle' before, but if you fear of packets being listened to without either server or client knowing then I think TLS and SSL are for the purpose of prohibiting that.
[QUOTE=Jallen;23076151]-snip-[/QUOTE]
Thank you! It works really well
[QUOTE=ZeekyHBomb;23079210]It doesn't matter if the client thinks he is logged in, as long as the server knows whether or not he is.
Not sure where you stated any 'man in the middle' before, but if you fear of packets being listened to without either server or client knowing then I think TLS and SSL are for the purpose of prohibiting that.[/QUOTE]
Thought I did..
Anyways, it doesn't matter if the server knows it because then the person can use the application as though they are logged in.
[QUOTE=high;23080033]Anyways, it doesn't matter if the server knows it because then the person can use the application as though they are logged in.[/QUOTE]
If I'm understanding you correctly, it sounds like you're saying that if a man-in-the-middle tricks the client into thinking it's successfully logged in when it really hasn't, then the client effectively [i]is[/i] successfully logged in because it'll start sending commands to the server that it should only send when logged in, and the server will honor them.
That last part ("and the server will honor them") is a problem. For any client/server application to be secure, the server must know what the client is allowed to do at any given time, and reject attempts to do things that aren't allowed, regardless of what the client thinks it's allowed to do. Clients can't be trusted (because their behavior can be altered by users or men-in-the-middle) so you mustn't rely on the client to enforce security measures.
[QUOTE=Wyzard;23080486]If I'm understanding you correctly, it sounds like you're saying that if a man-in-the-middle tricks the client into thinking it's successfully logged in when it really hasn't, then the client effectively [i]is[/i] successfully logged in because it'll start sending commands to the server that it should only send when logged in, and the server will honor them.
That last part ("and the server will honor them") is a problem. For any client/server application to be secure, the server must know what the client is allowed to do at any given time, and reject attempts to do things that aren't allowed, regardless of what the client thinks it's allowed to do. Clients can't be trusted (because their behavior can be altered by users or men-in-the-middle) so you mustn't rely on the client to enforce security measures.[/QUOTE]
The client doesn't do anything with the server other then checking that it can log into a valid account.
[QUOTE=high;23058090]I want to secure the connection from my client to the server using rsa but I can't figure out how to stop packets from being resent.
I was thinking about adding a timestamp but isn't that really easy to bypass?[/QUOTE]
You're using RSA only as the first step of your login, right?
[QUOTE=gparent;23086245]You're using RSA only as the first step of your login, right?[/QUOTE]
Well I am using it so only the server can generate the packets.
And actually I am doing an RSA encrypted hash and random DES key. And the body of the packet is encrypted with DES.
Sorry, you need to Log In to post a reply to this thread.