Progress.

Published August 15, 2006
Advertisement
Phew, I've done "alot" of programming lately. The first thing I did(which I did over a week ago) was to add HTML support for my logging system(including bold and colored text [grin]). The next thing I did, which I started on thursday was to make a 2D sidescroller....

Yeah, it failed, but I accomplished things I've never accomplished before. Things like textureswaps, moving bullets, gamestates etc. But therein lies the problem. I have never done such a thing before so I kinda suck at designing it(yes, I have started to write down my thoughts now). So I froze it the day before yesterday.

What now?

Well, since I managed to do textureswaps, gamestates and (partly) bullets, I thought I'd do it the proper way(Meaning acctualy deleting my allocated memory [grin]). So yesterday I started out with an ambitious idea to write my own allocation functions. It crashed... But today is a fresh day, and I would like some help on how to do things. So here's some questions:

How do you delete/store your resources?
Do you store them in one big std::vector or do you store them in separate ones?
Do you keep rendervectors?
I mean, f.ex in the menu state do you make a std::vector and in the gamestate do you make another one?
Do you even use std::vectors?
I read HopeDaggers journal and he said he used std::lists, I don't have any experience with std::lists.

Do you make a STATE class or do you just use a global string called gState?

How do you generate your textures(OpenGL)?
I managed to do this, but I'm not sure it's the best way. Right now when I create an object I push_back it to a static std::vector called Renderer::textures and store the position, then I call a method in Renderer which is called GenerateTextures which traverse through the Renderer::textures and calls glGenerateTextures(1, Renderer::textures). finnaly I retrieve my GLuint from the Renderer::textures list and load in images using SDL.

Thanks for any input!
0 likes 4 comments

Comments

ApochPiQ
Usually, I'll set up a system that allocates objects, gives them a unique ID number, and then holds them in a std::map. You can get the original object (or, better, a reference to it) quite easily, and the ID insulates you from the risks of having a lot of pointers floating around, while still being lightweight and nice and abstract.
August 15, 2006 06:02 AM
Samsonite
Thank you, now one last question:

If I have a std::vector or map that stores pointers(CObject* f.ex), will I delete the object if I do:


delete(CMemoryManager::AllocVec[i]);


Thanks for answering my question, I'll go look up on std::map now.
August 15, 2006 06:07 AM
Samsonite
Nobody?
August 16, 2006 09:23 AM
Programmer16
I'm pretty sure that'll work.

Also, for iterated-deletion, use something like this:

for(std::vector<TYPE>::iterator ListItor = Vector.begin(); ListItor != Vector.end(); ++ListItor)
{
    TYPE* pValue = (*ListItor);
    delete pValue;
}



I'm not sure if it's required, but I always get errors when trying to call delete (*ListItor).

Anyway, std::map FTW!
August 16, 2006 10:00 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Goodbye, Gamedev!

1239 views

Untitled

1109 views

Merry Christmas!

1140 views

Untitled

1094 views

Scrolling Demo

1031 views

New PC

911 views

Untitled

853 views

Untitled

887 views

Progress.

915 views
Advertisement