Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the ambiera forums
I have been working on my gameengine for ages now and it is preatty useable already and i made some games with it.(i guess all of them arepostet on this forum) anyway. One thing i came across while programming the games is the communication of entities and exchange of variables. I did this with passing void* pointers in clback functions and implementing a simple get/setVarINT/FLOAT and so on. ok this was pretty tidious work and i doesn't always work when i have for example a class that needs to be passed and a callback would be overkill there. So i came up with a system used in most scripting languages. I didn't integrate it yet bc its not quite done. But the fundamentals are already layed out.
int main()
{
localVar A;
localVar B;
A = 5;
B = 1;
A = A + 1;
B = B - 6;
printf("A = %i and B = %i\n", (int)A, (int)B);
localVar C = AppFrame::string("Hello");
C = C + AppFrame::string(" whats up");
printf("Text is: %s\n", C.c_str());
int First = 0;
AppFrame::string second = "Test";
AppFrame::SAttributeContainer Container;
Container.Bind("Health", &First);
Container.Bind("Name", &second);
printf("Health: %i, Name: %s\n", (int)Container.getAttribute("Health"), Container.getAttribute("Name").c_str());
Container.setValue("Health", 132);
Container.setValue("Name", "Sudi");
printf("Health: %i, Name: %s\n", (int)Container.getAttribute("Health"), Container.getAttribute("Name").c_str());
Container.setValue("Health", "100");
printf("Health: %i, Name: %s\n", (int)Container.getAttribute("Health"), Container.getAttribute("Name").c_str());
}
What do u think about that system? any good?
PS: this is no dreaming this actually already works^^
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
I believe strong type are actually an advantage, not a weakness. If something is an int for example, it says that it is only supposed to contain a number, that that number must be an integer. Those information are as relevant as the value stored within the variable. Removing them or making them changeable can break the code in whole new ways. They are plenty of way to convert types to other when the need arise, some even dangerous in their uses. In short, generic types are good, but only for prototyping and should be avoided when you want to convey information about a type.
so, enough rambling..... a simple question for you now. Have you considered binding not the variable, but a function to the 'Health" attribute so that you can validate and or react to the variable setting?
Nice idea...i did it by adding a callback function that is called when ever the attribute is changed.
localVar a;
a = 5;
a = irr::core::stringc("Hallo"); //The var will not be changed here bc irr::core::string is not of type int
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
that would work with my method and is intended to be used with the conatiner as u see in my first post last command
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
ok i guess u got it all wrong.
i was taking about comunication between entities or the map editor. there u normaly don't need any virtual functions or anything. because the other class doesn't know at all how the other class looks like. Same with the map editor. the editor doesn't know how the class looks like. of course i can implement some simple types like int,float,string,vector,color but over all that is not what i want. i want it to be really independant of any class and rules. so i guess we are talking two different ways.
and btw. my just invented implemantation looks a little bit better than yours
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
don't get me wrong but i think we both tried to accomplish different things in the first place.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.