I thought I could make my animation run faster by having drawing operations done in one objects and to eliminate get and set methods with using pointers. So I had:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
float x, y, buf //buf is there so the size of both structs is the same
float x, y, seq
struct pellet p;
struct explosion e;
fireworks.cpp: Yea I have problems being consistent with names. whatever
1 2 3 4 5 6 7 8 9 10
struct pellet *a = (struct pellet*) malloc(sizeof(struct pellet));
/* set pellet a data */
I rewrote it with a vector and only one object class and it works fine now. Thanks.
Would using an base abstract class help if you are dealing with different but similar classes? I made a game that had basically a bunch of bad guys with a bunch of weapons and the game was unstable. I used vectors. Sometimes it would work fine other times it would crash. The biggest problem I think was the collision detection class I wrote for it which made its own datatype and stored essential info on every on-screen object. I had to be careful how often I fired the shotgun weapon lest I crash the program.
I wouldn't bother running it on my old macbook with only 2Gs of RAM D:
I'm always on the look out for ways to conserve RAM. I personally think its always better to conserve memory even at the expense of processor usage (although the 2 aren't mutually exclusive)