#include <acknex.h>
#include <default.c>
void stretch_sprite(ENTITY* sprite,VECTOR* vec1,VECTOR* vec2){
VECTOR temp;
//calculating the scale factor, its distance_between_vectors/sprite_length;
//f.e. if sprite is 10 quants and the distance is 100 quants scale factor is 10, so when i scale sprite 10 times i get the desired length
var scale_factor = vec_dist(vec1,vec2)/sprite.skill1;
sprite.scale_x = scale_factor;
//finding the angles between vectors
vec_set(temp,vec1);
vec_sub(temp,vec2);
vec_to_angle(sprite.pan,temp);
//apperantly, sprites stand prep. to x so add 90 to pan.
//do not directly add 90 to pan or you'll screw up the other amgles
ang_rotate(sprite.pan,vector(90,0,0));
//center of the sprite is on the middle, so ew have to move our new long sprite to middle of the vectors
vec_lerp(temp,vec1,vec2,0.5);//temp now stores the middle of the vectors
vec_set(sprite.x,temp);
}
void sprite_act(){
//i only need to calculate these once, so insted of doing it in stretch_sprite function i do it here
my.skill1 = my.max_x-my.min_x;//this stores the sprites original length
}
void sphere_act(){
ENTITY* ent_sprite = ent_create("sprite.tga",nullvector,sprite_act);
while(!ent_sprite) wait(1);
my.skill1 = 0;
my.skill2 = 1;
while(1){
//sphere movement
my.pan += 10*time_step;
my.skill1 += my.skill2*time_step;
my.x -= my.skill1*cos(my.pan)*time_step;
my.y += my.skill1*sin(my.pan)*time_step;
my.z = 100*sin(my.pan);
if(my.skill1>=10) my.skill2 = -1;
else if(my.skill1<=-10) my.skill2 = 1;
stretch_sprite(ent_sprite,my.x,nullvector);
wait(1);
}
}
void main(){
wait(1);
level_load("");
ent_create("sphere.mdl",nullvector,sphere_act);
}