View Single Post
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,991

Violet CLM has disabled reputation

Oct 31, 2013, 08:55 AM
Violet CLM is offline
Reply With Quote
Quote:
Originally Posted by minmay View Post
I want to make a TNT-like explosion with a custom radius. So basically I want to recreate what appears to be a part of BEHAVIOR::TNT, but I have no way to see inside that behavior, and mine needs to as close as possible. Any help? I have no idea what the shape should be, how the force parameter passed to onObjectHit should be calculated, etc.
Umm... good luck. There's a lot of code required for doing this right that just isn't publicly exposed in the API yet. Calling onObjectHit is okay, but without more direct access to the underlying collision code, I'd honestly be tempted to spawn a bunch of invisible PLAYERBULLET objects in a circle around the explosion and give them .animSpeed values based on their distance from the center. For extra credit, you could also search through the object list, decide which ones are near enough, and if they have .isBlastable set to true, change their .xSpeed and .ySpeed values.
Quote:
But I want a pickup with its own sprite
For most cases, just calling determineCurAnim should be fine?
Quote:
Originally Posted by cooba View Post
Code:
int frame = obj.objectID * 8 + jjGameTicks;

if (obj.yPos > jjWaterLevel) frame = frame*2 + (int(obj.xPos) + int(obj.yPos) * 256)*16;
else frame = (frame + int(obj.xPos) + int(obj.yPos) * 256)*16;

if (obj.ySpeed == 0) jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos + jjSin(frame)*4, obj.curFrame, obj.direction);
else jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction);
urge to simplify rising
Code:
if (obj.ySpeed == 0) {

  int frame = obj.objectID * 8 + jjGameTicks;

  if (obj.yPos > jjWaterLevel) frame = frame*2 + (int(obj.xPos) + int(obj.yPos) * 256)*16;
  else frame = (frame + int(obj.xPos) + int(obj.yPos) * 256)*16;

  jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos + jjSin(frame)*4, obj.curFrame, obj.direction);
}
else obj.draw();
__________________