Forum » Programiranje » program ne dela-prosim pomoč(VB)
program ne dela-prosim pomoč(VB)
]Fusion[ ::
Moja koda:
Form:
Const PI = 3.141592654
Const FOCUS = 300
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
Zavrti (5)
Case vbKeyLeft
Zavrti (-5)
End Select
End Sub
Private Sub Form_Load()
Dim n As Integer
With Dots(1)
.Xk = 100
.Yk = 100
.Zk = -100
End With
With Dots(2)
.Xk = 100
.Yk = -100
.Zk = -100
End With
With Dots(3)
.Xk = -100
.Yk = -100
.Zk = -100
End With
With Dots(4)
.Xk = -100
.Yk = 100
.Zk = -100
End With
With Dots(5)
.Xk = 100
.Yk = 100
.Zk = 100
End With
With Dots(6)
.Xk = 100
.Yk = -100
.Zk = 100
End With
With Dots(7)
.Xk = -100
.Yk = -100
.Zk = 100
End With
With Dots(8)
.Xk = -100
.Yk = 100
.Zk = 100
End With
For n = 1 To 8
Draw_Dots (n)
Next n
End Sub
Private Sub Draw_Dots(index)
Dim scX As Long
Dim scY As Long
scX = FOCUS * Dots(index).Xk / (Dots(index).Zk + 250)
scY = FOCUS * Dots(index).Yk / (Dots(index).Zk + 250)
With Line1(index - 1)
.X1 = scX
.X2 = scX
.Y1 = scY
.Y2 = scY
End With
End Sub
Private Sub Zavrti(Kot As Double)
Dim n As Integer
Dim SinKot, CosKot
Dim RadKot As Double
RadKot = CRad(Kot)
SinKot = Sin(RadKot)
CosKot = Cos(RadKot)
For n = 1 To 8
Dots(n).Xk = Dots(n).Zk * SinKot + Dots(n).Xk * CosKot
Dots(n).Zk = Dots(n).Zk * CosKot - Dots(n).Xk * SinKot
Draw_Dots (n)
Next n
End Sub
Function CRad(Deg) As Double
CRad = Deg * (PI / 180)
End Function
Module:
Type Dot
Xk As Long
Yk As Long
Zk As Long
End Type
Public Dots(8) As Dot
Vse dela lepo samo kocko mi med vrtenjem popači(postaja vedno tanjša) in ne vem v čem je problem.
PLEASE HELP!!!
Form:
Const PI = 3.141592654
Const FOCUS = 300
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
Zavrti (5)
Case vbKeyLeft
Zavrti (-5)
End Select
End Sub
Private Sub Form_Load()
Dim n As Integer
With Dots(1)
.Xk = 100
.Yk = 100
.Zk = -100
End With
With Dots(2)
.Xk = 100
.Yk = -100
.Zk = -100
End With
With Dots(3)
.Xk = -100
.Yk = -100
.Zk = -100
End With
With Dots(4)
.Xk = -100
.Yk = 100
.Zk = -100
End With
With Dots(5)
.Xk = 100
.Yk = 100
.Zk = 100
End With
With Dots(6)
.Xk = 100
.Yk = -100
.Zk = 100
End With
With Dots(7)
.Xk = -100
.Yk = -100
.Zk = 100
End With
With Dots(8)
.Xk = -100
.Yk = 100
.Zk = 100
End With
For n = 1 To 8
Draw_Dots (n)
Next n
End Sub
Private Sub Draw_Dots(index)
Dim scX As Long
Dim scY As Long
scX = FOCUS * Dots(index).Xk / (Dots(index).Zk + 250)
scY = FOCUS * Dots(index).Yk / (Dots(index).Zk + 250)
With Line1(index - 1)
.X1 = scX
.X2 = scX
.Y1 = scY
.Y2 = scY
End With
End Sub
Private Sub Zavrti(Kot As Double)
Dim n As Integer
Dim SinKot, CosKot
Dim RadKot As Double
RadKot = CRad(Kot)
SinKot = Sin(RadKot)
CosKot = Cos(RadKot)
For n = 1 To 8
Dots(n).Xk = Dots(n).Zk * SinKot + Dots(n).Xk * CosKot
Dots(n).Zk = Dots(n).Zk * CosKot - Dots(n).Xk * SinKot
Draw_Dots (n)
Next n
End Sub
Function CRad(Deg) As Double
CRad = Deg * (PI / 180)
End Function
Module:
Type Dot
Xk As Long
Yk As Long
Zk As Long
End Type
Public Dots(8) As Dot
Vse dela lepo samo kocko mi med vrtenjem popači(postaja vedno tanjša) in ne vem v čem je problem.
PLEASE HELP!!!
Thomas ::
Kolikor na hitro vidim, je problem v tem:
>Dots(n).Xk = Dots(n).Zk * SinKot + Dots(n).Xk * CosKot
>Dots(n).Zk = Dots(n).Zk * CosKot - Dots(n).Xk * SinKot
X.k, ki ga dobiš v prvi liniji, takoj ponucaš v tadrugi. Potem se ti pa ta učinek kopiči.
Moraš imet ene vmesne spremenljivke!
>Dots(n).Xk = Dots(n).Zk * SinKot + Dots(n).Xk * CosKot
>Dots(n).Zk = Dots(n).Zk * CosKot - Dots(n).Xk * SinKot
X.k, ki ga dobiš v prvi liniji, takoj ponucaš v tadrugi. Potem se ti pa ta učinek kopiči.
Moraš imet ene vmesne spremenljivke!
Man muss immer generalisieren - Carl Jacobi
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | vb.net: dynamic textboxOddelek: Programiranje | 1180 (1070) | saule |
» | visual basic 2008 express editionOddelek: Programiranje | 1815 (1242) | sel |
» | VB in kk dobit Ip od račnalnikaOddelek: Programiranje | 1206 (1040) | alesrosina |
» | API+VBOddelek: Programiranje | 2091 (1795) | webblod |
» | Visual basic Progress barOddelek: Programiranje | 1562 (1495) | Lunik |