• What do you need help with? V4 (January 2012)
    966 replies, posted
It works! Thanks! Could you explain to me why this was the problem?
...and a simpler way to write the whole thing is: [code]my_max = foldl1 max[/code]
[QUOTE=xxxkiller;34372770]It works! Thanks! Could you explain to me why this was the problem?[/QUOTE] [code]y0 = yPix / 300 -1.0f;[/code] The 300 was being evaluated as an int, and was demoting the result so that yPix / 300 always yielded an int.
[QUOTE=xxxkiller;34372770]It works! Thanks! Could you explain to me why this was the problem?[/QUOTE] If you divide an integer by an integer, you get an integer.
Ahh ok! I understand why I was getting boxes then! Thanks for the quick and swift replies!
[QUOTE=swift and shift;34370389][img]http://i.imgur.com/pB82x.png[/img][/QUOTE] What is this language?
[QUOTE=sim642;34374467]What is this language?[/QUOTE] Haskell.
I'm attempting to write a wrapper for the Windows command shell, allowing for things like fullscreen usage in an Aero environment (damn you, Microsoft) and custom colour schemes, aliases, profiles ETC. At the moment I'm using _popen and _pclose to execute the command and pipe the results back to my code, but since I'm on Windows, it's popping up a console every time I execute something. How can I get around this?
[QUOTE=Chris220;34375192]I'm attempting to write a wrapper for the Windows command shell, allowing for things like fullscreen usage in an Aero environment (damn you, Microsoft) and custom colour schemes, aliases, profiles ETC. At the moment I'm using _popen and _pclose to execute the command and pipe the results back to my code, but since I'm on Windows, it's popping up a console every time I execute something. How can I get around this?[/QUOTE] Are you writing a Win32 GUI application? If so, _popen and _pclose aren't even supposed to work. You need to use [URL="http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx"]Win32 API functions.[/URL]
Urgh. Moving all my (xbox) gamepad logic from xinput (windows) to SFML's system. It seems to use one single kind of weird pseudo-axis for both the left and right triggers (hold left - it goes to 100, hold right and it goes to -100), which won't work properly because you can hold both triggers and it thinks neither is held. Anyone know how to get around this? [editline]25th January 2012[/editline] Oh and another thing: the dpad is treated as a joystick too (what) which is all fine and manageable, except that there's no way to know if no dpad buttons are actually pressed. All you have is the angle the user is pointing to.
[QUOTE=NovembrDobby;34379871]Urgh. Moving all my (xbox) gamepad logic from xinput (windows) to SFML's system. It seems to use one single kind of weird pseudo-axis for both the left and right triggers (hold left - it goes to 100, hold right and it goes to -100), which won't work properly because you can hold both triggers and it thinks neither is held. Anyone know how to get around this? [editline]25th January 2012[/editline][/QUOTE] SFML uses DirectInput, which in an older API than XInput. The trigger issue is an intentional "feature" by Microsoft when using an XBox360 controller with DirectInput. I don't think there is any way to get around it, since Microsoft recommends the use of XInput. See here: [url]http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx[/url] [quote]In order to test the trigger values separately, you must use XInput.[/quote] This is why I prefer the days when everybody used Logitech gamepads instead of 360 controllers. EDIT: Actually, I think SFML doesn't even use DirectInput, but basic WinApi functions.
[QUOTE=NovembrDobby;34379871]It seems to use one single kind of weird pseudo-axis for both the left and right triggers (hold left - it goes to 100, hold right and it goes to -100), which won't work properly because you can hold both triggers and it thinks neither is held.[/QUOTE] -snip- Oh nevermind, I got ninja'd with information.
Two questions: 1. How can I change the icon of files that are opened with my program. 2. I can't seem to set files to open with my program by default, it doesn't show up when I double click it.
[QUOTE=shill le 2nd;34379776]Are you writing a Win32 GUI application? If so, _popen and _pclose aren't even supposed to work. You need to use [URL="http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx"]Win32 API functions.[/URL][/QUOTE] Thank you very much :)
[QUOTE=Wyzard;34372769]A simpler way to write the second definition is: [code]my_max (x:xs) = max x $ my_max xs[/code][/QUOTE] thanks!
Ok, so I'm spawning cmd.exe and redirecting its standard input and output streams to my application, so I can read its output. Here's the code I'm using to actually read the output: [cpp]char commandResult[2048]; ZeroMemory(commandResult, 2048); unsigned long bytesRead; ReadFile(stdOutR, commandResult, 2048, &bytesRead, NULL);[/cpp] Now, can someone please explain why if I run that it only returns the first line of the output, but if I put a breakpoint on the ReadFile line, then continue execution as soon as it breaks, it captures the entire output? I've already tried putting a 10 second wait after ReadFile to make very sure that it's not a race condition or something, and I can't think of what else to try!
[QUOTE=Chris220;34388439]Now, can someone please explain why if I run that it only returns the first line of the output, but if I put a breakpoint on the ReadFile line, then continue execution as soon as it breaks, it captures the entire output?[/QUOTE] I think you have to loop until bytesRead == 0
Can anyone point me in a way for a library/ tutorial/ anything for making a music visualizer with C#? Aswell as this problem: I have a XNA game that saves the player and the score's for each level in a ACCES .accdb database. Inserting new players, retrieving already existing players and updating them with new scores and getting all scores from it goes without a problem. Only when i close the game it deletes all new records from the database but i don't have any sql DELETE statements in my game?
[QUOTE=ToXiCsoldier;34391839]Can anyone point me in a way for a library/ tutorial/ anything for making a music visualizer with C#? Aswell as this problem: I have a XNA game that saves the player and the score's for each level in a ACCES .accdb database. Inserting new players, retrieving already existing players and updating them with new scores and getting all scores from it goes without a problem. Only when i close the game it deletes all new records from the database but i don't have any sql DELETE statements in my game?[/QUOTE] You can use [URL="http://naudio.codeplex.com/"]NAudio[/URL] to decode and play some audio formats. The WPF demo has some example visualizations. Are you commiting the transactions?
[QUOTE=Tamschi;34393066]You can use [URL="http://naudio.codeplex.com/"]NAudio[/URL] to decode and play some audio formats. The WPF demo has some example visualizations. Are you commiting the transactions?[/QUOTE] Thanks for the NAudio link, ill give it a try tomorrow. About the database: At the beginning of the game a player can insert it's name, if he pressed "continue" a SELECT command will check if the playername exists in the list. If it exists it will get all the player information with a SELECT command. If not then it will create a new one use the INSERT command to insert it into the database. If the player leaves the options menu, the database will be updated with the UPDATE command If a player completes a level the database will be updated aswell, same command. The highscore menu asks all the playernames and respective scores. It all works and the data is inserted into ACCES, until i close the game (either via stop debugging or use my close button (game1.exit)) then it loses all the new data i inserted that debug session. I use a object in my project to keep the current playerinformation (name, difficulty, and score for each level).
[QUOTE=shill le 2nd;34390445]I think you have to loop until bytesRead == 0[/QUOTE] Well, that's what I tried doing at one point, and it works in some cases and not others. It occasionally will get me the output line by line, but sometimes it'll just spam me with the entire output each iteration of the loop. It's really odd :/
Code::Blocks is the best IDE for C and C++ correct?
Nah, vim.
[QUOTE=esalaka;34395311]Nah, vim.[/QUOTE] But for windows?
[QUOTE=Doritos_Man;34395193]Code::Blocks is the best IDE for C and C++ correct?[/QUOTE] "Best" is subjective, personally I prefer (as do many people) Visual Studio 2010. Of course, if you're looking for a decent Linux IDE then yes, Code::Blocks may well be your best choice.
[QUOTE=Doritos_Man;34395193]Code::Blocks is the best IDE for C and C++ correct?[/QUOTE] It's alright, not nearly as good as Visual Studio though. [QUOTE=esalaka;34395311]Nah, vim.[/QUOTE] Vim is not an IDE.
[QUOTE=dajoh;34396099]It's alright, not nearly as good as Visual Studio though. Vim is not an IDE.[/QUOTE] Id say that with the extensions for there exists for vim, it may as well be.
Another very basic Python question. Would someone explain the difference between something like %-6.2f and plain old %.2f? I know the .2 means add 2 decimal points, but what do numbers that come before the decimal mean?
Where do I start if I want to learn C++?
-snip-
Sorry, you need to Log In to post a reply to this thread.