Skip to content

Instantly share code, notes, and snippets.

@ydnax
Created February 7, 2012 11:29
Show Gist options
  • Save ydnax/1759236 to your computer and use it in GitHub Desktop.
Save ydnax/1759236 to your computer and use it in GitHub Desktop.
void energy::update(ticks time){
const float angle=getAngle(start, target);
float fx, fy, tx, ty;
fx=start.x;
fy=-1*start.y;
tx=target.x;
ty=-1*target.y;
float dx,dy;
const float vert=getPointDistance(start, target);
const float addl=pxps*(time/1000);
thedistance+=addl;
//const float diff=vert-thedistance;
if(thedistance>vert){
delete this;
return;
}
dx=sin((angle/180)*M_PI)*thedistance;
dy=sqrt(pow(thedistance,2)-pow(dx,2));
xx+=dx;
xy+=dy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment