Sphere formation & its rotation problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Sphere formation & its rotation problem

Hello. I'm Doom game mapper and scripter. I create complex scripts to do sophisticated actions. And it's pure C-like programming or ACS scripts which are native to that.

I'm forming a sphere of elements and everything is fine. But I face problems when trying to make it to turn around like a planet. Points istelf can do a smooth 1 circle turn.

But when I try to make them move they [b]jump[/b] to start point and start to move along whole circle arc.

I want so they all would turn from their own positions [u]without a jump[/u].

Here is the code:
[code]
#include "zcommon.acs"
//====================================

#define FRACBITS 16
#define MAXRADIUS 320.0

str projectiles[6] = {"DoomImpBall", "CacodemonBall", "ArachnotronPlasma", "PlasmaBall", "BaronBall", "Rocket"};

//---------------
int ar_r[1300];
int ar_x[1300];
int ar_y[1300];
//---------------

script 5 (int tid, int type, int quantity)
{
quantity = random(8, 30);
type = random(1,6);
tid=1;
int steps, i, x, y, dx, dy;
steps = 40;
int index_r, index_x, index_y;
index_r=0; index_x=0; index_y=0;
int circle_radius = random(94.0, MAXRADIUS);
int radius;
int basex = GetActorX(tid);
int basey = GetActorY(tid);
int basez = GetActorZ(tid);
int spawnX, SpawnY;
int angle;
int zAngle;
//int x_angle=0;
int r_tag = 699;

Switch(1)
{
case 1: // SPHERE http://pastebin.com/L6FdWkV3
for (int z1 = 0; z1 < quantity; ++z1)
{
zAngle = FixedDiv(z1 << FRACBITS, ((quantity-1)*2) << FRACBITS);
for (int n1 = 0; n1 < quantity; ++n1)
{
//------------------------------------------------------
angle = FixedDiv(n1 << FRACBITS, quantity << FRACBITS);
radius = FixedMul(circle_radius, sin(zAngle));
spawnX = FixedMul(radius,cos(angle));
spawnY = FixedMul(radius,sin(angle));
//------------------------------------------------------
ar_r[index_r] = radius;
ar_x[index_x] = spawnX;
ar_y[index_y] = spawnY;
//------------------------------------------------------
++r_tag; ++index_r; ++index_x; ++index_y;
//------------------------------------------------------
Spawn(projectiles[type-1], basex + spawnX - 1000.0,
basey + spawnY,
basez + circle_radius + FixedMul(FixedMul(circle_radius, 0.82), cos(zAngle)),
r_tag, (angle + 1.0)>>8);
//------------------------------------------------------------------------------------------
print(s:"projectile: ", d:r_tag, s:" radius: ", f:ar_r[index_r-1], s:" index: ", d:index_r);
//------------------------------------------------------------------------------------------
delay(2);
}
}
break;
}
//---------------------------------------------------------------------------------------------------
for(int k = 700; k <= r_tag; ++k)
{
radius = ar_r[k-700];
for (i=0; i<steps; i++)
{
angle = FixedDiv(i << FRACBITS, steps << FRACBITS);
x = FixedMul(radius,cos(angle));
y = FixedMul(radius,sin(angle));
dx = x - ar_x[k-700];
dy = y - ar_y[k-700];
ar_x[k-700] = x;
ar_y[k-700] = y;
SetActorVelocity(k, dx, dy, 0, FALSE, TRUE);
delay(1);
}
//delay(1);
}
}[/code]
Additional commands: [link=http://zdoom.org/wiki/Spawn]Spawn[/link], [link=http://zdoom.org/wiki/FixedDiv]FixedDiv[/link], [link=http://zdoom.org/wiki/FixedMul]FixedMul[/link], [link=http://zdoom.org/wiki/SetActorVelocity]SetActorVelocity[/link]

I think they jump to starting point because for every point angle is counted from 0. IMHO, as there are steps/quntity steps in each part, it should be added to angle count. I don't know how and I don't know if am I right. I need your help to investigate the problem and find a solution.

1. To see what is really happening you need a game WAD: [link=http://www.mediafire.com/?61ll4oasdbwlqn8]For worst[/link]
The file is attached here too.

2. To play that wad you need the game istelf: [link=http://zdoom.org/files/zdoom/2.5/zdoom-2.5.0.zip]ZDOOM[/link]

3. To edit game map space or ACS script you need: [link=http://www.doombuilder.com/files/builder168_setup.exe]Doom builder[/link]

4. Here is a picture to better understand the view and maybe to see what's wrong. It's a view from top to bottom: [img=http://img864.imageshack.us/img864/9449/sphererotatioprob.png]

I look forward to hearing from you.
Sign In or Register to comment.