⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 这个是用Visual Basic写的一个机器人程序
💻 FRM
📖 第 1 页 / 共 5 页
字号:
Private Sub btnResetLinks_Click()


ModeIND = " Links Reset."

'should be used in construction mode.
'this will reset the length of all links without having to destroy
'and re-create the link

'I realize that the usefullness of this function may not be clear
'at first.  If you make a link in construction mode, and then change
'the position of one of the vertices,  you'll find that when you
'click simulate, the link will pop back out to its original size.
'This will reset that size so it doesn't do that.
'I put this here because it was driving me completely insane.

'Try to make sure your construct is at rest (make gravity=0 and pause
'the muscle cycle) or else bad things may happen such as your links
'may suddenly 'slouch'.
focusdummy.SetFocus

For i = 1 To MaxLinks
   With Link(i)
     T1 = .target1_id
     T2 = .target2_id
     xer = (vertex(T2).X) - (vertex(T1).X)
     yer = (vertex(T2).y) - (vertex(T1).y)
     Leng = Sqr(Abs(xer ^ 2 + yer ^ 2))
     .linklength = Leng
   End With
Next i

End Sub

Private Sub btnRevers_Click()

'reverse the clock, if you make a robot that walks,
'this may make it walk backwards

ClockSpeed = ClockSpeed * -1
INDspd = "Spd: " & ClockSpeed

End Sub

Private Sub btnSave_Click()

Call mnuSaveAs_Click
focusdummy.SetFocus

End Sub

Private Sub Combo1_Click()

If Combo1.Text = "Presets..." Or Combo1.Text = "" Then Exit Sub


    CycleTime = 0
    focusdummy.SetFocus
    Call BTNpicCon_Click
    DoEvents
    For i = 1 To MaxVertices
      vertex(i).used = False
    Next i
    For i = 1 To MaxLinks
      Link(i).used = False
    Next i
    VertexCount = 0
    LinkCount = 0
    mode = 0
    SubMode = 0
    
    
Call File_Read(App.Path & "\presets\" & Combo1.Text)

End Sub



Private Sub cycleview_MouseDown(Button As Integer, Shift As Integer, X As Single, y As Single)


'this may be hard to understand but I'm not going to explain it
'in length because I doubt anyone will want to tinker with it.

'Basically when a link is selected, you can click on the cycle box
'with the left button to make a dot appear.  The higher above the
'line the dot, the farther the link will push when the cycle hits it.
'The lower the dot below the line, the more the link will contract.

'By right clicking or dragging to the side, you can alter how
'gradually the link will reach its fully enlarged (or contracted)
'state.

If SubMode = 4 Then
  With Link(SelLink)
If Button = 1 Then
   .pushtiming = X - 2
   Do While .pushtiming > CycleSize Or .pushtiming < 0
   If .pushtiming > CycleSize Then .pushtiming = .pushtiming - CycleSize
   If .pushtiming < 0 Then .pushtiming = .pushtiming + CycleSize
   Loop
   .pushstrength = (0 - y) + (CycleBuffer.ScaleHeight / 2)
   
End If

If Button = 2 Then
   .pushspan = Abs(.pushtiming - (X - 2))
   If .pushspan > (CycleSize / 2) Then .pushspan = (CycleSize / 2)
End If
End With


End If




End Sub


Private Sub cycleview_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)

'again, easy way to make dragging possible
Call cycleview_MouseDown(Button, Shift, X, y)


End Sub


Private Sub Form_Load()



FS_Mode = False

ModeIND = " Construct Mode    Click to create vertexes and links.  Click and drag to move vertexes.  Right click to cancel a link."
Combo1.AddItem ("MuscleDemo.botz")
Combo1.AddItem ("Walker.botz")
Combo1.AddItem ("AntiGrav.botz")
Combo1.AddItem ("Unicycle.botz")
Combo1.AddItem ("Dancer.botz")
Combo1.AddItem ("Spike-ball.botz")
Combo1.AddItem ("Jumper.botz")

'Set Variables------------------------------------------------------
DrawColor = RGB(0, 0, 0)
BGColor = RGB(255, 255, 255)
CurrentPhase = 1

Gravity = 0.4
WallBounce = 0.4
Atmosphere = 0.01
LeftWind = 0
Tension = 0.9
WallFriction = 0.7
ClockSpeed = 3

    'Calibrate the dimensions of the playing field
    'This way you can change the playing field just
    'by resizing Main.
    
BoardX = Main.Width
BoardY = Main.Height
RightWall = BoardX - 3   'these are adjusted to keep the vertices
Ceiling = BoardY - 6     'from seeming to sink under the floor
Buffer.Width = Main.Width
Buffer.Height = Main.Height
    'Everything is drawn on the buffer and then blitted to the main
    'picturebox.  That way theres no flicker because Main never has
    'to be cleared.  This idea is inspired by DirectX.
'-------------------------------------------------------------------




'Set up Visuals-----------------------------------------------------
Me.Show   'make sure the form is shown
DoEvents  'let windows do what it needs to
mode = 0  'the default mode is construction mode.

Buffer.BackColor = BGColor


'-------------------------------------------------------------------

File_Read (App.Path & "\resume.botz")
Slider1.Value = LeftWind
Slider1_Click
Slider2.Value = 100 * Atmosphere
Slider2_click
Slider3.Value = Gravity * 100
Slider3_Click


'Now that everthing is good and set up, we can begin the subroutine
'that governs the operation of the program.   The value in the
'brackets is the speed at which the program cycles. lower is faster.
'15 milleseconds is the fastest my computer can go, play with this
'value if you like


Cycle_Botz (25)

End Sub

Private Sub Form_Unload(Cancel As Integer)

File_Save (App.Path & "\resume.botz")
End

End Sub



Private Sub Frame_ControlPanel_Click()

End Sub

Private Sub fs_Click()
 If fs.Checked = False Then
    Me.WindowState = 2
    Main.Height = Form1.ScaleHeight
    ModeIND.Visible = False
    BoardX = Main.Width
    BoardY = Main.Height
    RightWall = BoardX - 3
    Ceiling = BoardY - 6
    Buffer.Width = Main.Width
    Buffer.Height = Main.Height
    fs.Checked = True
    CHKTop.Visible = False
    Me.BorderStyle = 0
    FS_Mode = True
    
    Frame_ControlPanel.Visible = False
Else
    FS_Mode = False
    Me.WindowState = 0
    Main.Height = 341
    ModeIND.Visible = True
    BoardX = Main.Width
    BoardY = Main.Height
    RightWall = BoardX - 3
    Ceiling = BoardY - 6
    Buffer.Width = Main.Width
    Buffer.Height = Main.Height
    fs.Checked = False
    CHKTop.Visible = True
    
    Frame_ControlPanel.Visible = True
End If
End Sub

Private Sub HScroll1_Change()

End Sub

Private Sub INDrad_Change()


'I don't think this needs explaining

If INDrad = "" Then Exit Sub
vertex(SelVertex).Radius = INDrad

End Sub

Private Sub Main_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyDelete Then Call btnDelete_Click

End Sub

Private Sub Main_MouseDown(Button As Integer, Shift As Integer, X As Single, y As Single)


Dim applies, applieslink, inty As Integer
xer = X
yer = Main.Height - y - 3
applies = 0


If Button = 2 Then
    If HowManySelected > 1 Then
      SubMode = 0
      ClearMultiSelect
      Exit Sub
    Else
      SubMode = 0
    End If
End If

If HoverVertex > 0 Then applies = HoverVertex
If HoverLink > 0 Then applieslink = HoverLink: applies = 0

i = applies
If mode = 1 And Button = 1 Then
    ClearMultiSelect
    SelVertex = i
    vertex(i).Selected = True
    SubModeData = i
    SubMode = 2
    DragDot = i
    SelLink = 0
End If


If mode = 0 Then
If Button = 1 And Shift <> 1 Then
  

  If SubMode = 1 Then
     If applies = 0 And applieslink = 0 Then
        ClearMultiSelect
        inty = AddVertex(xer, yer, 0, 0, 0, 0, CurrentPhase)
        vari = AddLink(inty, SubModeData)
         SubModeData = inty
        Exit Sub
     Else
        If applieslink = 0 Then
        inty = applies
        vari = AddLink(inty, SubModeData)
        SubModeData = inty
        SelVertex = applies
        vertex(applies).Selected = True
        Exit Sub
        End If
     End If
  End If
  
  If SubMode = 0 And applies = 0 And applieslink = 0 Then
     ClearMultiSelect
     inty = AddVertex(xer, yer, 0, 0, 0, 0, CurrentPhase)
     SubModeData = inty
     SubMode = 1
     Exit Sub
  End If
  
    If applies > 0 Then
        If vertex(applies).Selected = False Then
            ClearMultiSelect
            SelVertex = i
            vertex(i).Selected = True
            SubModeData = i
            SubMode = 2
            DragDot = i
            SelLink = 0
        Else
            SelVertex = i
            vertex(i).Selected = True
            SubModeData = i
            SubMode = 2
            DragDot = i
            SelLink = 0
        End If
    End If
End If


End If





i = applies
If Button = 1 And Shift = 1 And mode = 0 Then
   'multi select
   If applies > 0 Then
          ToggleSelction applies
   End If
   Exit Sub
Else
 If Button = 1 And mode = 0 Then
'if nothing else, then
    If applies > 0 Then
        SelVertex = i
        vertex(i).Selected = True
        SubModeData = i
        SubMode = 2
        DragDot = i
        SelLink = 0
    End If
    If applieslink > 0 Then
       SelLink = applieslink
       SubMode = 4
       ClearMultiSelect
    End If
  End If
End If





         
End Sub


Private Sub Main_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)

MouseX = X
MouseY = y

xer = X
yer = Main.Height - y - 3

  If SubMode = 2 Then
     With vertex(SubModeData)
     .X = xer
     .y = yer
     End With
  End If
     
For i = 1 To MaxVertices
   With vertex(i)
   If .used = True Then
      If xer > (.X - 6) And xer < (.X + 6) Then
         If yer > (.y - 6) And yer < (.y + 6) Then
           'this vertex is meant to be hovered over

           HoverVertex = i
           HoverLink = 0
           Exit Sub
           End If
      End If
   End If
   End With
Next i

For i = 1 To MaxLinks
   With Link(i)
   If .used = True Then
      If x

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -