• What do you need help with? Version 1
    5,001 replies, posted
[QUOTE=VeryNiceGuy;24829816]Try Google instead of spamming your thread[/QUOTE] Try helping instead of being a douche
because flaming me helps your chances :rolleye:
Well, can you help?
No, I'm sorry. Are you doing this for a school project?
Funny, I could use this. We just learned the color codes today. Anyone have some memorable (G-rated) mnemonics for remembering it?
Yes, it is a school project due tomorrow. But, the thing is, When I input numbers, I get 0 back. When I input colors, I get #VALUE The fuck is that?
You say you have no programming experience? Are you sure you should be in such a class?
[QUOTE=Whiterfire;24833941]Yes, it is a school project due tomorrow. But, the thing is, When I input numbers, I get 0 back. When I input colors, I get #VALUE The fuck is that?[/QUOTE] How are you inputting the colours? Are they strings?
[QUOTE=VeryNiceGuy;24834116]You say you have no programming experience? Are you sure you should be in such a class?[/QUOTE] It's hard to explain, but he is just starting to teach us. It's not a programming class, the class is called "Science, Research, and Technology". For example, later in the year we build robots. But this is a course for the research portion. [editline]10:45PM[/editline] I input them like this: Resistance(red,orange,blue)
Yeah, that won't work. Your program has no idea how to process those inputs, because they're not strings. You have to put double quotes around all the colour names: [quote]Function Resistance(Color1, Color2, Color3) 'First color is The first Number. SecondColor is the SecondColor number. If there is no fourth color, then the Third is how many 0's you add at the end. If there is a fourth, then the first three are your first three numbers and the FOURTH is the number of 0's. Select Case Color1 Case "black": First = 0 Case "brown": First = 10 Case "red": First = 20 Case "orange": First = 30 Case "yellow": First = 40 Case "green": First = 50 Case "blue": First = 60 Case "purple": First = 70 Case "violet": First = 70 Case "grey": First = 80 Case "white": First = 90 End Select Select Case Color2 Case "black": SecondColor = 0 Case "brown": SecondColor = 1 Case "red": SecondColor = 2 Case "orange": SecondColor = 3 Case "yellow": SecondColor = 4 Case "green": SecondColor = 5 Case "blue": SecondColor = 6 Case "purple": SecondColor = 7 Case "violet": SecondColor = 7 Case "grey": SecondColor = 8 Case "white": SecondColor = 9 End Select Select Case Color3 Case "black": Third = 10 ^ 0 Case "brown": Third = 10 ^ 1 Case "red": Third = 10 ^ 2 Case "orange": Third = 10 ^ 3 Case "yellow": Third = 10 ^ 4 Case "green": Third = 10 ^ 5 Case "blue": Third = 10 ^ 6 Case "purple": Third = 10 ^ 7 Case "violet": Third = 10 ^ 7 Case "grey": Third = 10 ^ 8 Case "white": Third = 10 ^ 9 End Select Resistance = (First + SecondColor) * Third End Function [/quote] And then call the function using =Resistance("red", "orange", "blue") When you don't use double quotes to input the parameters, Excel thinks you're referring to variables defined in the spreadsheet, and when you don't use double quotes in the VBA script itself, it thinks you're referring to variables defined in VBA. Neither are what you want. [b]EDITED[/b] Also, put Option Compare Text at the top of your script. This way the input strings are not case-sensitive.
I need a hand at making my java game more efficient, Currently i have an array that gets images from an array and then draws each image in the correct position however this means im making something like 3000 draw's a second which lags it to something like 15 FPS. Wat i want to do is when the game first starts to create an image from the array and just draw that one image instead of all the different segments of the image, is this possible or would i just have to use the finished image instead of an array?
The hell? Show your code I don't understand what you mean.. You have multiple images in an array and you're trying to draw them all?
[URL="http://silveiraneto.net/2008/04/27/simple-java-tileset-example/"]THIS[/URL] is in essence what im doing however i have a bigger array, a second layer for things like objects and it calls draw() every time it finishes, which makes it lag alot. So what ii want to do is build the finished image and then just draw that image instead of the array
[cpp]#version 110 uniform float timer; uniform mat4 window_matrix; uniform mat4 model_matrix; uniform bool animated; uniform int frames; uniform int current_frame; attribute vec2 texcoord; attribute vec4 position; varying vec2 frag_texcoord; void main() { vec2 temp = texcoord; if (animated){ float step = 1.0 / float(frames); if ( temp.x == 0.0 ){ temp.x = step * float(current_frame); } else if ( temp.x == 1.0) { temp.x = step * float(current_frame) + step; } } frag_texcoord = temp; gl_Position = window_matrix * model_matrix * position; }[/cpp] Any ideas why this would crash and is it a good way of doing animation? Error log gives no errors, just crashes. [editline]07:43PM[/editline] Wow... I restarted Visual Studio and now it compiles and works fine...
[QUOTE=shill le 2nd;24835273]Yeah, that won't work. Your program has no idea how to process those inputs, because they're not strings. You have to put double quotes around all the colour names: And then call the function using =Resistance("red", "orange", "blue") When you don't use double quotes to input the parameters, Excel thinks you're referring to variables defined in the spreadsheet, and when you don't use double quotes in the VBA script itself, it thinks you're referring to variables defined in VBA. Neither are what you want. [b]EDITED[/b] Also, put Option Compare Text at the top of your script. This way the input strings are not case-sensitive.[/QUOTE] Thanks, but you were a bit too late. I got it on my own. Thanks for the explanation though, I'll keep that in mind for future codes. Thanks for the Tip on option compare text, though!
I have a Manager class that I use to run through my entities and was wondering if this function is legal, I can't test it for a few hours, but it looks safe to me. [cpp] void Run( void ( T::*func )( sf::RenderWindow &w ) ) { for each( T* i in Database ) { i->func(); } } [/cpp] T is a template typename
[QUOTE=NorthernGate;24851578]I have a Manager class that I use to run through my entities and was wondering if this function is legal, I can't test it for a few hours, but it looks safe to me.[/QUOTE] No, it's illegal, you'll go to jail for running it. :wink: Your "func" is a function that expects a RenderWindow& parameter, but you're not passing one when you call it. And is this meant to be real, valid C++, or pseudo-C++? There's no "each" keyword in C++. (You might be thinking of [url=http://www.cplusplus.com/reference/algorithm/for_each/]std::for_each[/url], but that's used differently than what you have written.)
[QUOTE=Wyzard;24852831]No, it's illegal, you'll go to jail for running it. :wink: Your "func" is a function that expects a RenderWindow& parameter, but you're not passing one when you call it. And is this meant to be real, valid C++, or pseudo-C++? There's no "each" keyword in C++. (You might be thinking of [url=http://www.cplusplus.com/reference/algorithm/for_each/]std::for_each[/url], but that's used differently than what you have written.)[/QUOTE] That's odd. I finally got a chance to test it, after fixing up the errors, and this: [cpp] void Run( void ( T::*func )( sf::RenderWindow *w ) ) { for each( boost::shared_ptr<T> i in Database ) { (i.get()->*func)( Window ); } }[/cpp] Compiles and runs their step function perfectly with: [cpp] Entities.Run( &Entity::Step ); [/cpp]
What is "for each"? That isn't valid C++, is it?
I think he's trying to do a [url=http://en.wikipedia.org/wiki/Foreach]foreach loop[/url] Basically, a for loop but without having to explicitly specify how many iterations you go through. You could just pull the number of items in your object and put it inside the conditional segment of the for loop. Foreach takes longer to run than a for loop, by the way.
[QUOTE=Chris220;24856277]What is "for each"? That isn't valid C++, is it?[/QUOTE] boost.
NorthernGate, what compiler are you using? If "for each" compiles, you're probably relying on some non-standard language extension. [QUOTE=robmaister12;24856396] Foreach takes longer to run than a for loop, by the way.[/QUOTE] How do you figure? Any sane implementation should iterate in the same way that a "normal" for-loop would. The C++0x [url=http://en.wikipedia.org/wiki/C++0x#Range-based_for-loop]range-based for[/url], for example, iterates over containers using iterators. [editline]07:13AM[/editline] Yep, looks like it's [url=http://stackoverflow.com/questions/197375/visual-c-for-each-portability]Microsoft-specific[/url].
[cpp]void computerAI::goRandom() { char i, j; while (board.setMark(i = rand()%3, j = rand()%3, -1) == false); //Stores the locations xLoc = i; yLoc = j; }[/cpp] What am I missing here. This should set i and j to two numbers between 0-2, but it always sets it to first 2,2, and then 1,1, and then 0,0 (it would always do 2,2 but there is some code to stop it from picking the same cordinate twice). [editline]08:08AM[/editline] Ah I see, you need to do some other stuff. I just assumed it would generate a random value.
[QUOTE=Pepin;24858354]Ah I see, you need to do some other stuff. I just assumed it would generate a random value.[/QUOTE] I assume by "do some other stuff" you mean "seed the RNG". Computers are deterministic and can't produce [i]actual[/i] random sequences; what you get are [url=http://en.wikipedia.org/wiki/Pseudorandom_number_generator][i]pseudo[/i]-random sequences[/url] that [i]look[/i] unpredictable but actually do follow a deterministic pattern. The algorithm will always produce the same sequence of numbers for the same starting "seed" value, so to get different sequences each time your program runs, you have to seed the RNG with something that's different each time. A common choice is the system's clock, since that constantly changes.
I have such statement : [cpp] if ((Ball2.x >= Pad1.x && Ball1.x <= Pad2.x) && (Ball2.y >= Pad1.y && Ball1.y <= Pad2.y)) { Offset = sf::Vector2f(-Offset.x, Offset.y + (Pads[i].GetPos().y - Position.y)); }[/cpp] Ball1 and Pad1 are top left corners and Ball2 and Pad2 are bottom right corners. This is used for rectangular collision checking, but problem is that I need to somehow find if those 2 rectangles collide on lines parallel to x axis or y axis so I know how should I bounce those. Any advice?
[QUOTE=turb__;24856414]boost.[/QUOTE] Ah, I see now. Thanks.
[QUOTE=Chris220;24861338]Ah, I see now. Thanks.[/QUOTE] Boost's range-based loop is done with the for_each templated function or BOOST_FOREACH macro. The syntax he uses is not valid standard C++ and can't be amended by a library like boost. As pointed out, the reason it compiles is because of an MSVC-specific extension.
I have a question about WQL: is it possible to catch both __InstanceCreationEvent and Deletion in a single query without catching __InstanceModificationEvent? I need this because catching modification events slows down the query and they are useless to me. This is .NET, by the way.
When I texture a quad (not using quads, you know what I mean) that is larger than the original size of the texture I get this white lines on the top of it. What can I do about it? (making a screenshot of it) [editline]08:47PM[/editline] Ok, I changed their wrap to ClampToEdge and there are no white lines now but it still gets outlined with them. [IMG]http://i.imagehost.org/0923/Untitled_8.png[/IMG]
I don't know if there's a better solution, but a way to fix it is using texture coordinates like 0.01f and 0.99f instead of 0.0f and 1.0f.
Sorry, you need to Log In to post a reply to this thread.