Ways on Keeping My Game From Eating RAM

Pages: 1234
closed account (N36fSL3A)
I'm checking if the 2 tiles that belong overhead and share the same graphics are run over, so we just skip them and carry on.
closed account (o1vk4iN6)
1
2
3
4
5
6
7
8
9
// If we go too far down...
		if(_y > Res.TileSet_IMG->h)
		{
			// go back to the top
			_y = 0;

			// Move over one
			_x += TILE_W;
		}


If your tile height is 32, and your image is 32 in height, this will be false and you won't move over to the next column.

Also names with a prefix underscore are reserved in C++.
Last edited on
closed account (N36fSL3A)
My image will never be 32 pixels in height.

The tileset will be required to be 160 pixels in height. (5 tiles)

The width can be infinite.
closed account (o1vk4iN6)
That was an example to make the error more obvious. It doesn't matter the height of the image, it will always count an extra tile outside the bounds because the y position is going to be equivalent to the image height which you do not check for.

It's like array bounds, you are considering an index of 1 valid for an array of size 1 when only 0 is a valid index in this case.
Last edited on
closed account (N36fSL3A)
I have no Idea on how to fix this. So it would be y + 32?
closed account (o1vk4iN6)
Well from the code you already have you'd just have to do...
 
if(_y >= Res.TileSet_IMG->h)


I forget was it you who said they were advanced in C++ and made 2-3 games or someone else :/.
Last edited on
closed account (N36fSL3A)
I made a space shooter and I made a box game. :P

But I've been working on an RPG game for the longest, which explains why my code has bad programming practices.

Thanks xerzi! I put _y + 32, but I'll change it to >= now.
closed account (N36fSL3A)
Would changing my maps to binary reduce ram usage?
Would changing my maps to binary reduce ram usage?


Maybe the code that loads the maps might use less memory, but once the maps are fully loaded there won't be any difference.

Remember... RAM is just how much memory you're using. IE: how many variables you have allocated. If storing the map as binary means you are using fewer variables, then that means reduced RAM usage.

Though I doubt how the map is stored in a file will change how the map is stored once loaded in memory -- which is why it wouldn't make a difference.
closed account (N36fSL3A)
So, would you recommend me doing it?
It's really up to you. How you store files has literally 0 impact on the program apart from the loading process.

Binary maps are harder to edit and easier to load.
Text maps are easier to edit and harder to load.

If you already have a working text loader and it performs reasonably well, I see no reason to switch to a binary format.

If you switch to a binary format, you'll probably need to make some kind of map editor to be able to easily modify the maps.
closed account (N36fSL3A)
That's what I was planning on doing.

I don't want people break my game.
If you are going to write an editor then I would tend to prefer a binary format.
closed account (N36fSL3A)
Can I save ti the same way I do now, just use the .write() function fstream objs have?
I wouldn't recommend it. But it depends on how portable you want it to be.

I made a post about this topic a while back that got turned into an article.

http://www.cplusplus.com/articles/DzywvCM9/
closed account (o1vk4iN6)
I don't want people break my game.


Making your files binary format won't stop people from breaking your game. People are still able to deduce usually what they are by looking at multiple files, the names of the files, as well, binary data isn't some magical thing.
closed account (N36fSL3A)
I know. But I don't want the average joe to just f*ck up my game by changing a few values.
Bad news. Chances are that only a handful will bother playing your game. In truth you are making the game for you. If the end user wants to change values in your game they will crack it.

Yes, that means all these companies saying they are making their games for the gamers are actually lying. They are making the game for themselves and hoping others will like it as much as they liked making it. Do you think back in the early 90s gamers asked for Mortal Kombat or Street Fighter? No! The developers decided they wanted to make it and hoped it would be liked by others. All we, as game programmers, can do is make the game and hope a lot of people play it.

In other words, stop worrying about people hacking your game and just make the game already. Being able to mod games are the norm now (ie the Oblivion and Skyrim, Fallout 3 and New Vegas).
closed account (o1vk4iN6)
(ie the Oblivion and Skyrim, Fallout 3 and New Vegas)

Can't really call it the normal and list such biased examples of games which were all developed by a single studio...

Yes, that means all these companies saying they are making their games for the gamers are actually lying.


Not really, a lot of games are dumbed down and made easier to accommodate the average gamer so they will not feel frustrated while playing the game so that they will continue to do so. The only ones that are actually like this are smaller indie teams which can experiment with features and gameplay as they don't have to usually fill expectations when millions are being poured into a game. Games like minecraft or even now with crowd funding games like planetary annihilation.
Last edited on
xerzi wrote:
Can't really call it the normal and list such biased examples of games which were all developed by a single studio...

Not biased. I own the PS3 versions of all those and have never touched the PC version as I don't mod. Single studio or not those are the 4 largest modded games of their time which is the only reason I listed them. Minecraft is so you can mod it, but you have to know Java in order to even do that. With Elder Scrolls and Fallout you are given tools where you build the levels, items and everything you want, set the data in the tools and then the tools let you put them in the game or even publish them for other owners of the game to play the mods.

xerzi wrote:
Not really, a lot of games are dumbed down and made easier to accommodate the average gamer so they will not feel frustrated while playing the game so that they will continue to do so.

They don't dumb it down for the gamer, the dumb it down in fear the gamer will get frustrated with the game and leave it. The history of games prove this, older games challenged you and were damn hard to beat, but now the games are easy to beat. This discussion made me think of this video (WARNING the guys voice is a little grating) http://www.penny-arcade.com/patv/episode/when-difficult-is-fun

I'm a huge Metal Gear fan, and to date I have never been able to beat Metal Gear or the recent release of Metal Gear 2. Yet I have played and beat MGS, MGS2, MGS3, MGS VR Training, MSG4, MGS Acid, MGS Acid 2, MGS Peacewalker, and yet to play Revengeance.
Last edited on by closed account z6A9GNh0
Pages: 1234