Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Goal: Spawn a sinuate laser from the boss's location moving
- //at constant angular velocity through a circle with increasing
- //radius.
- //Just setup for the laser
- let obj=Obj_Create(OBJ_SINUATE_LASER);
- ObjShot_SetGraphic(obj,7);
- Obj_SetPosition(obj,GetX,GetY);
- ObjSinuateLaser_SetLength(obj,40);
- ObjSinuateLaser_SetWidth(obj,10);
- ascent(t in 0..T){
- //Ok, now for the motion. Pretty easy when expressed in terms of
- //position relative to time:
- //x_pos=GetX+R*t/T*cos(W*t);
- //y_pos=GetY+R*t/T*sin(W*t);
- //where R is the maxiumum radius, T is the time for the circle
- //to expand to it, and W is an arbitrary angular velocity
- //As sinuate lasers must be controlled with speed & angle, this
- //isn't enough. The strategy is to convert the position functions
- //into velocity functions and generate an angle and velocity from
- //these.
- //Differentiating the above equations with respect to t.
- x_vel=R/T*cos(W*t)-W*R*t/T*sin(W*t);
- y_vel=R/T*sin(W*t)+W*R*t/T*cos(W*t);
- //From here it's just converting the two velocities into a speed
- //and angle.
- Obj_SetSpeed(obj,(x_vel^2+y_vel^2)^0.5);
- Obj_SetAngle(obj,atan2(y_vel,x_vel));
- yield;
- }
Advertisement
Add Comment
Please, Sign In to add comment