Answer the question
In order to leave comments, you need to log in
How to add images/objects without inflating the class code?
I studied on the examples of the old graphic library, by the way, the first program was created by me in 2012, but there is not a single release, all because it is difficult to navigate in a program in which a class starts to take 1000+ lines of code, I will explain here there is a method for example loadimage ():
LoadImages()
{
...
loadfile("1.png");
loadfile("2.png);
...
loadfile("100500.png");
...
}
setverteces()
{
...
object1.x=0.1;
object1.y=0.2;
object2.x=0.1;
object2.y=0.3;
...
object100500.x=0.4;
object100500.y=-0.8;
...
}
, Answer the question
In order to leave comments, you need to log in
It can be turned..
object1.x=0.1;
object1.y=0.2;
object2.x=0.1;
object2.y=0.3;
object1.SetCoord(0.1, 0.2);
object2.SetCoord(0.1, 0.2);
object1 = new object(0.1, 0.2, "100500.png");
{
"x": 0.2,
"y": 0.1,
"texture": "car.png"
}
object = new Object("/object1.json");
You need to transfer the list of images to a text file and load them in a loop - the class code will not be inflated. Load object coordinates from a file and process in a loop - the class code will not be inflated.
xml, json, just in its text format - it doesn't matter. It is more convenient to load data from a file, then you can modify it simply by changing text files, without recompilation. Maybe even without restarting the game.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question