Jump to content
  • Advertisement

squicklid

Member
  • Content Count

    173
  • Joined

  • Last visited

Community Reputation

132 Neutral

About squicklid

  • Rank
    Member
  1. squicklid

    Are globals really THAT bad?

    I hate globals for the most part. Globals cause spaghetti code - macrame of frail data. Pull one piece, and everything unravels. I have seen it used extensively in a professional setting, and it is bad. Bad programming practice made people set globals before calling a subroutine, and then they check the globals after it returns. You should pass things as parameters. If there are too many values to pass, put them into a structure and then pass that. If a function needs to pass back a lot of data, have it take a pointer to a structure, and populate it. There are very few times when you should be using globals. Real modular programming avoids globals like the plague because they are so hard to maintain.
  2. squicklid

    deleting **int

    No, that memory is on the stack, and is automatically destroyed when it becomes out of scope.
  3. How do I call a routine of one Form from another Form? Is there some System::blah::blah that a I can use to get a list of the currently open Forms? -G
  4. squicklid

    Good ways to store 2D wall data?

    C code: struct Tile { ImageInfo image; bool walkable; }; Tile map[WIDTH][HEIGHT]; This is the best way to do it.. that I can think of anyway. It would be quite wasteful to use a list to store wall information. -Garrett
  5. squicklid

    Math question

    #include <stdio.h> int plus(int a, int b) { int counter = 0; while (counter<a) total++; counter = 0; while (counter<b) total++; return total; } void printError() { printf("Invalid command line parameters.\n"); printf("usage: add 2 2\n") } int main(int argc, char **argv) { if (argc < 2) { printError(); return 1; } else if (*argv[1] != '2' || *argv[2] != '2') { printError(); return 1; } printf("2 + 2 = %d\n", plus(2, 2)); return 0; }
  6. Runtime Library is set to Multi-threaded DLL (/MD). Garrett
  7. I have made several 2d map editors and I have used a 2d array to store map data in every one. However, I made them in VB5. I made a picture box for the "map". When the actual map data is modified, this picture box gets redrawn(also on the paint event). When the user clicks on the picture box, you can find out what tile they clicked on by using integer division. xTile = xPixel / TILE_SIZE_X; yTile = yPixel / TILE_SIZE_Y; map[xTile][yTile].tileIndex = selectedTile_; map[xTile][yTile].penetrable = isPenetrable_; Where selectedTile_ would be a member variable that is an index or reference to a pallet of tiles you have created. And isPenetrable_ describes whether you want to be able to walk through it or not. You can add as much stuff to these as you want.
  8. squicklid

    Rotate and Resize RGB bitmap

    I imagine a resize would involve calculating the new percentage (if it is smaller than the original) and then only copying every n pixels. This of course would be very blocky and unattractive looking. To make it larger you would do nearly the same thing, except for every n pixels you would copy twice or thrice... or more, depending on how large you are making it. To rotate is a whole 'nother story involving trig.
  9. I am using Microsoft Visual C++ 2005 Express. When I try to build my project on Release mode with "Maximize Speed" set as a compiler option, I get an error when I try to get the c_str() of a std::string. example: #include <string> using namespace std; int main() { string s = "bob"; const char *t = s.c_str(); return 0; } I get the linker errors: main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) char const `private: static char const * __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@CAPBDXZ@4DB) main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static char const * __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Nullstr(void)" (__imp_?_Nullstr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@CAPBDXZ)
  10. squicklid

    "this" pointer destroyed (c++)

    No that is in debug mode
  11. Does anyone agree that the "while" keyword of C'ish langauges should be "whilst"?
  12. squicklid

    "this" pointer destroyed (c++)

    I am quite sure it has to do with the string class. #include <string> using namespace std; int main() { string s = "bob"; return 0; } This compiles, but when I try to run it, I get this: Unhandled exception at 0x00000000 in test2.exe: 0xC0000005: Access violation reading location 0x00000000. It sure doesn't look like this code accesses null memory addresses. It works, however, if I take out the line 'string s = "bob"' Garrett
  13. squicklid

    "this" pointer destroyed (c++)

    I removed that line of code and the program runs fine. I was doing this: string s = "blah"; loadMap(s); And I changed it to this: loadMap("blah"); Now it works... Garrett
  14. squicklid

    "this" pointer destroyed (c++)

    I would have posted some code, but I thought I'd spare you the flood. Maybe I'll put it this way: is there an option that needs to be changed in order to use standard strings, or maybe win32 functions?
  15. I switched compilers from VC++6 to VC++2005 Express and now... Suddenly and Magically, it doesn't run. It compiles, but doesn't run. I am able to run the exact same code with version 6. Here's what's happening: I stepped through the game in version 2005 and directly after I create a std::string, the "this" pointer of the current class becomes some apparently random number, causing obvious crashing. It seems like the string is copying over the program's memory, but why? It is the standard template library... and it works in other compilers. And no, I am not using the CLR. -- std::string s = "C:/maps/jim.map"; -- Garrett
  • 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!