I'm programming a game now. I designed a small engine to make the programming of the game some faster.
I make a class, if I want to render a bird, I place the mesh into the object of that class. That object goes into a collection.
Another function renders the collections. But not all the objects have to be rendered all the time, because they are out the sight for example.
What is faster?
1. Placing all the objects that have to be rendered in another collection so the renderfunction renders the whole collection. I have to transfer objects from one collection to another often then.
calculatevisible calculates that the object is in sight or not.Code:Sub transfer() for i = 1 to collection1.count if calculatevisible(collection1.item(i)) then collection2.add collection1.item(i) next i End sub Sub Render() for j = 1 to collection2.count collection2.item(j).render next j End sub
2. Or just adding a parameter to the objects so the renderer can see when it has to be rendered:
Code:for i = 1 to collection.count If collection.item(i).visible then collection.item(i).render Next i




Reply With Quote