• What do you need help with? Version 1
    5,001 replies, posted
maybe your mouse coordinates need to be converted to world coordinates (if you have a camera or something)
[QUOTE=turb_;23421469]are you 64 bit or 86 bit [editline]09:42PM[/editline] are youn 64 bit or 86 bit??[/QUOTE] 86 bits is a lot of bits
Could I get someone to help me with my Programming issues over Steam? :frown:
[QUOTE=Zally13;23441360]Could I get someone to help me with my Programming issues over Steam? :frown:[/QUOTE] You could just post here. There's no such thing as stupid questions, after all.
I feel as if it's one of those easier things to talk to personally, on Steam. However, I suppose I can post it here. Basically, I made a code. I am going really slow in my book, I really want to understand everything before I continue on. Anyways, this is my code: [code]// ask for a person's name, and greet the person #include <iostream> #include <string> int main() { // ask for the person's name std::cout << "Please enter your first name: "; // read the name std::string name; // define name std::cin >> name; // read into name // write a greeting std::cout << "Hello, " << name << "!" << std::endl; return 0; } [/code] I saved it as "2_workingwithstrings.cpp" and I have issues attempting to debug it. It's probably my fault. Basically, when I hit the Debug Button on the top toolbar, the little play button, it says my Project is out of date, so I hit Yes to build it. It then starts to Build it, and says: [code]Unable to start program 'CL\Users\Josh\Documents\Visual Studio 2010\Projects\getting_started\Debug\getting_started.exe'. The system cannot find the file specified.[/code]In the Output for the Build, it says: [code]1>------ Build started: Project: getting_started, Configuration: Debug Win32 ------ 1> 2_workingwithstrings.cpp 1> LINK : C:\Users\Josh\Documents\Visual Studio 2010\Projects\getting_started\Debug\getting_started.exe not found or not built by the last incremental link; performing full link 1>getting_started.obj : error LNK2005: _main already defined in 2_workingwithstrings.obj 1>C:\Users\Josh\Documents\Visual Studio 2010\Projects\getting_started\Debug\getting_started.exe : fatal error LNK1169: one or more multiply defined symbols found ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== [/code]
You're compiling two code modules (.cpp files, basically) with main functions, you must only define one. In Visual Studio, there's probably an option you can check for your files to disable compiling/linking for that file. If not, simply remove the other file from the project and rebuild.
Ah, didn't know that. Thanks. It worked!
Am I using too many if statements? Is it okay to loop the program with a while loop? :v: I don't know what I'm doing. [code]namespace MenuSystem2 { class Program { //Fixes line placement according to the Wrap varible. static int NoWrap(int line, int opt) { if (line < 1) { line = 1; } if (line > opt) { line = opt; } return line; } static int YesWrap(int line, int opt) { if (line < 1) { line = opt; } if (line > opt) { line = 1; } return line; } //If conditions are met, then an X will be drawn next to the selected option. static void xDraw(int line, int no) { if (line == no) { Console.WriteLine("[x]"); } else { Console.WriteLine("[_]"); } } static void Main(string[] args) { //Varibles indicating status int Running = 1; int Exit = 0; int Line = 1; int PauseMsg = 0; int FirstRun = 1; int DebugMode = 1; //MainOptions int Wrap = 0; //Menu OPTS int Menu = 1; int MainOptions = 4; int Options = 4; //Buffer string Buffer = " "; string CurrentOption; //Other ConsoleKeyInfo keys; //Main loop while (Running == 1) { Console.Clear(); Console.WriteLine("==FUNKY MENU=="); Console.WriteLine("Select an option: \n"); //MainOptions if (Menu == 1) { Options = 4; Console.Write(" 1. Run Program "); xDraw(Line, 1); Console.Write(" 2. Options "); xDraw(Line, 2); Console.Write(" 3. About "); xDraw(Line, 3); Console.Write(" 4. Exit "); xDraw(Line, 4); } //Options if (Menu == 2) { Options = 2; Console.Write("1. Wrap On/Off "); xDraw(Line, 1); Console.Write("2. Back "); xDraw(Line, 2); } //Debug Info if (DebugMode == 1) { Console.WriteLine("\n\n=DEBUG INFO="); Console.WriteLine("Value of Line: {0}", Line); } // //Reading for keys is below // keys = Console.ReadKey(); if (keys.KeyChar == '1') { Line = Line - 1; } else if (keys.KeyChar == '2') { Line = Line + 1; } else if (keys.KeyChar == '3') { /////////////////// //Menu1's Options// /////////////////// if (Menu == 1) { if (Line == 1) { Buffer = "Not yet Implimented..."; } else if (Line == 2) { Line = 1; Menu = 2; } else if (Line == 3) { Buffer = "Not yet Implimented..."; } else if (Line == 4) { Running = 0; } } } //Checking Options are true if (Wrap == 0) { Line = NoWrap(Line, Options); } else { Line = YesWrap(Line, Options); } } } } }[/code]
Quick question, is it possible to include a Python file as a header file for C++?
[QUOTE=slayer20;23469123]Quick question, is it possible to include a Python file as a header file for C++?[/QUOTE] Can your C++ compiler compile python?
[QUOTE=Chris220;23469271]Can your C++ compiler compile python?[/QUOTE] No idea. But is it possible?
You can include any type of file as long as it is text for either C or C++. Just make sure you keep the header guards there (Are you trying to make a polyglut?)
As chandler said, you can include any (plaintext) file The reason I asked if it can compile python is because it won't be able to compile an include python file, if it can't compile python code
[QUOTE=Chris220;23470456]As chandler said, you can include any (plaintext) file The reason I asked if it can compile python is because it won't be able to compile an include python file, if it can't compile python code[/QUOTE] So it would only work for polyglots.
How can I make an object move towards a point? [code] if(a.x > b.x) { a.x --; } ... [/code] Works, obviously, but that does one axis then the other. I need it to move diagonally, following a path. Do I need to use trigonometry or something? D: Maybe this: [URL="http://www.policyalmanac.org/games/aStarTutorial.htm"]http://www.policyalmanac.org/games/aStarTutorial.htm[/URL] Oh, I don't know. Help? :v: [editline]08:08PM[/editline] (C++ and SDL, by the way)
If you want it to move the specified distance every frame, then yes, trigonometry.
I need some way to split a large area (image in this case) into several smaller chunks with a maximum area of 32767 pixels. The width/height ratio of the chunks doesn't matter as long as they are all equally sized and with an area smaller than 32767. Please help.
Try something like a BSP style thing. Split your image in two. Are the two parts less than max size? No, split again. Are the 4 parts less than max size? Do this until all parts are less than max size.
god fucking damnit I don't get A* pathfinding AT ALL. I've read through a million tutorials and still can't even get close to anything. makes me wonder if I should just quit programming in overall if I can't figure out basic things
[img]http://maurice.gmod.de/halp.png[/img] The block is made up of 1 body, which holds 4 shapes (each square). I am removing the stuff that is between the green lines. How am I supposed to know if the thing that's left of 1 is connected to the rest? Hell, how am I supposed to know the rest of 2 and 3, and 4 are still connected? Relevant functions are [url]http://love2d.org/wiki/Body[/url] and [url]http://love2d.org/wiki/Shape[/url] .
is there any way at all to implement pathfinding on a C++ console app? eg. in a 2d array of chars
[QUOTE=NotMeh;23513934]god fucking damnit I don't get A* pathfinding AT ALL. I've read through a million tutorials and still can't even get close to anything. makes me wonder if I should just quit programming in overall if I can't figure out basic things[/QUOTE] This is a great tutorial: [url=http://www.policyalmanac.org/games/aStarTutorial.htm]A* Pathfinding for Beginners[/url]. It also includes sample code in C++ and Blitz Basic (whatever that may be).
This is the first result on google if you enter almost anything about pathfinding. Do you honestly think I didn't read through it all? Without an example code I don't get anything at all and the library this guy used is crazily confusing.
You would be surprised how many people ask stuff here without ever looking it up. Also, what do you have a problem with? Understanding how it works or actually coding it?
[QUOTE=NotMeh;23515517]This is the first result on google if you enter almost anything about pathfinding. Do you honestly think I didn't read through it all? Without an example code I don't get anything at all and the library this guy used is crazily confusing.[/QUOTE] Why would you need example code? Learn the language itself first, then read through that guide. You should be able to apply it yourself. Then come back if you have specific problems of course.
[QUOTE=Jawalt;23482811]Try something like a BSP style thing. Split your image in two. Are the two parts less than max size? No, split again. Are the 4 parts less than max size? Do this until all parts are less than max size. [/QUOTE] Finally got around to implementing that and it works remarkably well, thanks. Obligatory screenshot: [img_thumb]http://ace.saxservers.net/stuff/MrTD/returnofmrtd3.png[/img_thumb] That is a 512x256 terrain made out of 128x128 parts.
Um I have a problem with my bios. When I change one of the settings and save them, Windows doesn't load, the screen stays black after, any help?
[QUOTE=Maurice;23514088][IMG]http://maurice.gmod.de/halp.png[/IMG] The block is made up of 1 body, which holds 4 shapes (each square). I am removing the stuff that is between the green lines. How am I supposed to know if the thing that's left of 1 is connected to the rest? Hell, how am I supposed to know the rest of 2 and 3, and 4 are still connected? Relevant functions are [URL]http://love2d.org/wiki/Body[/URL] and [URL]http://love2d.org/wiki/Shape[/URL] .[/QUOTE] Use floodfill. If they're not all filled something is unconnected.
[QUOTE=ace13;23520680]Obligatory screenshot: [img_thumb]http://ace.saxservers.net/stuff/MrTD/returnofmrtd3.png[/img_thumb][/QUOTE] I recognize my world heightmap :v: Anyway, I'm working on one of my first Android apps. All it's supposed to do is show your IP address. This way it works fine: [cpp]try { URL site = new URL( "http://www.overvprojects.nl/ip.php" ); URLConnection con = site.openConnection(); BufferedReader reader = new BufferedReader( new InputStreamReader( con.getInputStream() ) ); String ip = reader.readLine(); ipText.setText( ip ); reader.close(); } catch ( MalformedURLException e ) { e.printStackTrace(); } catch ( IOException e ) { e.printStackTrace(); }[/cpp] But because I want to learn how sockets work, I rather do it manually with sockets. So I came up with this: [cpp]Socket sock = null; PrintWriter out = null; BufferedReader in = null; try { sock = new Socket( "www.overvprojects.nl", 80 ); out = new PrintWriter( sock.getOutputStream(), true ); in = new BufferedReader( new InputStreamReader( sock.getInputStream() ) ); } catch ( UnknownHostException e ) { e.printStackTrace(); } catch ( IOException e ) { e.printStackTrace(); } out.println( "GET /ip.php HTTP/1.1" ); out.println( "Host: www.overvprojects.nl" ); out.println( "" ); out.flush(); String buf = ""; while ( buf != null ) { try { buf = in.readLine(); } catch ( IOException e ) { e.printStackTrace(); } if ( buf != null && Pattern.matches( "^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$", buf ) ) { ipText.setText( buf ); break; } } try { in.close(); out.close(); sock.close(); } catch ( IOException e ) { e.printStackTrace(); }[/cpp] That works, however it takes an extremely long time to finish the request, which I don't understand because it's supposed to disconnect as soon as it's found the IP Address. I added [cpp]ipText.setText( "Broke out of the loop!" )[/cpp] and this is printed, yet it still freezes until the connection times out. What am I doing wrong?
I am a babby programmer and bad with math, please help me figure this out: (c++) [code] char map[500][500]; void genwilderness() { int i,j,k,r; //i = x; //j = y; for (k=0;k<500;k++) { r = rand() % 3 + 1; if (r == 1) { map[i][j] = 'T'; } else if (r == 2) { map[i][j] = ','; } else if (r ==3) { map[i][j] = '.'; } i++; if(i > 100) { i=0; j++; } if (j > 100) { break; } TCODConsole::root->setChar(k,k,map[i][j]); } } [/code] the problem with it is that it only generates wilderness along a single line, which is slanted. It should be filling the entire screen with random trees and ground, and then should break when it hits a certain point. edit: Ok, I've fixed it sort of, but now it won't run at all: global.hpp [code] void startgame() { TCODConsole::root->clear(); TCODConsole::root->flush(); mapisgen = true; while (gameisrunning & !TCODConsole::isWindowClosed()){ TCODConsole::root->printCenter(40,15,TCOD_BKGND_NONE,"Rogue Town Alpha Build"); while(mapisgen){ genwilderness(); TCODConsole::root->flush(); } } } [/code] map.hpp [code] bool mapisgen; char map[500][500]; void genwilderness() { int i,j,k,r; //i = x; //j = y; while(j<=60){ for (k=0;k<500;k++) { r = rand() % 3 + 1; if (r == 1) { map[i][j] = 'T'; } else if (r == 2) { map[i][j] = ','; } else if (r ==3) { map[i][j] = '.'; } i++; if(i == 500) { i=0; j++; } TCODConsole::root->setChar(i,j,map[i][j]); } } mapisgen = false; } [/code]
Sorry, you need to Log In to post a reply to this thread.