Gå til innhold

Anbefalte innlegg

Videoannonse
Annonse

Imports System
Imports System.Windows.Forms
Module Main
       Sub Main
               Dim fMainForm As New MainForm
               fMainForm.ShowDialog()
       End Sub
       
       Public Class MainForm
               Inherits System.Windows.Forms.Form
                  Public Sub New
                     MyBase.New()
                       Me.Text = "This is my form"
                       MsgBox("Hello World")
               End Sub
               
       End Class
       
End Module

 

:woot:

Lenke til kommentar

Lag et enkelt 3D program som bare tegner 3D linjer, eller et rutenett:

Public Class Form1
 Inherits System.Windows.Forms.Form
 Protected timer1 As Timer
 Protected graph As Graphics
 Sub New()
   MyBase.New()
   timer1 = New timer()
   timer1.Interval = 100
   timer1.Start()
   graph = Me.CreateGraphics()
 End Sub
 Public Function Point3D(X As Single, Y As Single, Z As Single) As Point
   Return New Point(X / Z, Y / Z)
 End Function
 Public Sub Line3D(g As Graphics, p As Pen, X1 As Single, Y1 As Single, Z1 As Single, X2 As Single, Y2 As Single, Z2 As Single)
   g.DrawLine(p, Point3D(X1,Y1,Z1), Point3D(X2,Y2,Z2))
 End sub
 Public Sub DrawGrid(g As Graphics, Width As Single, Height As Single, Cols As Integer, Rows As Integer, ZLocation As Single)
   Static cWidth As Single = Width / cols
   Static cHeight As Single = Height / rows
   Static xx As Single = 0, yy As Single = 0
   Dim p As Pen = Pens.Green
   Dim X As Integer, Y As Integer
   xx = -(cwidth / 2)
   yy = -(cheight / 2)
   For Y = 0 To Rows
     yy += cheight
     Line3D(g, p, xx, yy, ZLocation, xx, yy + cheight, ZLocation)
   Next
   yy = -(cheight/2)
   xx = -(cwidth/2)
   For X = 0 To Cols
     Line3D(g, p, xx, yy, ZLocation, xx + cwidth, yy, ZLocation)
     xx += cwidth
   Next
 End Sub
 Private Sub Timer1_Tick(sender as Object, e As EventArgs) Handles Timer1_Tick
   Static X As Double
   X += 0.001
   DrawGrid(graph, 128, 128, 16, 16, Sin(X)*128 + 128)
 End Sub
End Class

Tegner et 3D rutenett som går i sinusbølge fra, og mot skjermen(ikke testet)

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...