• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=T3hGamerDK;38124039]Have a search for "I love Ruby 2012" and read it. It'll help you out with some of the more common items in Ruby.[/QUOTE] [img]http://i.imgur.com/j2lHK.png[/img] Great book...
[QUOTE=MakeR;38124317][img]http://i.imgur.com/j2lHK.png[/img] Great book...[/QUOTE] My point exactly.
[QUOTE=itsthejayden;38123907]I need help getting started with Ruby. I don't have a clue on how to install it and make it run. (I'm not a total newbie I just am really confused.) Also some tutorials on getting started would be nice![/QUOTE] [url]http://rubyinstaller.org/downloads/[/url] why's (poignant) guide to ruby will do [url]http://mislav.uniqpath.com/poignant-guide/book/chapter-1.html[/url] if not [url]http://www.ruby-lang.org/en/documentation/quickstart/[/url] and maybe this ([U]only maybe[/U]) [url]http://www.tutorialspoint.com/ruby/[/url] And may this help you along the way [url]http://www.ruby-doc.org/core-1.9.3/[/url] There are lots of tutorials, but you probably won't need them (you will see why)
[QUOTE=vombatus;38124480]-snip-[/QUOTE] I installed it and such but I can't find the fxri folder in my start menu.
[QUOTE=Funley;38113784]I heard that in XNA, doing KeyboardState.GetPressedKeys() is not recommended since it allocates memory each time and i plan on doing it all the time. Is this true?[/QUOTE] Probably doesn't matter, unless you're doing it multiple times per frame for every different key press check. You can just store the result at the start of each frame.
[QUOTE=NovembrDobby;38124742]Probably doesn't matter, unless you're doing it multiple times per frame for every different key press check. You can just store the result at the start of each frame.[/QUOTE] Thanks. I tried to make a textbox but i failed horribly. Some people suggested to use a tetxbox from winforms, how? All the samples i found were either unaccesible of broken.
[QUOTE=Funley;38126211]Thanks. I tried to make a textbox but i failed horribly. Some people suggested to use a tetxbox from winforms, how? All the samples i found were either unaccesible of broken.[/QUOTE] I dunno if that's a good idea, I wouldn't want to rely on winforms myself. We can help you with a custom XNA one though :) and I think a few people have made UI libraries around here.
Currently making a BSP renderer in XNA (you may have seen in WAYWO) however I am having trouble getting good FPS on the larger maps, especially q3dm11. On xbox I am getting 17fps minimum and I'd like to be able to have good FPS on as many of the XNA/MonoGame platforms as possible. I am currently using a vertex buffer with every vertex and an index buffer that changes each frame. I am calculating the indexes once and then rendering each pass of the BasicEffect effect. I have also implemented PVS culling and frustum culling that happens each frame, the frustum culling is only leaf accurate, however I see no fast way to be any more accurate as there are no smaller divided bounding boxes.
This might sound like a stupid question, but I just started using Visual Studio and it appears some feature is enabled where if I try to go and edit a line of code, rather than just pushing the text to the right of it over, it over-writes it ( kind of like how calculators do ). I've scavenged the options menu for quite a while but can't seem to find anything related.
[QUOTE=Bellmanator;38130127]This might sound like a stupid question, but I just started using Visual Studio and it appears some feature is enabled where if I try to go and edit a line of code, rather than just pushing the text to the right of it over, it over-writes it ( kind of like how calculators do ). I've scavenged the options menu for quite a while but can't seem to find anything related.[/QUOTE] There is a button on your keyboard labeled "INS". Press it once, then try again.
Writing a program to generate a concordance. Here's (some of) my output: [QUOTE]Cats | 3 are | 3 domesticated | 3 | 3 es [/QUOTE] That last line should say felines, but as you can see, the first 5 characters (there should be a space in front of the vertical line) have overwritten the "felin" in felines. It runs through exactly the same output code as the rest of the words, and it happens for each word at the end of my input, leading me to believe the terminator is screwing something up. [editline]21st October 2012[/editline] Guess what works when I use VS instead of NetBeans. It might be G++ specific...
Anyone know anything about .obj files? I'm getting a normal index bigger than the total amount of normals. [editline]value[/editline] Nevermind, stupid mistake. I was thinking: [QUOTE][B]f [/B][B]------ [/B][B]v1/vn1/vt1 ------ v2/vn2/vt2 ------ v3/vn3/vt3[/B][/QUOTE] Turns out it is: [QUOTE][B]f [/B][B]------ [/B][B]v1/vt1/vn1 [/B][B]------ [/B][B]v2/vt2/vn2 [/B][B]------ [/B][B]v3/vt3/vn3[/B][/QUOTE]
[QUOTE=ben1066;38127786]Currently making a BSP renderer in XNA (you may have seen in WAYWO) however I am having trouble getting good FPS on the larger maps, especially q3dm11. On xbox I am getting 17fps minimum and I'd like to be able to have good FPS on as many of the XNA/MonoGame platforms as possible. I am currently using a vertex buffer with every vertex and an index buffer that changes each frame. I am calculating the indexes once and then rendering each pass of the BasicEffect effect. I have also implemented PVS culling and frustum culling that happens each frame, the frustum culling is only leaf accurate, however I see no fast way to be any more accurate as there are no smaller divided bounding boxes.[/QUOTE] Did you write your own BSP parser?
[QUOTE=NovembrDobby;38127352]I dunno if that's a good idea, I wouldn't want to rely on winforms myself. We can help you with a custom XNA one though :) and I think a few people have made UI libraries around here.[/QUOTE] I prefer to make my own UI. This is what i have in the textbox's Update() right now: [code] ks = Keyboard.GetState(); Keys[] keys = ks.GetPressedKeys(); foreach (Keys k in keys) { if (oldks.IsKeyUp(k)) { Conlog.Print(k.ToString()); if (k == Keys.Enter) { Conlog.Print("Enter hit"); mGame.ExecuteString(text, "CommandLine"); text = ""; } else if (k == Keys.Back) { if (text.Length > 0) { text = text.Remove(text.Length - 1); } } else if (k == Keys.Space) { text += " "; } else { if (keysToCheck.Contains(k)) { if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += k.ToString().ToUpper(); } else { text += k.ToString().ToLower(); } } else { switch (k.ToString()) { case "OemPeriod": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += ":"; } else { text += "."; } break; case "OemComma": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += ";"; } else { text += ","; } break; case "D1": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "!"; } else { text += "1"; } break; case "D2": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += '"'; } else { text += "2"; } break; case "D3": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "#"; } else { text += "3"; } break; case "D4": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "¤"; } else { text += "4"; } break; case "D5": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "%"; } else { text += "5"; } break; case "D6": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "&"; } else { text += "6"; } break; case "D7": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "/"; } else { text += "7"; } break; case "D8": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "("; } else { text += "8"; } break; case "D9": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += ")"; } else { text += "9"; } break; case "D0": if (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift)) { text += "="; } else { text += "0"; } break; } } } } } oldks = ks; [/code] Of course this works for only my Nordic keyboard since it's hardcoded for it.
[QUOTE=Protocol7;38134134]Writing a program to generate a concordance. Here's (some of) my output: That last line should say felines, but as you can see, the first 5 characters (there should be a space in front of the vertical line) have overwritten the "felin" in felines. It runs through exactly the same output code as the rest of the words, and it happens for each word at the end of my input, leading me to believe the terminator is screwing something up. [editline]21st October 2012[/editline] Guess what works when I use VS instead of NetBeans. It might be G++ specific...[/QUOTE] Figured this out thanks to someone on SA. The way Notepad does newlines is with a carriage return and a line feed, but I was only stripping the line feed, so G++ was freaking out on the carriage return but not the line feed. Strip out all control characters and punctuation with this: [cpp]std::string stripPunct(std::string in) { in.erase(std::remove_if(in.begin(), in.end(), ispunct), in.end()); in.erase(std::remove_if(in.begin(), in.end(), iscntrl), in.end()); return in; }[/cpp] And it works!
[QUOTE=Mozartkugeln;38136088]Did you write your own BSP parser?[/QUOTE] I did, based heavily on [url]http://www.flipcode.com/archives/Simple_Quake3_BSP_Loader.shtml[/url] and [url]http://q3libxna.codeplex.com/[/url] but I get the data fine, it's just slow rendering.
I want to create a library with some of the functions I use often so I don't have to write them each time I need 'em. I used Code Blocks' Static Library project type thingy to create the libmylib.a file from this source file: [code] #include "mylib.h" void gotoxy(short x,short y) { COORD coords = {x,y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coords); } void set_color(int color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color); } [/code] and I have this header file: [code] #ifndef MYLIB_H_INCLUDED #define MYLIB_H_INCLUDED #include <Windows.h> void gotoxy(short x,short y); void set_color(int color); #endif // MYLIB_H_INCLUDED [/code] So, I put the .a file in ...\lib and the .h file in ...\include, include the file in a new project with #include <mylib.h> and when I try to use a function I get this: ...undefined reference to `gotoxy(short, short)' Any idea why?
[QUOTE=WhatTheEf;38139415]I want to create a library with some of the functions I use often so I don't have to write them each time I need 'em. I used Code Blocks' Static Library project type thingy to create the libmylib.a file from this source file: -snip- So, I put the .a file in ...\lib and the .h file in ...\include, include the file in a new project with #include <mylib.h> and when I try to use a function I get this: ...undefined reference to `gotoxy(short, short)' Any idea why?[/QUOTE] You still have to actually link the library in Project Settings.
Done that, still not working.
Stupid Java thing again. The problem is event handling, and what I'm trying to do is to convert a temperature though a method whenever a number is entered in a JTextField or when the to/from JComboBoxes are changed. How exactly would I go about this to begin with, research isn't helping, and the book certainly isn't helping.
Does anyone else have problems compiling Haskell packages with cabal from hackage? Most packages I'd like to use, such as Darcs, just fail to build because of missing dependencies and errors like that.
Sorry I'm still really new to this but C# I need to find out how many items in an array are over a certain number but I can't for the life of me figure out how to do it. For example if there was an array that had { 5, 1, 8, 4, 2 } and I needed to find how many of those numbers were >= 5 it would find that there is 2 numbers >= 5
You just want a for loop, loop through the numbers. If a number is larger then two, add one to a counter variable.
[QUOTE=Tovip;38148299]Sorry I'm still really new to this but C# I need to find out how many items in an array are over a certain number but I can't for the life of me figure out how to do it. For example if there was an array that had { 5, 1, 8, 4, 2 } and I needed to find how many of those numbers were >= 5 it would find that there is 2 numbers >= 5[/QUOTE] [cpp] int[] numbers = { 5, 1, 8, 4, 2 }; [/cpp] Imperative: [cpp] int count = 0; foreach (var number in numbers) { if (number >= 5) { ++count; } } [/cpp] Functional: [cpp] int count = numbers.Where(x => x >= 5).Count(); [/cpp]
I want to make a regex to check for any of the following characters in VB [code] !#$%&'()*+,-./"[/code] Any idea how to do this? There is an Escape method, but it doesn't work on double quotes and I'm not even entirely certain I quite get how that method even works [php]Dim specialRegex As New Regex("!%&'*,-./" + Regex.Escape("+*#()$"))[/php] Tried that to see if it worked for the other characters, but it didn't, I'm at a loss.
I think you just probably need to surround your matches with []. Edit: Dear got that was a terrible sentence.
Hey guys, I just started code academy's Java a couple weeks ago and have a question relating it back to real world problems. I hate to be the [I]ideas guy[/I], but I really don't know where to start. Let's assume I have a text book without a glossary, and I want to create one. The terms are bolded, but really aren't defined. How would I accurately program something to pull out the bolded terms in the text book, and generate a somewhat accurate definition?
[QUOTE=blacksam;38154261]Hey guys, I just started code academy's Java a couple weeks ago and have a question relating it back to real world problems. I hate to be the [I]ideas guy[/I], but I really don't know where to start. Let's assume I have a text book without a glossary, and I want to create one. The terms are bolded, but really aren't defined. How would I accurately program something to pull out the bolded terms in the text book, and generate a somewhat accurate definition?[/QUOTE] An "ideas guy" is generally someone who has this grand idea that would take a team of programmers a long time to do, and just asks people to hand them a completed game so that they can take all the credit for it. Asking for guidance on a question is perfectly fine. "Can has code plz?" is not. As for the actual question, unless there are points in the book where they explicitly state "A <word> is a <definition>" or something similar, you'll have a very hard time getting good definitions out of it. This is because languages have very complex structures (multiple phrases might mean the same thing, words mean different things in context, etc). The field of computer science that deals with these kinds of things is called [url=http://en.wikipedia.org/wiki/Natural_language_processing]natural language processing[/url]. Specifically, you'd be interested in [url=http://en.wikipedia.org/wiki/Natural_language_understanding]natural language understanding[/url]. If you want a very loose "definition" of the word, you can search through the book for the keywords and keep track of the words/phrases in the sentences that use that word. Go through each word and print out only the most commonly used words/phrases. In all likelihood, the definitions will be a list of nouns related to the word and verbs that are done to the word. There isn't much more you can do without defining the structure of the English language and parsing each sentence for parts of speech to define how the most common words relate to the object. If you want a computer to actually be able to convincingly define something and not just list it's properties, you'd have to essentially build a machine that could pass the Turing test. [editline]23rd October 2012[/editline] Alternate, more reasonable solution: screw the book, pull definitions from an online dictionary.
[QUOTE=robmaister12;38154796]An "ideas guy" is generally someone who has this grand idea that would take a team of programmers a long time to do, and just asks people to hand them a completed game so that they can take all the credit for it. Asking for guidance on a question is perfectly fine. "Can has code plz?" is not. As for the actual question, unless there are points in the book where they explicitly state "A <word> is a <definition>" or something similar, you'll have a very hard time getting good definitions out of it. This is because languages have very complex structures (multiple phrases might mean the same thing, words mean different things in context, etc). The field of computer science that deals with these kinds of things is called [url=http://en.wikipedia.org/wiki/Natural_language_processing]natural language processing[/url]. Specifically, you'd be interested in [url=http://en.wikipedia.org/wiki/Natural_language_understanding]natural language understanding[/url]. If you want a very loose "definition" of the word, you can search through the book for the keywords and keep track of the words/phrases in the sentences that use that word. Go through each word and print out only the most commonly used words/phrases. In all likelihood, the definitions will be a list of nouns related to the word and verbs that are done to the word. There isn't much more you can do without defining the structure of the English language and parsing each sentence for parts of speech to define how the most common words relate to the object. If you want a computer to actually be able to convincingly define something and not just list it's properties, you'd have to essentially build a machine that could pass the Turing test. [editline]23rd October 2012[/editline] Alternate, more reasonable solution: screw the book, pull definitions from an online dictionary.[/QUOTE] I have the PDF in front of me and I am doing ctrl f to find the definitions. It's not so bad. I was more interested in efficiency and the science behind formatting the definitions. I tried thinking of a simple OCR solution that didn't involve me buying an expensive printer to find the bolded text. Now I stumble upon natural language and Chomsky. Thanks for making me an excuse to procrastinate on this assignment. Heart to you kind sir.
[QUOTE=Stonecycle;38140054]Stupid Java thing again. The problem is event handling, and what I'm trying to do is to convert a temperature though a method whenever a number is entered in a JTextField or when the to/from JComboBoxes are changed. How exactly would I go about this to begin with, research isn't helping, and the book certainly isn't helping.[/QUOTE] To get a number from a [I]JTextField[/I], I suggest adding an [I]ActionListener[/I] to it, just like you would to a [I]JButton[/I]. Keep in mind that this requires pressing Enter. If you wish to convert as soon as the user stops typing, a clean way of doing this would be adding a [I]FocusListener[/I] to the text field and implementing the [I]focusLost[/I] method to call the conversion method. This will convert the units when the text field component loses focus (e.g. when you click on something else). [cpp] private JTextField textFieldTemp; private void parseTextField() { // Set your temperature field or w/e you have to textFieldTemp.getText(), then call the conversion method. // It might be a good idea to check if the text is a number, either using try/catch with NumberFormatException, or regex. convertTemp(); } /* Put the following into your component initialization method */ textFieldTemp = new JTextField(); textFieldTemp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { parseTextField(); } }); textFieldTemp.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent evt) { // Unneeded } @Override public void focusLost(FocusEvent evt) { parseTextField(); } }); [/cpp] As far as the combo boxes go, they also work with [I]ActionListeners[/I] — whenever a user selects an option, the listener is triggered. This, of course, means that you can do something along the lines of this: [cpp] private JComboBox comboBoxUnits; /* Put the following into your component initialization method */ comboBoxUnits = new JComboBox(new String[] { "Pascal", "Celsius", "Fahrenheit" }); // Initializing it with String[] is fine, but it'd be much better if you made an enumeration, plus it'd make converting between units easier. comboBoxUnits.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { // Set your unit field or w/e you have to comboBoxUnits.getSelectedItem(), then call the conversion method. convertTemp(); } } [/cpp]
Sorry, you need to Log In to post a reply to this thread.