עזרה בפתרון תקלה בפרויקט VB - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

עזרה בפתרון תקלה בפרויקט VB


ניר.

Recommended Posts

רציתי לדעת בכלליות מה בשגיאה אומרת ואיך פותרים אותה אבל הינה הקוד שגורם לבעיה...


Option Explicit

Dim ball As GufType, table As GufType, walls(1 To 11) As GufType
Dim Peres As Point3D, ballCenter As Point3D, tableCenter As Point3D
Dim bp1 As Point3D, bp2 As Point3D, tp1 As Point3D, tp2 As Point3D
Dim tableBorder As Border, ballBorder As Border
Dim W!, H!, score%, lifes%, moneWalls%

Private Type BorderPoint
Max As Single
Min As Single
End Type

Private Type Border
X As BorderPoint
z As BorderPoint
End Type

Private Type recordType
i As Integer
z As Single
End Type
Private Sub printBorderInfo(a As Border)
MsgBox "max X=" + Str(a.X.Max) + " min X=" + Str(a.X.Min) + " max Z=" + Str(a.z.Max) + " min Z=" + Str(a.z.Min), , "ערכי הגבול"
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
ballCenter = Center(ball) ' center of ball

bp1 = ballCenter
bp1.X = bp1.X + 10

bp2 = ballCenter
bp2.z = bp2.z + 10

tp1 = tableCenter
tp1.X = tp1.X + 10

tp2 = tableCenter
tp2.Y = tp2.Y + 10

ballBorder.X.Max = Max_Coordinate_In_Vertices(ball, 1)
ballBorder.X.Min = Min_Coordinate_In_Vertices(ball, 1)
ballBorder.z.Max = Max_Coordinate_In_Vertices(ball, 3)
ballBorder.z.Min = Min_Coordinate_In_Vertices(ball, 3)

'בדיקת הפסד
If lifes = 0 Then
MsgBox "הפסדת במשחק , ניקודך הוא : " + Str(score), , "הפסדת במשחק"
Form2.Hide
Form1.Show
End If
'סיום בדיקת הפסד

'הוזזת הכדור
If tableBorder.z.Min > ballBorder.z.Min - 60 Then
If KeyCode = 40 Then 'down key
SivuvGeneral ball, ballCenter, bp1, -5
MoveBody ball, 0, 0, 5
End If
End If

If KeyCode = 37 Then 'left key
SivuvGeneral ball, ballCenter, bp2, -5
MoveBody ball, -5, 0, 0
End If

If KeyCode = 38 Then 'up key
SivuvGeneral ball, ballCenter, bp1, 5
MoveBody ball, 0, 0, -5
End If

If KeyCode = 39 Then 'right key
SivuvGeneral ball, ballCenter, bp2, 5
MoveBody ball, 5, 0, 0
End If

If KeyCode = 27 Then 'exit and return main
Form2.Hide
Form1.Show
End If
'סיום הוזזת הכדור

If KeyCode = 67 Then 'check button
'printBorderInfo tableBorder
'printBorderInfo ballBorder
'MsgBox "סך הכול החיים : " + Str(lifes)
MsgBox "ערך המונה של הקירות : " + Str(moneWalls)
End If

If tableBorder.z.Min = ballBorder.z.Min Then
lifes = lifes - 1
End If

drawWithHiding 'ציור כל הגופים עם הסתרה
End Sub
Private Sub Form_Load()
Caption = "לוח משחק"

score = 0
lifes = 4
moneWalls = 0

Label1.Caption = "ניקוד : " + Str(score)
Label2.Caption = "חיים : " + Str(lifes)
ScaleMode = vbPixels
FillStyle = vbSolid
WindowState = vbMaximized
End Sub
Private Sub Form_Resize()
W = ScaleWidth
H = ScaleHeight

Label3.Caption = Date
Label4.Caption = Time

timerRefresh.Interval = 1000
timerRefresh.Enabled = True

tableBorder.X.Max = Max_Coordinate_In_Vertices(table, 1)
tableBorder.X.Min = Min_Coordinate_In_Vertices(table, 1)
tableBorder.z.Max = Max_Coordinate_In_Vertices(table, 3)
tableBorder.z.Min = Min_Coordinate_In_Vertices(table, 3)

Peres.X = W / 2
Peres.Y = H / 2
Peres.z = 600

FillColor = vbBlue 'ציור השולחן
GetBody App.Path + "\Cube", table
Normalize_Vertices table
Silum table, 3750, 20, 3750
MoveToCenter Form2, table
MoveBody table, 0, 100, 100
tableCenter = Center(table) 'מרכז השולחן
'Draw_SOLID_Perespective_NEW Form2, table, Peres

FillColor = vbYellow 'הגדרת הכדור
GetBody App.Path + "\BALL10", walls(11)
Normalize_Vertices walls(11)
Silum walls(11), 60, 60, 60
MoveToCenter Form2, walls(11)
MoveBody walls(11), 0, 130, -71.90177
'Draw_SOLID_Perespective_NEW Form2, walls(11), Peres

FillColor = vbRed 'הגדרת הקיר
GetBody App.Path + "\Cube", walls(1)
Normalize_Vertices walls(1)
Silum walls(1), 200, 100, 200
MoveToCenter Form2, walls(1)
MoveBody walls(1), 100, 150, -88.21352
'Draw_SOLID_Perespective_NEW Form2, walls(1), Peres

Dim i As Integer
walls(6) = walls(1)
addVertexAtCenter walls(6)
addVertexAtCenter walls(1)
moneWalls = moneWalls + 1
For i = 1 To 5
walls(i) = walls(1) 'redWalls
addVertexAtCenter walls(i)
moneWalls = moneWalls + 1
Next i
For i = 6 To 10
walls(i) = walls(1) 'greenWalls
addVertexAtCenter walls(i)
moneWalls = moneWalls + 1
Next i
drawWithHiding
End Sub
Private Sub timerRefresh_Timer()
Label1.Caption = "ניקוד : " + Str(score)
Label2.Caption = "חיים : " + Str(lifes)
Label3.Caption = Date
Label4.Caption = Time
End Sub
Private Sub drawWithHiding()
Dim j%, k%, l%
Dim arr(1 To moneWalls) As recordType

For j = 1 To moneWalls
arr(j).i = j
arr(j).z = walls(j).V(walls(j).vertices, 3)
Next j
'========= מיון בועות ===========
For k = 1 To moneWalls - 1
For l = k + 1 To moneWalls
If arr(k).z > arr(l).z Then
swap arr, k, l
End If
Next l
Next k

Cls
FillColor = vbBlue
Draw_SOLID_Perespective_NEW Form2, table, Peres

For k = 1 To moneWalls
FillColor = QBColor(1 + arr(k).i)
Draw_SOLID_Perespective_NEW Form2, walls(arr(k).i), Peres
Next k
FillColor = vbYellow
Draw_SOLID_Perespective_NEW Form2, walls(11), Peres
End Sub
Private Sub swap(arr() As recordType, k%, l%)
Dim rec As recordType
rec = arr(k)
arr(k) = arr(l)
arr(l) = rec
End Sub

לפי איתור הבאגים של התוכנה הוא מצביע על הקוד שנמצא ב - Private Sub drawWithHiding()...

קישור לתוכן
שתף באתרים אחרים

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...