Zup
2006-04-21 19:37:02
Open up paint, drag the canvas out to 750x500 px. Set focus on paint and run. Drag and let go to "throw" the mouse. Kind of buggy but I don't want to fix it.
program MouseGravity; //by Zup
const
bounce = 0.9; //Energy lost when cursor hits wall (1 = no loss, > 1 = gain in energy)
drag = 0.8; //Overall drag on the cursor
g = 1; //Mouse gravity
xvStart = 15; //Initial x-velocity
throwSensitivity = 20; //Higher will move cursor with slower mouse movements
waitTime = 10; //Do not change unless your computer is slow (then make lower)
function p(num: Extended): Extended;
begin
if(num < 0)then
result:= num * -1;
end;
function n(num: Extended): Extended;
begin
if(num > 0)then
result:= num * -1;
end;
procedure Gravity;
var
x, y, oldx, oldy, newx, newy: Integer;
xe, ye, xv, yv: Extended;
begin
xv:= xvStart;
yv:= 0;
repeat
GetMousePos(x, y);
xe:= x;
ye:= y;
if(not(IsMouseButtonDown(true)))then
begin
if(x < 0)then
begin
MoveMouse(0, y);
xv:= p(xv);
xv:= xv * bounce;
end;
if(x > 750)then
begin
MoveMouse(750, y);
xv:= n(xv);
xv:= xv * bounce;
xv:= xv * drag;
end;
if(y < 0)then
begin
MoveMouse(x, 0);
yv:= p(yv);
yv:= yv * bounce;
end;
if(y > 500)then
begin
MoveMouse(x, 500);
yv:= n(yv);
yv:= yv * bounce;
end;
yv:= yv + g;
xe:= xe + xv;
ye:= ye + yv;
x:= Round(xe);
y:= Round(ye);
MoveMouse(x, y);
wait(waitTime);
end else
begin
GetMousePos(oldx, oldy);
wait(throwSensitivity);
GetMousePos(newx, newy);
xv:= newx - oldx;
yv:= newy - oldy;
end;
until(false);
end;
begin
Gravity;
end.