You are not logged in.
Pages: 1
So I'm doing and old school vector/line looking tank game. Everyting looks like it's line draw. It's prety cool.
For the tank explosion, I'm drawing the tank to a surface, centered on it, then I fragment the surface into bit using draw surface part. say 16 parts so the tank looks like it broke apart.
I have a problem and if memory serves I thing xot had a similar problem a while ago. The thing is, the resulting explosion seems to happen a few pixels ahead of the actual tank position. I looked and looked and can't seem to find exactly where the problem is... Is it the calculation to draw the tank on the surface? is it the draw part that is off by a few picels? I dont know. it seem to draw ahead, in the direction the tank is driving.
So here. I onlyt do thins is an act of dispear, Like you know me. I tend to fix my own problems but I need a fresh brain.
The GMK
explodetank script and explodeTankObj
Last edited by icuurd12b42 (2010-08-01 00:04:22)
Offline
Hmmmm. Host-A seems to be having database problems.
This probably isn't the answer you are looking for, but for lack of anything else to post, here is how I handled this sort of effect. This is sprite based but it should be readily adaptable to surfaces.
instance_explode() (mirror if above does not work)
EDIT
OK, Host-A is working again. I've downloaded it, but I won't be able to look into it for a few hours.
Last edited by xot (2010-08-03 13:14:07)
Abusing forum power since 1986.
Offline
Fix appears simple.
In ExplodeTankObj
replace:
xx[ct] = midx-size/2 + xat * bitsize;
yy[ct] = midy-size/2 + yat * bitsize;
... with:
xx[ct] = tank.x - size/2 + xat * bitsize;
yy[ct] = tank.y - size/2 + yat * bitsize;
The center of the bounding box is not necessarily the position of the object. You need to draw the pieces relative to the object, not the bounding box.
Q: Is there a reason you are creating a surface that has twice the necessary width and height? Seems extremely wasteful to draw all those pieces when ~75% of them have nothing drawn on them.
Abusing forum power since 1986.
Offline
Thanks man. Works like charm!!
Q: Is there a reason you are creating a surface that has twice the necessary width and height? Seems extremely wasteful to draw all those pieces when ~75% of them have nothing drawn on them.
Yeah, good catch. I was using sprite_width originaly, before i segragated the code from conceptual test to generic method. There I was using sprite_width instead of bounding box. I forget to remove that *2; originaly used to cheaply account for the rotation, a hack that I forgot to ajust in the final code.
A million thanks!
So, how do you like the feel of it?
[edit]
OK, over here, I lose the front edge of the tank. weird.
size = max(right-left,bottom-top);
size = max(right-left,bottom-top)+2; //still
size = max(right-left,bottom-top)+8; //fine
Last edited by icuurd12b42 (2010-08-02 02:54:05)
Offline
Seems like a good system, it's pretty similar to mine. Surfaces are nice for supporting image_angle. I might extend mine with surfaces to support that. When I wrote it, I didn't think I'd be using image_angle, but I might.
Regarding the edge of the tank getting cut off, and I'm just guessing here, but maybe you should determine the dimensions of the surface with:
size = 2 * max( tank.x-left, right-tank.x, tank.y-top, bottom-tank.y );
Abusing forum power since 1986.
Offline
Thanks, it's perfect now.
Offline
Cool, glad it's working.
Abusing forum power since 1986.
Offline
Pages: 1