• What do you need help with? Version 1
    5,001 replies, posted
What exactly is the problem? Is there a compilation error? Also, I think Keyboard.GetState() is an XNA thing
[QUOTE=Chris220;25616245]What exactly is the problem? Is there a compilation error? Also, I think Keyboard.GetState() is an XNA thing[/QUOTE] "The name 'Keyboard' does not exist in the current context (CS0103) " Ive been watching videos about XNA i might have gotten that and another function mixed up
[QUOTE=toaster468;25616265]"The name 'Keyboard' does not exist in the current context (CS0103) " Ive been watching videos about XNA i might have gotten that and another function mixed up[/QUOTE] Use the return value from Console.ReadKey: [cpp] Console.WriteLine("Press any key:"); char c = Console.ReadKey().KeyChar; // Or use the .Key property for non-text input Console.WriteLine("You have pressed: {0}", c); [/cpp]
something from my old projects: [cpp]public void controll() { ConsoleKeyInfo controller = new ConsoleKeyInfo(); controller = Console.ReadKey(); if (controller.Key == ConsoleKey.UpArrow ) {posy--; Console.Clear();} ... [/cpp]
There's no reason to create a new, empty ConsoleKeyInfo object only to throw it away at the next line...
Thank you jA_cOp
How can I import an assembly from a dll in MC++? [editline]24th October 2010[/editline] Figured it out, it was just #using. Duh. Next problem: I'm trying to make a class, defined in C#, from MC++. The compiler recognises the class but it complains that: none of the 2 overloads could convert all the argument types. The constructor of the class accepts 2 strings. I am passing 2 strings, like this: System::String( script ), System::String( name ) [editline]24th October 2010[/editline] Figured it out, it was just #using. Duh. Next problem: I'm trying to make a class, defined in C#, from MC++. The compiler recognises the class but it complains that: none of the 2 overloads could convert all the argument types. The constructor of the class accepts 2 strings. I am passing 2 strings, like this: System::String( script ), System::String( name )
Where is this god damn blue line thing coming from?!? [img]http://filesmelt.com/dl/11111111.png[/img] It's pissing me off because IT WON'T GO AWAY AGGGHHH :tinfoil:
[QUOTE=VeryNiceGuy;25625586]Where is this god damn blue line thing coming from?!? [img_thumb]http://filesmelt.com/dl/11111111.png[/img_thumb] It's pissing me off because IT WON'T GO AWAY AGGGHHH :tinfoil:[/QUOTE] How long has it been there?
[QUOTE=thomasfn;25620309] The constructor of the class accepts 2 strings. I am passing 2 strings, like this: System::String( script ), System::String( name )[/QUOTE] System::String(script, name);
[QUOTE=ScreenNamesSuck;25626339]How long has it been there?[/QUOTE] Either I just noticed it there or it just appeared and won't get out
I think the root of my linker woes is that the .lib files are compiled in VS 2005. I tried to premake4 it with the settings: premake4 vs2010 [--unicode] [--ticpp-shared] [--dynamic-runtime] but I can't seem to compile the output because the .lib files are "Unable to start program c:\ticpp\lib\ticpp.lib. This file is an unrecognized or unsupported binary file." Anyone got a clue as to how to fix this?
If I want to simply declare an integer in the Source engine that'll be available for entities to check and which doesn't reset when for example reloading a save (it's for an inventory system), where do you suppose I would do this? I'm having a hard time understanding Source's code structure...
So, I've played around with 3D perspective and got everything working nicely with non-deprecated OpenGL but I have a problem. I render a rotating rectangle (textured) and it rotates (roll) fine but when I pitch it down a bit and keep rolling it I get clipping on the left and right. Here's a sceeenshot: [img]http://b.imagehost.org/0360/clipping.png[/img] and here's the shader code as I think the problem is there: [cpp]#version 110 uniform float timer; uniform mat4 window_matrix; uniform mat4 model_matrix; uniform int animated; uniform int frames; uniform int current_frame; attribute vec2 texcoord; attribute vec4 position; varying vec2 frag_texcoord; mat4 view_frustum( float angle_of_view, float z_near, float z_far ) { return mat4( vec4( 1.0 / tan(angle_of_view), 0.0, 0.0, 0.0), vec4( 0.0, 1.0 / tan(angle_of_view), 0.0, 0.0), vec4( 0.0, 0.0, (z_far + z_near) / (z_far - z_near), 0.1), vec4( 0.0, 0.0, -2.0 * z_far * z_near / (z_far - z_near), 1.0) ); } void main() { vec2 temp = texcoord; if (animated == 1) { 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 * view_frustum( radians( 60.0 ), 0.0, 100.0 ) * position; }[/cpp]
Hi im currently making a tile based game in C++ Now on top of the first layer of tiles i have added trees, these are supposed to get randomly generated (between 15 & 28 trees) and then are randomly positioned in the window making sure that they are atleast a set distance from any other tree (so they dont overlap) this is the code for the whole thing and i cant see anything wrong with it but it isnt working, trees are still overlapping and getting generated all over the place [cpp] const int treeint = sf::Randomizer::Random(15, 28); int *treeX = NULL; int *treeY = NULL; treeX = new int[treeint]; treeY = new int[treeint]; for(int i = 0 ; i < treeint; i++ ) { int treeXInt; do{ treeXInt = sf::Randomizer::Random(0, 780); if(i == 0) { treeX[i] = treeXInt; } else { for(int z = 0; z < i; z++) { if((treeXInt < (treeX[z] - 60)) || (treeXInt > (treeX[z] + 60))) { treeX[i] = treeXInt; break; } } } }while(treeX[i] == NULL); int treeYInt; do{ treeYInt = sf::Randomizer::Random(0, 620); if(i == 0) { treeY[i] = treeYInt; } else { for(int z = 0; z < i; z++) { if((treeYInt < (treeY[z] - 80)) || (treeYInt > (treeY[z] + 80))) { treeY[i] = treeYInt; break; } } } }while(treeX[i] == NULL); std::cout << treeX[i] << std::endl; std::cout << treeY[i] << std::endl; } [/cpp]
I tried using farseer but my collisions are off, this is what I've posted on the farseer forums but no one answers ... [url]http://farseerphysics.codeplex.com/Thread/View.aspx?ThreadId=232205[/url]
[QUOTE=Richy19;25678892]Hi im currently making a tile based game in C++ Now on top of the first layer of tiles i have added trees, these are supposed to get randomly generated (between 15 & 28 trees) and then are randomly positioned in the window making sure that they are atleast a set distance from any other tree (so they dont overlap) this is the code for the whole thing and i cant see anything wrong with it but it isnt working, trees are still overlapping and getting generated all over the place [cpp]--codesnip--[/cpp][/QUOTE] The problem in your code is that 1) new[] will initialize stuff as random memory (you could use new int[treeint](); to init to 0) 2) the tree is accepted as long as [i]one[/i] tree does not collide with the current. [cpp]int distance(const sf::Vector2i &a, const sf::Vector2i &b) { return a * a + b * b; } //... const std::size_t treeint = sf::Randomizer::Random(15, 28); sf::Vector2i *trees = new sf::Vector2i[treeint]; for(std::size_t i = 0 ; i < treeint; i++ ) { init_tree: trees[i] = sf::Vector2i(sf::Randomizer::Random(0, 780), sf::Randomizer::Random(0, 620)); for(std::size_t z = 0; z < i; z++) { if(distance(trees[i], trees[z]) < 100 * 100) { goto init_tree; } } std::cout << trees[i].x << '\n' << trees[i].y << std::endl; }[/cpp]
[QUOTE=ZeekyHBomb;25680020]. [cpp]int distance(const sf::Vector2i &a, const sf::Vector2i &b) { return a * a + b * b; } [/cpp][/QUOTE] It doesnt seem to like that code, says "no match for operator * in a * a and teh same for b * b im guessing it cant multiply the 2 vectors -snip-- didnt work
Oops [cpp]int distance(const sf::Vector2i &a, const sf::Vector2i &b) { const int dx = a.x - b.x, dy = a.y - b.y; return dx * dx + dy * dy; }[/cpp]
[QUOTE=ZeekyHBomb;25681037]Oops [cpp]int distance(const sf::Vector2i &a, const sf::Vector2i &b) { const int dx = a.x - b.x, dy = a.y - b.y; return dx * dx + dy * dy; }[/cpp][/QUOTE] But... Isn't distance sqrt( abs( x2-x1 + y2-y1 ) ) or am I on something?
Works now thanks :D
[QUOTE=esalaka;25681105]But... Isn't distance sqrt( abs( x2-x1 + y2-y1 ) ) or am I on something?[/QUOTE] It's sqrt(dx² + dy²): (a² (the distance) = b² (dx²) + c² (dy²)), but: [QUOTE=ZeekyHBomb;25680020][cpp]if(distance(trees[i], trees[z]) < 100 * 100)[/cpp][/quote] already taken into consideration. Squaring the 100 instead of squarrooting the distance :D
[QUOTE=ZeekyHBomb;25681140]It's sqrt(dx² + dy²): (a² (the distance) = b² (dx²) + c² (dy²)), but: already taken into consideration. Squaring the 100 instead of squarrooting the distance :D[/QUOTE] That's an interesting way to solve the problem. I wouldn't name the method "distance", though. And yeah, I just realized the distance can be solved from the Pythagoran theorem. I'm smart today.
[QUOTE=esalaka;25681208]That's an interesting way to solve the problem. I wouldn't name the method "distance", though.[/QUOTE] That's the normal way to solve the problem, avoiding the square root by comparing the distance squared to 100*100.
[QUOTE=esalaka;25681105]But... Isn't distance sqrt( abs( x2-x1 + y2-y1 ) ) or am I on something?[/QUOTE] That is correct Edit: :ninja: I don't even know how I managed to get ninja'd that much I swear I didn't have the thread open for that long :monocle: Edit 2: Wait no that isn't right Totally realised that before Zeeky pointed it out
No it's not. He forgot squaring the deltas.
[QUOTE=esalaka;25681105]But... Isn't distance sqrt( abs( x2-x1 + y2-y1 ) ) or am I on something?[/QUOTE] AB = sqrt((Xb - Xa)² + (Yb - Ya)²) Or, if you're in a tri-dimensional space AB = sqrt((Xb - Xa)² + (Yb - Ya)² + (Zb - Za)²)
[QUOTE=pikzen;25682306]AB = sqrt((Xb - Xa)² + (Yb - Ya)²) Or, if you're in a tri-dimensional space AB = sqrt((Xb - Xa)² + (Yb - Ya)² + (Zb - Za)²)[/QUOTE] I was already corrected and already noticed that myself, too, thank you very much.
[QUOTE=esalaka;25682351]I was already corrected and already noticed that myself, too, thank you very much.[/QUOTE] Didn't saw page 87 :smith:
In C#, I'm having a List with a lot of objects on. I have several threads iterating over the list, but I occasionally need to remove objects from the list, preferably in another thread. Can I in any way make it thread safe for multiple threads to iterate over and occasionally remove elements? Or should I use a database? MSSQL would be the obvious choice for C#, but I'd like it to be as cross-compatible as possible, so is MySQL a good alternative for C#?
Sorry, you need to Log In to post a reply to this thread.