Files

35 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# impact_morph_block.js — spinFrame() (satır 68)
[← impact_morph_block.js](index.md) · [← Master](../../wiki.md)
```javascript
function spinFrame(c, x, y, z, tick)
{
if (tick >= DURATION) return;
var world = c.getWorld();
var spin = ((tick / FRAME_TICKS) * SPIN_PER_FRAME) % 360;
// player'a bakma yaw'ı
var faceYaw = YAW_FIX;
if (FACE_PLAYER) {
var p = nearestPlayer(world, x, y, z);
if (p !== null) {
var pp = p.getPosition();
faceYaw = Math.atan2(-(pp.x - x), (pp.z - z)) * 180 / Math.PI + YAW_FIX;
}
}
var yaw = faceYaw, pitch = PITCH_FIX, roll = 0;
if (SPIN_AXIS === "roll") roll = spin; // dik durur, kendi düzleminde döner
else if (SPIN_AXIS === "pitch") pitch = spin + PITCH_FIX;
else yaw = spin + YAW_FIX; // yatay eksende döner
world.displayMorph(buildMorph(roll), FRAME_TICKS + 2, x, y, z, yaw, pitch, RANGE, null);
c.scheduleScript(FRAME_TICKS, function (ctx) {
spinFrame(ctx, x, y, z, tick + FRAME_TICKS);
});
}
```