SRL Archive - Other Scripts

Gravity


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.

Pwnd

2006-04-21 20:15:01

Hah, that's neat :D

The Prince of Randomness?

2006-04-21 21:35:23

Funny :D lol bouncy

ReFLeX

2006-04-21 23:25:04

wow this has got to be one of the coolest scripts ive seen

The Un-Named

2006-04-22 06:43:20

Set bounce on 2 and hold up the runtime error shield! :D

Sjoe

2006-04-22 07:05:20

Haha, pretty funny :p

Sdcit

2006-04-22 11:30:30

Ah it has returned

Try setting it to -1

Jagex_Fagex

2006-04-22 19:48:18

i seem to remeber this on kaitnieks, was it on there??wel done!

XxKanexX

2006-04-22 21:35:46

I remember when you released this (Or something like this) at Kait.. Excellent ;p Keeps me occupied.

Zup

2006-04-23 15:06:51

Yea it's a script I found sitting on my harddrive that I wrote when I was in Florida.

newguy45

2006-06-15 04:59:05

Ah shit! i droped im pincle….lol