Later "dat" is causing the heap corruption, even if it shouldn't. After many many many hours of figuring out why, I found out that the value of my "dat" pointer isn't the same as the value returned by the new operator (found it out by stepping into the new operator and looking what it returns). For example new returns 0x...e18, but "dat" is 0x...e1c. The offset is always 4 bytes long. This causes my program to fail when using for example _msize() function.
I heard that global variables are bad.. but what is the other way to use things like "Soundsystems" etc. g_SoundSystem has to be global so i can use it from any place in the program. I was also thinking about setting flags in certain points but that would also require global access. In other words: Can you help me in understanding how to replace globals?
I am trying to understand the basics of the pathfinding, but I don't understand the main idea. I understand how the algorithms work, for example A* algorithm. The thing that confuses me is how do I actually set the vertices. Let's say I have a tile-based map in a 2D game. Do I set them manually , for example in my level editor, and store the coordinates of the vertices in the array/list/tree/anything?
When learning to create games I always wonder if my way of thinking is "correct". Yeah, I know that when it comes to programming, everything that works and is free of bugs etc is correct. But I don't like this kind of approach, because I think it limits my self-development. What's more, games seem too complex for me, to allow myself to have this kind of approach. Here is something I was thinking about:
Let's say I want to create Tanks game, with the camera from above. Just a basic 2D game. And I want to create, for example, 5 levels, loaded from file. So here is my idea: I can create an array of integers, and save it to the file. Doesn't matter if it is made with an editor or manually (another conclusion: if creating levels the way I see it is correct, I am able to create a level editor, even with my very poor programing experience, hurray ). So let's say I have the 80x60 array of integers. Then, when the level is reached in the game, the constructor loads the array, and based on the numbers sets proper textures (10x10 px) in the right order. For example, when it finds "0" in the array, then the upper left corner will be an empty space, where the tank can move. Same with "1" for obstacle, and "2" for destroyable, for example a box. So basically, my level is just a set of 80*60 textures, positioned on the base of the array.
This is just an example, one of the many things that I find complex and confusing. I have talked with my friend, who has created some simple games. He said that his first level editor was just a huge "if/else" program. And this is what I am trying to avoid, learn the game development standards
For the past few days I have been working on the Pong clone. I have made it before, but I wasn't satisfied with the quality of the code, so I decided to rewrite it. I guess you all are bored, because of the Pong Clones attacking you from every side, but here it is: