Is movement on the moon at a rate
of 1/6th or 1/2 of Earth?

(vb source code for gravity on the moon)
form moon

Private Sub cDrop_Click()
LabelMax.Caption = 0
ScaleRat = 0.6667 'arbitrary scale can ignore (turns twips (1/15th of a pixel) into mm)
Command9.Visible = True 'make pause button visible
Grav = Val(TextGee.Text) 'gravity
BallVel = 0
Chronos = HScroll1.Value
Timer3.Interval = Chronos 'set frame rate interval
ElapseT = 0
Hippos = 0
Msurface = LabelSurface.Top - CricketBall.Height 'set surface of planet/moon
AstroPosition = 1800
Timer3.Enabled = True 'start frames
Timer2.Enabled = True 'record duration of jump

End Sub

Private Sub Command1_Click()
End
End Sub

Private Sub Command10_Click()
HScroll1.Value = 120 'set timer for frame rate
End Sub

Private Sub Command3_Click()
TextGee.Text = 9.8 'earths gravity
TextGee.BackColor = Command3.BackColor
LabelSurface.BackColor = Command3.BackColor
End Sub

Private Sub Command4_Click()
TextGee.Text = 1.63 'moons gravity
TextGee.BackColor = Command4.BackColor
LabelSurface.BackColor = Command4.BackColor
End Sub

Private Sub Command6_Click()
HScroll1.Value = 20 'set timer for frame rate
End Sub

Private Sub Command7_Click()
HScroll1.Value = 40 'set timer for frame rate
End Sub

Private Sub Command9_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
Timer2.Enabled = True
Else
Timer1.Enabled = False
Timer2.Enabled = False
End If
End Sub

Private Sub CommandReset_Click()
Timer1.Enabled = False
Timer2.Enabled = False

Command3.Value = True
HScroll1.Value = 100
Buzz.Top = Msurface
End Sub

Private Sub HScroll1_Change() 'set timer rate from scrollbar
Chronos = HScroll1.Value
Timer1.Interval = Chronos
LabelThousandths.Caption = Chronos
End Sub

Private Sub Text1_LostFocus()
Grav = Val(TextGee.Text)
End Sub

Private Sub Text2_LostFocus()
Jumpup = Val(TextJump.Text) 'force of jump
End Sub

Private Sub Timer1_Timer() 'for astronaut
'(buzz is a picturebox with a graphic in it.)

AstroPosition = AstroPosition - Jumpup
'jumpup is the velocity that buzz is moving
'(subtract his velocity from his posiition to move up or down)

Buzz.Top = AstroPosition
'astroposition is the position of the astronaut on the vertical axis

Jumpup = Jumpup - Grav
' velocity is altered by the force of gravity (grav))
LabelVelocity.Caption = Int(Jumpup * ScaleRat)

'get max height of astronaut
LabelHeight.Caption = Int(Msurface - Buzz.Top)
If Int(Msurface - Buzz.Top) > Hippos Then Hippos = Int(Msurface - Buzz.Top)
LabelMax.Caption = Int(Hippos * ScaleRat)

If Buzz.Top > Msurface Then 'land on surface (end jump)
Timer1.Enabled = False
Timer2.Enabled = False
Buzz.Top = Msurface
End If
End Sub

Private Sub Timer3_Timer() 'for ball
'(cricketball is a picturebox with a graphic in it.)

AstroPosition = AstroPosition - BallVel
'jumpup is the velocity that buzz is moving
'(subtract velocity from position to move down only)

CricketBall.Top = AstroPosition
'astroposition is the position of the astronaut on the vertical axis

BallVel = BallVel - Grav
' velocity is altered by the force of gravity (grav))
LabelVelocity.Caption = Int(BallVel * ScaleRat)

'get max height of astronaut
LabelHeight.Caption = Int(Msurface - CricketBall.Top)

If CricketBall.Top > Msurface - CricketBall.Height Then 'land on surface (end jump)
Timer3.Enabled = False
Timer2.Enabled = False
CricketBall.Top = Msurface
End If
End Sub

Private Sub Cjump_Click() 'begin jump
ScaleRat = 0.6667 'arbitrary scale can ignore (turns twips (1/15th of a pixel) into mm)
Command9.Visible = True 'make pause button visible
Grav = Val(TextGee.Text) 'gravity
Jumpup = Val(TextJump.Text) 'starting velocity of astronaut. VERY IMPORTANT
Chronos = HScroll1.Value
Timer1.Interval = Chronos 'set frame rate interval
ElapseT = 0
Hippos = 0
Msurface = LabelSurface.Top - Buzz.Height 'set surface of planet/moon
AstroPosition = Msurface 'line buzz with surface of planet/moon
Timer1.Enabled = True 'start frames
Timer2.Enabled = True 'record duration of jump

End Sub

Private Sub Timer2_Timer()
'MsgBox ">"
ElapseT = ElapseT + 0.01 'add 1/100th of a second to elapsed time
'set timer2.interval = 10
'leave all timers default to enbaled=false
LabelETime.Caption = ElapseT

End Sub


module for global variables
Global Grav As Double 'gravity
Global Chronos As Integer 'timer speed
Global Jumpup As Double 'velocity of astronaut
Global Msurface As Integer ' surface position of planet/moon
Global ElapseT As Currency ' elapsed time
'(currency is more accuarate for avoiding rounding errors when in 10ths or 100ths of a second)
Global AstroPosition As Double 'position of astronaut on Y-axis
Global Hippos As Double 'highest position of astronaut
Global ScaleRat As Double
Global BallVel As Double
'credits (2008)
'www.poseidons.net
'youtube
'rollitup.org

 

poseidons net