• Content count

  • Joined

  • Last visited

Community Reputation

103 Neutral

About mapPhil

  • Rank
  1. Thanks haegarr, that sound's like a great solution to my problem. Do you know of any tutorials/examples of how to do this?
  2. Apologies for the lack of detail. [quote name='BitMaster' timestamp='1354269477' post='5005645'] For something as tiny as 10000 (int, string, int) I see no problem with keeping the data in memory. [/quote] I am creating a list for a GUI and considering the the amount of data in the list could be exponential, even larger than 10,000 - though it's unlikely it is certainly possible. On top of this I am my list can handle a varied amount of columns. All of the data will actually be strings, even in the example in my first post. I have not used the file libraries much, but the code I wrote is this to create the file: [CODE] std::ofstream file;"data.bin", std::ios::in | std::ios::out | std::ios::binary | std::ios::app); std::string str = "0,Hello World,0"; std::string::size_type sz = str.size(); if (file) { for(int i = 0; i < 10000; i++) { file.write(str.c_str(), strlen(str.c_str())); file << std::endl; } } file.close(); [/CODE] If this is incorrect please let me know. Note: I actually won't be creating the binary file myself, only receiving the file and reading the data in FetchData method. The main problem presented is my list works perfectly fine up until I require the 4000th row then It becomes noticeably slower, this is because I am iterating through the file until I reach the index required.
  3. hi all, Basically I want to find the quickest way in which to search for data quickly, from a binary file. For example my bin file will contain data such as: 0,Hello World,0 0,Another World,1 Now I would like to search for each new line of a 10,000 (possible more) .bin file. Currently I am doing it this way: [CODE] void FetchData(const unsigned int& line,int column, std::string& data) { if (file) { // reset file pointer to beginning file.clear(); file.seekg(0, std::ios::beg); if (fs.good()) { // search for the desired line and exit loop for (int i = 0; i < (line+1) && file.eof() == false; i++) { std::getline(file,data); } } } } [/CODE] This does work, but are there any more efficient approaches I could take? I am also required to modify such data, but I am currently storing the .bin file in a vector temporarily and the modify particular elements of the vector and then overwrite the existing .bin file with the latest data. If there is a more efficient approach to this please let me know? Also on a side note, how would performance differ between using an .xml instead of a .bin file ? Thank you for any help offered.
  4. Hi, Can anyone recommend a resource for me to learn how to effectively do this? Only 7 images will be visible at once.
  5. I would like to know how I do the bounce effect which is like the one that appears on the iPhone when you scroll up fast and reach the end. I currently have the swipe and can detect when I reach the end. So when I reach the end I have the current position and the velocity in which the swipe travelled at? Any help will be appreciated
  6. Rotating Time Animation

    [quote name='BeerNutts' timestamp='1322510204' post='4888553'] Here's how I would do it: [code] // StartTime is the time you started // ROTATION_TIME is the time you want it to rotate from 0 to 90.0f delta = CurrentTime - StartTime; RotationDegrees = 90.0f * (delta/ROTATION_TIME); [/code] Basically, as time passes, delta will get closer and closer to ROTATION_TIME, which means (delta/ROTATION_TIME) will get closer and closer to 1. So, when it's 1, it will have rotated 90 degrees. You stop when (CurrentTime - StartTime) == ROTATION_TIME [/quote] Thank you, would start time be the [color="#1C2837"][size="2"]animTimeDelta then?[/size][/color] Would this also work when the rotation is relative?
  7. Rotating Time Animation

    Hi I want to rotate an object based on time using the x axis and rotating to 90 degrees I so far have but I know it's wrong? Any help would be great. float currentTime = time; float delta = currentTime - animTimeDelta; float delta = (90.0f * delta) / rotationTime; // rotation time will be 0.6f rotation_value += delta; if(rotVal > 90.0f) rotVal -= 0.0f; // should rotate the object using rotVal?? animTimeDelta = currentTime;
  8. Calculating Centre of changing shape

    Thank you for all the replies, I have solved it myself fortunately using the law of sines, right triangle and a ormula I developed, Oh and what I meant by a new polygon being added up, was that I would start off with 3 polygons for the triangle (no top face or bottom face). And then add another polygon to the scene to turn it into a square and so on, until there 360 polygons.
  9. Calculating Centre of changing shape

    [quote name='apatriarca' timestamp='1320774322' post='4881818'] Are the edges described in some order (i.e. clockwise)? Are the polygons convexes? In what coordinate system should the centre be described? Do you know something else? [/quote] Sorry if i wasn't descriptive. I start off with a 3d triangle in 3d space (x,y,z). The polygons are convexes. The things i would know = Centre point of the 3d triangle. The dimensions of each polygon. All the polygons will be the same height and width. A new polygon (4 vertices) will be added up until there are 360 sides.
  10. you have the length of each side, but the number of sides is ever changing for example a triangle will turn into a square and then into a octagon. How would i go about finding the centre point each time? Thanks
  11. Hi, I know how to create a digital clock using #include<time.h> but will this header allow me to set the time as well? if anyone can point me in the right direction that will be great. Thanks
  12. Lets say you have a class called spaceship and that class inherited a weapon class and an asteroids class. All of these classes feature a void controls function, would you declare all of the occurrences of the controls function virtual considering the spaceship class is inheriting it from two headers? I know it would compile but what is the recommended way? Thanks
  13. HighScores equal too problem

    ^Yeh i know, i was just trying anything to get it to work [quote][color="#1C2837"][size="2"]'d have to see more context to know for sure, but it seems to me like the problem is you copy the high score into the top slot, then notice that it should displace all the other scores below it, and move them down; problem is, each score moved down is still "equal to" the high score, because the old high score is identical. So you again shift down the list, rinse, repeat, until all the slots are full of the same entry.[/size][/color][/quote] That was it thank you, i just needed to to clear the points at the end of the if statement
  14. HighScores equal too problem

    Out of curiosity is there a reason why my code example would not work?
  15. HighScores equal too problem

    [quote name='ApochPiQ' timestamp='1308604081' post='4825656'] Why not just add all the high scores to a container, sort it, and then remove the lowest n entries until you get to the maximum number of high scores you want to display? [/quote] Yeh that sounds easy enough, will give that a try, thanks