• What do you need help with? Version 1
    5,001 replies, posted
[QUOTE=Richy19;26144554]Who uses classes in C++ ? :v:[/QUOTE] who uses C++?
[QUOTE=efeX;26147326]who uses C++?[/QUOTE] Billions, if not [i]millions[/i] of people.
-snip-
I was reading about ifs, switches and conditional operator in my class today. I was wondering why is using the conditional operator ?: frowned upon?
I think just because it might look confusing. It's pretty simple when you think about it, but people try to do whatever they can to avoid thinking.
[QUOTE=The DooD;26155530]On another note, I was reading about ifs, switches and conditional operator in my class today. I was wondering why is using the conditional operator ?: frowned upon?[/QUOTE] It makes things look fairly ( 1 == 0 ) ? clear : confusing sometimes.
[QUOTE=The DooD;26155530]Wouldn't it be "Millions, if not Billions of people"? On another note, I was reading about ifs, switches and conditional operator in my class today. I was wondering why is using the conditional operator ?: frowned upon?[/QUOTE] Don't think it is, really. Use it when its meaning is obvious and you should be okay. The proper term is the ternary operator, by the way.
[QUOTE=arienh4;26157214]Don't think it is, really. Use it when its meaning is obvious and you should be okay. The proper term is the ternary operator, by the way.[/QUOTE] Ok, I thought it was conditional cause they call it that on the microsoft website
Well, [url]http://en.wikipedia.org/wiki/%3F:[/url]
I know this is probably me doing something stupid but I am trying to make a tank move in an openGL game. So left and right arrows turn it and forwards and backwards move in in the direction it is facing, the main movement is from: [code] if(0 <= spintrig && spintrig >= 90) { movex = sin(spintrig)*testpos; movez = cos(spintrig)*testpos; } else if(90 < spintrig && spintrig >= 180) { spintrig2 = spintrig-90; movex = sin(spintrig2)*testpos; movez = -cos(spintrig2)*testpos; } else if (180 < spintrig && spintrig >= 270) { spintrig2=spintrig-180; movex = -sin(spintrig2)*testpos; movez = -cos(spintrig2)*testpos; } else if(270 < spintrig && spintrig >= 360) { spintrig2=spintrig-270; movex = -sin(spintrig2)*testpos; movez = cos(spintrig2)*testpos; } glTranslatef(movex,0,movez); glRotatef(spin,0,1,0); //glRotatef(spin,0,1,0); //model.speedDisplayFaceNormals(); drawShip(); [/code] With the keys controlling from: [code] if(keys[VK_UP]) { testpos += 1; } else if(keys[VK_DOWN]) { testpos -= 1; } if(keys[VK_LEFT]) { spin+=0.2; spintrig+=0.2; } else if(keys[VK_RIGHT]) { spin-=0.2; spintrig-=0.2; } } void update() { spin += speed; if(spin > 360) spin = 0; if(spintrig > 360) spintrig = 0; }[/code] Basically I worked out that if the angle of movement is between 0-90 the Z movement and X movement will be both positive, if the angle is between 90 and 180 it will move between the negative Z and positive X axis and so on. The rotation works fine but my tank does not move at all. Anyone know what could be wrong? Oh and the sin and cos bits are just me working out the x and z counterparts of the movement. I am using x and z as I am eventually expanding it to 3D. Been a while since I have done it so am starting simple.
Can i make VS2010 compile my VB exe with a filename based on a variable in the program (version number)?
No
Really? Nothing like Me.exeName = ver & ".exe" ?
[QUOTE=Giraffen93;26158988]Really? Nothing like Me.exeName = ver & ".exe" ?[/QUOTE] Most likely not. Although I can think of a way to do it in a makefile. Or maybe you could excecute a script as a post-build step that changes the exe name?
Yeah, i noticed, but how do i use it / make it dynamic?
[QUOTE=Random112358;26158600]I know this is probably me doing something stupid but I am trying to make a tank move in an openGL game.[/QUOTE] A few things: [list][*]First thing's first, in regards to the code not working right now, here are my guesses - movex/movez are integral (should be floats), OR testpos is being reset constantly, OR the increment to testpos is too small to notice (depends on the world scale in your opengl scene). [*]Now, if I understand the code correctly, your tank won't turn around its position - it will instead turn around its starting position. To resolve this, you have to make the movement keys add to an xz coordinate with the sin or cos (respectively) of the angle multiplied against the movement amount. As-is you are replacing the xz coordinates every frame with a new position computed based on the angle. [*]Your angle checks are unnecessary (also, I think the second > should be a < ). You can replace the whole set of if-else statements with the contents of the first block, just setting the xz offsets with sin & cos directly. [*]As a side note, the trig functions only accept radians, so your angle checks need to be in radians or you need to convert the values. [*]Finally, I'm a bit unclear on the difference between spin and spintrig.[/list]
[QUOTE=Giraffen93;26159047]Yeah, i noticed, but how do i use it / make it dynamic?[/QUOTE] If I had bash and awk, I'd write an awk script that takes a source file as input and outputs the version number if found. Then I'd embed said awk script in a bash script that does something like mv unifrog.exe unifrog-$AWK_SCRIPT_RESULT.exe
[QUOTE=Giraffen93;26158611]Can i make VS2010 compile my VB exe with a filename based on a variable in the program (version number)?[/QUOTE] Erm, no you can't. You can use a post-build event to do it though, only gotcha is that you need to set an environment variable to the current version before building. [img]http://ahb.me/YFb[/img]
How do I use JSONCPP's writer? The documentation is shady about this. In fact, how the hell do I build it for VS2010? The doc says to get scons.py but I have no idea where this is.
Do anyone have any experience with winsock2? Im trying to write a minecraft server, this has worked before but now only one byte is written to the that buffer for the handshake packet, any ideas?
[QUOTE=shill le 2nd;26150462]Billions, if not [i]millions[/i] of people.[/QUOTE] Why make billions when we can make, millions!
[QUOTE=Tobba;26170217]Do anyone have any experience with winsock2? Im trying to write a minecraft server, this has worked before but now only one byte is written to the that buffer for the handshake packet, any ideas?[/QUOTE] You need to post some code and explain the relevant parts of the Minecraft format a bit.
How do I play music using SFML? I get this error in my console when I try to open the music file: [code]Failed to open "music.mp3" for reading Failed to play audio stream : sound parameters have not been initialized (call Initialize first)[/code]
[quote](call Initialize first)[/quote] [b]GUESS WHY[/b] [url]http://www.sfml-dev.org/tutorials/1.2/audio-streams.php[/url] [editline]20th November 2010[/editline] Initialize(ChannelsCount, SampleRate);
Well, I use sf::Music like the tutorial shows, but I get that error. And how should I call Initialize if it's protected? [editline]20th November 2010[/editline] Converting the file from .mp3 to .ogg fixed it. I assume that SFML can't read .mp3 or what?
Now this is surely odd, all the handshake data seems to be sent in a second packet, first an empty packet with 0x02 is sent(handshake) then a packet containing all the data is sent
[QUOTE=sim642;26173652]Well, I use sf::Music like the tutorial shows, but I get that error. And how should I call Initialize if it's protected? [editline]20th November 2010[/editline] Converting the file from .mp3 to .ogg fixed it. I assume that SFML can't read .mp3 or what?[/QUOTE] You shouldn't use mp3 anyways. And I doubt SFML can use it, as they would need to pay a license to get the right.
[QUOTE=sim642;26173652]Converting the file from .mp3 to .ogg fixed it.[/QUOTE] If you can, convert the audio to ogg form a lossless source. Converting from lossy format A to lossy format B makes it .. even more lossy.
[QUOTE=sim642;26173652]Converting the file from .mp3 to .ogg fixed it. I assume that SFML can't read .mp3 or what?[/QUOTE] SFML doesn't support Mp3 because of the expensive licensing fees Here's a list of formats it DOES support: [url]http://www.sfml-dev.org/documentation/2.0/classsf_1_1Music.htm#ab81c0a529683441223d4b66bcc36a57[/url]
[QUOTE=Chris220;26175785]SFML doesn't support Mp3 because of the expensive licensing fees [/QUOTE] You don't, as far as I recall, have to pay the fees if you're using .mp3 in a free application.
Sorry, you need to Log In to post a reply to this thread.