• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


  • Content count

  • Joined

  • Last visited

Community Reputation

146 Neutral

About tendifo

  • Rank
  1. Quote:Original post by alvaro The line `in >> temp;' reads in an integer from the file, in decimal. If you want to read a single character you shouldn't use an int variable. I know. The format I'm using goes kind of like this.. 0 0 0 1 1 1 ... 0 1 0 0 0 0 ... ... The 0s and 1s are characters (.. with spaces as delimiters). If I understand correctly how ifstream works, then "in >> temp" will read either a 0 or a 1 into temp, which is what I want. Hopefully that makes sense.
  2. Some code of mine doesn't seem to be working (it compiles and runs, but doesn't output the right thing). I recreated the problem with the following code (I stripped out all the irrelevant code). #include <fstream> #include <vector> int main() { std::vector < std::vector < bool > > h; std::ifstream in; std::ofstream out; int temp; for (int x = 0; x < 1024; x++) { h.push_back(std::vector < bool > ()); for (int y = 0; y < 768; y++) { h[x].push_back(false); } } in.open("h.txt"); for (int y = 0; y < 768; y++) { for (int x = 0; x < 1024; x++) { in >> temp; if (temp == 1) { h[x][y] = true; } else { h[x][y] = false; } } } in.close(); out.open("whattheheck.txt"); for (int y = 0; y < 768; y++) { for (int x = 0; x < 1024; x++) { if (h[x][y] == true) { out << "1"; } else { out << "0"; } if (x < 1024 - 1) { out << " "; } } out << std::endl; } out.close(); return 0; } The file, h.txt, contains a huge array of 0s and 1s (768 lines with 1024 1s and 0s). I read them into an array (a vector of vectors). Then I try writing them back out into the file, whattheheck.txt, in the same format. Every time I run this, I get all 0s, even if the input file had a large number of 1s. What could be causing this? Should I try something besides a vector of vectors? Am I reading it in wrong? FYI, I'm running it on a SGI Octane2 running IRIX. Thanks. Edit: If it's not already obvious, this is C++.
  3. I wouldn't blame the format because it is in ASCII. I don't think the performance loss is as great as you think.
  4. Quote:Original post by yacwroy Unfortunately, I'm not really a fan of shared_ptr though, and it's way too heavy for this use (not that that's too important). boost::shared_ptr is no more heavy than std::auto_ptr.
  5. I don't have the time to respond to all of these, but #4 and #5 caught my eye. #4) A pointer is 4 bytes wide. An int is (usually) 4 bytes wide. So passing one or the other makes no difference to speed. If you're so worried, do func(const int& blah). But really, this is pointless also. #5) Don't do that. There's no point to allocate 4 bytes (once again, usually) on the heap for one int. And the overhead of std::vector, std::list, etc is minimal. You shouldn't need to declare and allocate raw arrays on a normal basis. And in general.. 10,000 lines of code in one file is insane. Split it up into multiple files at least. I don't know how you even managed the code like that.
  6. Why not just keep a frame count, and after each second, spit it out, and reset it to zero?
  7. Computer Graphics: Principles and Practice by Foley, van Dam, Feiner, and Hughes Anything and everything related to computer graphics.
  8. Because the ASCII character set is a subset of most wide character sets, and still have the values 0-255 (the higher-order byte is just 0), this would work. std::string charstring = "hello, world"; std::wstring widestring; for (int i = 0; i < (int)charstring.length(); i++) widestring += (wchar_t)charstring[i]; LPCWSTR lpcwstr = widestring.c_str(); Although, LessBread's method is probably safer to use.
  9. Quote:Original post by GenuineXP While I'm at it, are there versions of std::log for any base other than e and 10? I've been using this hack so far. float r = std::log(x) / std::log(2) This (I think) yields the log base 2 of x. Messy, eh? Not only that, but I didn't bother with the use of static_cast<> here. Also, this obviously isn't ideal since I'm taking the natural logarithm of two numbers! I've seen hints online of a std::log2 function, and haven't tried to use it, but I've also read online that it doesn't exist (i.e., isn't standard). That's not a "hack"; it's a legit way of doing logs. Most computers/calculators/etc with math functionality don't come with anything but base 10 and base e logarithms because you can just do what you're doing now and divide by the logarithm of the base you want. If you're so intent on having a log2 function, make your own that wraps up what you're doing there. As for using int-specific functions, you could wrap the float and/or double functions into int functions of your own. Then you don't need to cast in your actual code.
  10. Take a look at this. http://en.wikipedia.org/wiki/Declaration_reflects_use I still prefer it this way, though: int* f; and not: int *f; But just my opinion.
  11. Quote:Original post by the_edd What's wrong with this: somebrush.draw_line(somesurface, x1, y1, x2, y2); ? I think it might get a bit tiring to type somesurface over and over again, especially if I'm drawing more than just a line or two.
  12. Quote:Original post by Spoonbender How about the obvious? Prevent the surface from getting destroyed while there are valid brushes attached to it? If this is C/C++, you can do that with smart pointers easily If I explicitely destroy the Surface, I want the Surface to be destroyed. I don't want it to stay alive as long as a Brush is using it. So it's not as simple as using a boost::shared_ptr or something like that. I may end up going with a variation of my (2); although, instead of having the Brush and Surface class handle the connection issues, I may push them into an auxillary connection class.
  13. I have two classes, Surface and Brush. The idea is that Surface provides a drawing surface (and handles all the system resources) and Brush does all the drawing on that surface. The way I want to do it is like so. Surface surf(500, 400); // Create a surface of size 500x400 Brush brush(surf); // Create a brush for the surface brush.draw_line(0, 0, 100, 100); // Draw a line from (0, 0) to (100, 100) I have this working quite nicely, but my concern here is that if we create a Brush somewhere and then the Surface gets destroyed, then we have a Brush that points to a Surface that no longer exists. I have two solutions for this. 1) Keep a running list of surfaces that still exist. Then the Brush can check if the surface it points to exists anymore. (This is how I'm doing it now). 2) Create a connection between the Brush and Surface. The Surface keeps track of which Brushes are assigned to it, and alerts them when it gets destroyed. (I was doing this, but switched to (1) after a while because it's simpler). What I'm wondering is which way is better or if there's a better method beyond these two. Connections betweens objects always seem messy in my opinion, so I'm leaning towards (1), but I'm open to other ideas. Thanks.
  14. Yea, I'll have to do something like that. I was just hoping C++ supported some special thing that would allow me to do it. Thanks anyway.
  15. Is there any easy way of making this work? I want the method do_something(), which is defined in a nested class, to have access to members of the parent class. #include <iostream> using namespace std; class some_class { public: int some_number; class { public: int do_something() { some_number++; } } some_object; some_class() { some_numer = 0; } }; int main() { some_class blah; blah.some_object.do_something(); cout << blah.some_number << endl; system("pause"); return 0; }