Esenthel, I need your help :(
What has to be done with custom particles when they died? I mean, every frame I'm changing the position of each particle and when their life time is out I get "0xC0000005: Access violation writing location 0x0000000c" on *position = Rnd(Ball(6.0)); Do I have to manually reborn them or something?
Sorry, there is no tutorial for custom particles and I don't have a clue on how to work with them. The position changing did work with normal particles.
Here is my code:
Code:
Gfx *gfx = Gfxs("../data/gfx/particle/star.gfx");
UInt col = ARGB(100, 40, 40, 40);
Int num = 2000;
Flt r = 0.05,
life = 7.0,
vel = 0;
Vec accel = 0;
Shape shape = Box(12, 12, 12);
part[0].createCustom(*gfx, col, num, r, life, accel, Rnd(Shape(shape)));
part[0].reset();
part[0].func = PARTICLE_FULL;
And in UpdateGame:
Code:
for(UInt n=0;n<2000;n++) {
Particle *particle = &part[0].p(n);
Vec *position = &particle->pos;
*position = Rnd(Ball(6.0));
while(position->length() < 10.1 || position->length() > 10.3)
position->setLength(10.2);
}
And Render:
Code:
case RM_PRT_PAL:
part[0].draw();
break;
The Rnd(Shape(shape)) in createCustom(...) does nothing, so I do *position = Rnd(Ball(6.0)); for each particle in UpdateGame.
The particles live 7 sec till I get "Access violation" and even in these 7 sec I can't see my particles, so I assume I do something wrong in particle creation.