47 lines
1.2 KiB
Text
47 lines
1.2 KiB
Text
Module Pendulum {
|
|
back()
|
|
degree=180/pi
|
|
THETA=Pi/2
|
|
SPEED=0
|
|
G=9.81
|
|
L=0.5
|
|
Profiler
|
|
lasttimecount=0
|
|
cc=40 ' 40 ms every draw
|
|
accold=0
|
|
Every cc {
|
|
ACCEL=G*SIN(THETA*degree)/L/50
|
|
SPEED+=ACCEL/cc
|
|
THETA+=SPEED
|
|
Pendulum(THETA)
|
|
if KeyPress(32) Then Exit
|
|
}
|
|
|
|
Sub back()
|
|
If not IsWine then Smooth On
|
|
Cls 7,0
|
|
Pen 0
|
|
Move 0, scale.y/4
|
|
Draw scale.x,0
|
|
Step -scale.x/2
|
|
circle fill #AAAAAA, scale.x/50
|
|
Hold ' hold this as background
|
|
End Sub
|
|
|
|
Sub Pendulum(x)
|
|
x+=pi/2
|
|
Release ' place stored background to screen
|
|
Width scale.x/2000 {
|
|
Draw Angle x, scale.y/1.5 ' 1.5 for 16:9 screen
|
|
Width 1 {
|
|
Circle Fill 14, scale.x/25
|
|
}
|
|
Step Angle x, -scale.y/1.5
|
|
}
|
|
Print @(1,1), lasttimecount
|
|
if sgn(accold)<>sgn(ACCEL) then lasttimecount=timecount: Profiler
|
|
accold=ACCEL
|
|
Refresh 1000
|
|
End Sub
|
|
}
|
|
Pendulum
|