Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

104 Neutral

About IggyT

  • Rank
  1. Taking less of a programming approach, I took out a picture editor and put everything where I wanted it. I think it'll become more difficult to make a program to contain the chaos rather than to manually contain it yourself. Unifying your artwork into a specific format will cut down the processing time/take away those bugs that can creep in from when something unexpected arises in another file. I don't know much about picture editors but if you found one with a grid I'm sure it'd help out a lot. (the alternative if making your own grid)
  2. If in the console you can use a simple char map[20][70]; //array And then use loops to set the outlying borders. Then a simple collision check would be to see when the character moves if that next space is whatever you use for borders, and if it is then -1 from his current location after you calculated that movement so that he's not inside the border before you display. alternatively you can set the borders at the declaration of the array, too. @SuperVGA ...huh, I had no idea they were so messy. I received the code from a friend that had been using it a while and blindly trusted it, thanks for the link.
  3. IggyT

    moving 2d array to 3d array

    It sounds like you want to just put the information from one array into another array, correct? If so this sounds like you just need a nested loop to solve your re-locating problem. int first=3; int second = 3; int sector[9] = {1,2,3,4,5,6,7,8,9}; int sector2[first][second]; for(int i = 0, s_count = 0; i<first; i++) for(int j = 0; j<second; j++, s_count++) //update s_count here so that it can update as the j position updates. sector2[j] = sector[s_count]; for(int i = 0, s_count = 0; i<first; i++) //this is for displaying the results and not part of the transfer process for(int j = 0; j<second; j++) cout<<sector2[j]; In this code s_count is kept track of so that you can add to each new array section first run through it starts at 0, the second at 3, third at 6...etc EDIT: I suggest doing as Krohm suggested, sketch this out, it'll give you a better understanding than someone just explaining it to you would.
  4. Are you talking about making a DOS game? If not, and working with only console application, then something you'll want to look into is how to clear the screen so that each new display is the only thing displayed. EDIT: took out some bad information
  5. Here's a wiki here that goes over a lot of this : http://wiki.gamedev.net/index.php/How_do_I_get_Started#Choosing_a_programming_language What it really boils down to is what do you want to get out of your language in the end. C# is similar to C and C++ and if you want to bridge it'd most likely be the best choice. Python decreases development time because it's a scripting language and once you learn it there's a good chance you'll just stick with it. From what I understand it's easy to use.
  6. Floats aren't 100% precise but this is a problem based on calculations being base 2 and can cause some collision errors. Int would be simplest to work with, it's easy to iterate and most positions in games can be scaled up or down to an int. Unless you're doing calculations that require you to use fractions or division (really the same thing)...I don't suggest using float.
  7. int DoLoad() //why output an int? { ifstream Profile1; Profile1.open("Profile1F.txt"); string Profile1V[6]; //this is an array of strings while (!Profile1.eof()) //this is a good practice { Profile1 >> Profile1V[5]; //with this you only access the last value of your array and therefore overwrite it every iteration } cout<<Profile1V[5]; //with this you only display the said last value of the array of strings Profile1.close(); //good practice return 0; } To make this simple, the only reason it's displaying 0 is the fact that you are only accessing the last memory section of the string array that you're making and you keep writing over it in each iteration of your loop so you end up with only the last value of your file. As a short lesson on arrays, arrays are safe temporary pointers, they allocate the size of whatever you're making the array of in memory space (in the case of strings you're making it the size of the string class in 6 slots side-by-side in memory) int array[6]; // is the same as declaring six separate integers. To access the first value of an array you start with 0 first value would be accessed using : array[0]; and the last is accessed using : array[5]; //one less than the number you originally used to allocate its size because the memory space begins with 0 Strings have the capability to resize themselves when you give them a new value (a string is a class that holds a resizeable const char array) so what you might want to do if you are only taking bool-type information in the file is just resize the string and add the new value in. (Or alternatively you can catenate like I did below.) string DoLoad() { ifstream Profile1; Profile1.open("Profile1F.txt"); string Profile1V; //this is a class that holds an array value for (int i = 0; !Profile1.eof(); i++) { Profile1V += " "; //this will resize your string by one space by telling your string to add in a blank space. THIS ONLY WORKS WITH STRINGS. getline(Profile1,Profile1V); //this will read to the newline symbol in each line of your file cout<<"\n"<<Profile1V; //this needs to be erased after you see the proof because it's unnecessary } Profile1.close(); return Profile1V; //send a copy of the string out into your program where you should put it in a function or loop that sorts it } This is a way of doing this, but to be honest you need to look into how arrays work and learn it very well. It's crucial to programming (as are pointers and addresses.) As a simple way of checking each of the values and putting them into a useable format do something like : string info = DoLoad(); //sets the value to what's output in my function above int size = info.length(); //sets to an easy to find and use variable holding amount of information you need bool YesOrNo[size]; //dynamically allocated array based on your information needs for(int i = 0; i<size; i++) //this checks each spot in your const char array (the string class called info I made above) { if(info == '0') YesOrNo = false; else if(info == '1') YesOrNo = true; else cout<<"\nThere was an error in loading!"<<endl; //while debugging or even after you need things like this to know why you program isn't working as planned. } //set the value accordingly here or use the bool array and have the values held elsewhere If you want to use this, give me some credit. But I suggest you make your own because it's your game and you'll need to decide how to deal with data.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!