• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=Philly c;32872141]I've always wondered how to do something like a planet renderer. I'm talking simply in terms of precision, not anything about planets because that's not what interests me as such. Obviously you can't just do floats and hope for the best. I've heard about keeping the absolute position as a 64 bit integer and then using relative positions with floats. Obviously by this terrible description you can see i'm way too stupid and don't understand how this would actually work. I've tried googling but I guess i'm searching all the wrong things and I haven't found anything decent on it. I'm pretty much asking for anything that can help.[/QUOTE] This post does a pretty good job of explaining it: [url]http://www.facepunch.com/threads/1082693?p=29596681&viewfull=1#post29596681[/url]
[QUOTE=Naarkie;32888740]Working on a village simulator thingy. I have a village class and a generator class. When the game starts the generator randomly generates some villages and puts them in the villages list. Each village has a name value, a food value, a population value, etc. My dillema: I'm trying to get something like an 'attack' command in. You type "attack VillageName" and it searches for a village in "villages" with the name parameter "VillageName", then subtracts 100 food from that village, etc. How would I do something like this? I'm doing this in C#, btw.[/QUOTE] Do this when you detect the "attack" command was given. [code]foreach (Village village in villages) { if (Village.Name == VillageName) { Village.Food -= 100; } }[/code]
Anyone know of a good C++ compiler/whatever other than Visual Studio?
[QUOTE=Phycosymo;32888943]Anyone know of a good C++ compiler/whatever other than Visual Studio?[/QUOTE] Code::blocks as from what i have heard.
[QUOTE=Phycosymo;32888943]Anyone know of a good C++ compiler/whatever other than Visual Studio?[/QUOTE] [QUOTE=Funley;32888950]Code::blocks as from what i have heard.[/QUOTE] That's an IDE (integrated development environment). Technically the compiler it uses and the one I'd suggest would be GNU compiler collection. It's called [url=http://www.mingw.org/]MinGW[/url] on windows.
[QUOTE=Funley;32888896]Do this when you detect the "attack" command was given. [code]foreach (Village village in villages) { if (Village.Name == VillageName) { Village.Food -= 100; } }[/code][/QUOTE] Thanks :smile:
-figured it out-
I seem to have a memory leak using C++/OpenGL, though only when I draw in 2D. If I comment out the draw function, it stops. But it's just this: [cpp] glBindVertexArray(vertexArrayObject); glDrawArrays(primitiveType, 0, nNumVerts); glBindVertexArray(0); [/cpp] Oddly it doesn't happen when drawing the 3D model, only text and rectangles.
[QUOTE=bean_xp;32879928]Try unchecking the option "View White Space" under Edit->Advanced[/QUOTE] can someone tell me where this thingy is? there is no advanced under edit and i cant find "View white space" anywhere :S
[QUOTE=Clio;32897156]can someone tell me where this thingy is? there is no advanced under edit and i cant find "View white space" anywhere :S[/QUOTE] Sorry, I assumed the menu layout would be the same in 2010 ultimate. The default shortcut is ctrl+R followed by ctrl+W, so you could try that, if that fails somebody else will have to help you.
[QUOTE=Corndog Ninja;32890893]-figured it out-[/QUOTE] Poor lonely googler that may have the same problem. [editline]21st October 2011[/editline] Ooo i have a problem where I can't get the program to run at all. [editline]Edited[/editline] Fixed.
How do you track the position of the cursor in XNA? It's really stumping me.
[QUOTE=Mr. Smartass;32900897]How do you track the position of the cursor in XNA? It's really stumping me.[/QUOTE] If you mean getting the cursor position, then: [csharp]MouseState State = Mouse.GetState(); int x = State.X; int y = State.Y;[/csharp] Or: [csharp]int x = Mouse.GetState().X; int y = Mouse.GetState().Y;[/csharp] To see how much the cursor has moved since the last frame you can compare with the previous mouse state: [csharp]MouseState State = Mouse.GetState(); int ChangeInX = State.X - PrevMouseState.X; int ChangeInY = State.Y - PrevMouseState.Y; PrevMouseState = State;[/csharp]
[QUOTE=Map in a box;32900738]Poor lonely googler that may have the same problem. [editline]21st October 2011[/editline] Ooo i have a problem where I can't get the program to run at all. [editline]Edited[/editline] Fixed.[/QUOTE] Hey guys, I've been trying to solve the P versus NP problem. --snip-- nvm, solved it.
Does anyone know how to debug print, Console.WriteLine, or anything in the .NET 4.5 C# (the C# in the Windows 8 preview)?
How do I quit out of a love application? love.quit() is a callback.
[QUOTE=supersnail11;32908456]How do I quit out of a love application? love.quit() is a callback.[/QUOTE] [URL]http://love2d.org/wiki/love.event.push[/URL] [cpp] function love.keypressed(key) if key == "escape" then love.event.push("q") end end [/cpp]
c++ Noob here. Objective is to test a bubble sort while doubling the array which it sorts by 2 each time. Everything goes smooth until like the 8th time it sorts where it crashes [code] #include "stdafx.h" #include <iostream> #include <time.h> #include <ctime> using namespace std; void bubble(int [], int); void showArray(int [], int); void mergesort(int a [], int low, int high); void merge(int a[], int low, int high, int mid); void swapIt(int & tFirst, int & tSecond); bool checkSort (int array[], int size); bool checkSort (string array[], int size); long long iCompares; const int START = 32; const int MAX_TIME = 70; int main() { //int * iArray; int * iArray2; int * iArray3; int iSize = START; int seed = time(0); long startTime, endTime, elapsedTime; bool bSort1 = true; bool bSort2 = true; bool bSort3 = true; while((bSort1 == true) && (bSort2 == true) && (bSort3 == true)) { int * iArray = new int[iSize]; //iArray2 = new int[iSize]; //iArray3 = new int[iSize]; //filling the array for (int i = 0; i < iSize ;i++) { iArray[i] = rand(); //iArray2[i] = iArray[i]; //iArray3[i] = iArray[i]; } if(bSort1 == true) { //sort the array cout << "Array before sort: "; //for (int i = 0; i < iSize; i++) //{ // cout << iArray[i]; // cout << " "; //} iCompares = 0; startTime = clock(); bubble(iArray, iSize); endTime = clock(); cout << "\nArray after sort: "; //for (int i = 0; i < iSize; i++) //{ // cout << iArray[i]; // cout << " "; //} elapsedTime = endTime - startTime; cout << "\nThe bubble sort for " << iSize << " took " << elapsedTime/static_cast<double>(CLOCKS_PER_SEC) << " seconds and " << iCompares << " compares\n"; iSize = iSize * 2; if ((elapsedTime/static_cast<double>(CLOCKS_PER_SEC)) >= 70) { bSort1 = false; } } delete [] iArray; //delete [] iArray2; //delete [] iArray3; iSize = iSize * 2; } } void bubble(int array[], int size) { bool swap; int temp = 0; do { swap = false; for (int count = 0; count < (size - 1); count++) { if (array[count] > array[count + 1]) { temp = array[count]; array[count + 1] = temp; swap = true; iCompares++; } } } while (swap); } [/code] I get this error and its driving me nuts Unhandled exception at 0x7578e124 in Lab07cs.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x003df64c.. Please help :(
Using SFML 1.6, trying to do a sort of render target thing. I know 2.0 has render textures but I don't want to update unless I really need to (modified SFML somewhat and I heard they don't work at all on intel GPUs). Does sf::Image::CopyScreen() only copy stuff that was presented when app->Display() has been called? Or does it get everything that's been app->draw()n since the last clear?
[QUOTE=NovembrDobby;32912970]Using SFML 1.6, trying to do a sort of render target thing. I know 2.0 has render textures but I don't want to update unless I really need to (modified SFML somewhat and I heard they don't work at all on intel GPUs). Does sf::Image::CopyScreen() only copy stuff that was presented when app->Display() has been called? Or does it get everything that's been app->draw()n since the last clear?[/QUOTE] I'd update to 2.0 if you want to use render targets. That's the main reason I'm using 2.0, 1.6 doesn't look so great for such things. Nothing works on Intel GPUs so I wouldn't worry too much about that. I have a related question though, I'm using SFML 2.0 and creating render targets takes [b]ages[/b]. Using this code: [code] void setupRender(int width, int height) { Console::GetInstance()->WriteLine("Initializing graphics..."); sf::Clock c; if (!window) { window = new sf::RenderWindow(sf::VideoMode(width, height), "SSX", sf::Style::Close); gameCanvas = new sf::RenderTexture(); } window->SetSize(width,height); //window->SetFramerateLimit(60); gameCanvas->Create(width, height); std::stringstream out; out << "... that took " << c.GetElapsedTime() << "ms"; Console::GetInstance()->WriteLine(out.str()); } [/code] I get this output: [code] Console initialized. Connecting to 255.255.255.255:8123 Unable to connect to server. UDP Port bound Initializing graphics... ... that took 21341ms [/code] I've figured out it's the call to gameCanvas->Create that takes all the time. It doesn't matter what width/height is passed. Takes the same amount of time on my integrated intel laptop as my quad core desktop with an 8800GTS. What gives? EDIT: Sorry my bad, it's the [b]new sf::RenderTexture();[/b] that causes this.
Hey guys. Basically I'm in Intro to Programming, and we're learning Visual Basic and using Visual Studio. There's an extra part to an assignment that will get me 5 points added to my final grade, and I'd like to get those if possible. The part of the assignment I'd already done was a program where the user would put a number in a textbox, and then a character they want in the second textbox, so say "3" and "G" and then when the button is hit the ListBox would display 3 rows with G's, with one G being added every row, like this [code]G GG GGG[/code] Here's the code I'd used to do that, it's probably very shoddily made, but it got the job done. Since we're just now learning loops, the program HAS to be made using a loop of some sort. [code]Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click X = Val(TextBox1.Text) Do Until X = 0 X = X - 1 Z += TextBox2.Text ListBox1.Items.Add(Z) Loop End Sub[/code] Well, that part I've got down, but for the extra points, here's what he wants: [IMG]http://i54.tinypic.com/zjhu8w.jpg[/IMG] Basically he wants the characters to be in the center of the listbox and wants it to go from 1 character to 4 to 6, and then for the second part back down to 4 then 2 then 1. Any help that can point me towards the right direction in doing this would be greatly appreciated! Sorry if I'm being confusing in explaining this.
This might be random or desperate, but think anyone is willing to help a C++ noob out? I always have random questions or things I'm not sure how to do and it'd be nice to have an expert I could talk to occasionally on steam. Just give me your ID and I'll add you.
[QUOTE=Mr_Razzums;32912490]c++ Noob here. Objective is to test a bubble sort while doubling the array which it sorts by 2 each time. Everything goes smooth until like the 8th time it sorts where it crashes [code]//code[/code] I get this error and its driving me nuts Unhandled exception at 0x7578e124 in Lab07cs.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x003df64c.. Please help :([/QUOTE] std::bad_allocs are thrown when it could not allocate the memory. The 8th time should allocate 32KiB, which should be fine. Are you sure it's just the 8th time?
Probably going to have to create a new thread but here goes nothing, I had a game idea in my head for some years now and to keep a long story short it brought me from nothing into C++ over some years in which i gathered alot knowledge about my goal. Now i need to make a decision,should i create my own engine(been messing with SFML and it is going well for now) or should i just use a premade engine? I'm thinking that i won't be able to work my idea out as good as i wan't when i start from scratch but then again i would gain allot of knowledge from this. I have 2 choices in my head: 1.Source engine(probably will be a pain) 2.Create an engine(Could get some bugs which i likely will never be able to solve) What should i do? Also don't hesitate to report mistakes in my post,English isn't my native language.
If you want to make a game, use an existing engine. If you primarily want to learn about the insides of an engine, make an engine - though be prepared that if you want to finish the game it's probably going to be a long road. Considering the time you will take to write the engine and the influence it's going to have on the end-product will be minimal you should use an existing engine if you're mostly after getting the game done. Programming the engine might be fun and you'll learn from it, but the game itself won't benefit from that and will be further away from your reach. A mid-way between a full engine like Source and DIY is taking separate modules and stitching them together, e.g. OGRE (graphics), Bullet (physics), sfml-sound, boost::asio (networking) and SDL for input (I've just taken those by random, but they would work together).
[QUOTE=ZeekyHBomb;32920620]If you want to make a game, use an existing engine. If you primarily want to learn about the insides of an engine, make an engine - though be prepared that if you want to finish the game it's probably going to be a long road. Considering the time you will take to write the engine and the influence it's going to have on the end-product will be minimal you should use an existing engine if you're mostly after getting the game done. Programming the engine might be fun and you'll learn from it, but the game itself won't benefit from that and will be further away from your reach. A mid-way between a full engine like Source and DIY is taking separate modules and stitching them together, e.g. OGRE (graphics), Bullet (physics), sfml-sound, boost::asio (networking) and SDL for input (I've just taken those by random, but they would work together).[/QUOTE] I was planning to use existing modules to create my own engine if i would go that road. I have no experience creating an engine that's why i'm asking what option i should choose.
[QUOTE=Mr_Razzums;32912490]c++ Noob here. Objective is to test a bubble sort while doubling the array which it sorts by 2 each time. Everything goes smooth until like the 8th time it sorts where it crashes I get this error and its driving me nuts Unhandled exception at 0x7578e124 in Lab07cs.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x003df64c.. Please help :([/QUOTE] I could run it fine past the 11th iteration (where I killed it because bubble sort is slow with big arrays). This may something creating a memory cap as a precaution to memory leaks.
[QUOTE=0lenny0;32920976]I was planning to use existing modules to create my own engine if i would go that road. I have no experience creating an engine that's why i'm asking what option i should choose.[/QUOTE] You'll never get that experience if you never start :P OGRE is a viable rendering engine from what I've heard. It's been around for a while, it has a active community, some commercial games use it. You can just take a look at the wiki to see how to get started with it. There are also articles explaining how to integrate modules, e.g. physics and input.
[QUOTE=ZeekyHBomb;32921045]You'll never get that experience if you never start :P OGRE is a viable rendering engine from what I've heard. It's been around for a while, it has a active community, some commercial games use it. You can just take a look at the wiki to see how to get started with it. There are also articles explaining how to integrate modules, e.g. physics and input.[/QUOTE] I have messed around with Ogre before,i'm trying out some different things. Maybe i should just work on the Source Engine and after i'm done just try redoing it on custom engine.
Does anyone have any good working 2d collision detection code? I'm trying to make a really simple 2d physics game where stuff has gravity, velocity, etc but can't rotate. Each square has a random size (as a double (I'm using Java)) that determines how big it is. However, I can't find any sort of collision code that works. Can anyone help me?
Sorry, you need to Log In to post a reply to this thread.