Post by deo on Oct 15, 2024 9:55:46 GMT
im trying to make a gps like system heres the code :
this is only a snippet of my code, for debug purposes only but it does the basic work done. After pressing the button to go to the gps module the gps works fine but after that instead of going gps1 it just freezes. Can some 1 help me here, Thank you
(bplus EDITED code by removing blank lines)
DECLARE SUB homepg
DECLARE SUB typg
DECLARE SUB lpg
DECLARE SUB mainpg
DECLARE SUB staffverif
DECLARE SUB staffpg
DECLARE SUB smenu
DECLARE SUB cusdet
DECLARE SUB menu
DECLARE SUB order
DECLARE SUB cbill
DECLARE SUB gps
DECLARE SUB gps1
Cls
Call homepg
End
'-------------------------- Home Page Subroutine --------------------------
Sub homepg
key$ = ""
Cls
Dim imgh As Long
Screen _NewImage(800, 600, 32)
imgh = _LoadImage("logo.png")
_PutImage (50, 100), imgh
Locate 10, 8
Print "Welcome To"
Locate 27, 38
Print "Press Enter to continue"
Locate 29, 40
Print "Press Esc to exit"
Do
key$ = InKey$
Loop Until key$ <> ""
If key$ = Chr$(27) Then
Call typg
Else
Call mainpg
End If
End Sub
'-------------------------- Type Page Subroutine --------------------------
Sub typg
Cls
Dim img2 As Long
Screen _NewImage(1000, 700, 32)
img2 = _LoadImage("typg.png")
_PutImage (50, 0), img2
End Sub
'-------------------------- Loading Page Subroutine --------------------------
Sub lpg
Screen 12
Cls
For i = 0 To 6
Line (140 - i, 200 - i)-(480 + i, 280 + i), 7, B
Next i
Line (140, 200)-(480, 280), 7, BF
a = 0
For k = 140 To 480 Step 34
Sleep 1
Line (140, 200)-(k, 280), 15, BF
Locate 20, 35
Print "LOADING"; a; "%"
a = a + 10
If a >= 0 And a <= 30 Then
Locate 12, 34
Print "Preparing..."
ElseIf a >= 40 And a <= 70 Then
Locate 12, 34
Print "Cooking..."
ElseIf a >= 80 And a <= 100 Then
Locate 12, 30
Print "Adding Final Touches..."
End If
Next k
End Sub
'-------------------------- Main Page Subroutine --------------------------
Sub mainpg
Cls
Dim img3 As Long
Screen _NewImage(800, 600, 32)
img3 = _LoadImage("b1.png")
_PutImage (303, 180), img3
img3 = _LoadImage("b2.png")
_PutImage (303, 296), img3
img3 = _LoadImage("b3.png")
_PutImage (600, 476), img3
img3 = _LoadImage("b4.png")
_PutImage (70, 476), img3
img3 = _LoadImage("b5.png")
_PutImage (260, 60), img3
Locate 1, 1
Print "DATE:"; Date$
Locate 1, 87
Print "TIME:"; Time$
Line (50, 50)-(750, 50), , B
Line (50, 50)-(50, 550), , B
Line (750, 50)-(750, 550), , B
Line (50, 550)-(750, 550), , B
Line (50, 50)-(60, 60), , B
Line (750, 50)-(740, 60), , B
Line (50, 550)-(60, 540), , B
Line (750, 550)-(740, 540), , B
buttonActive = 1
Do
While _MouseInput And buttonActive
If _MouseX >= 303 And _MouseX <= 303 + 191 And _MouseY >= 180 And _MouseY <= 180 + 93 And _MouseButton(1) Then
Sleep 1
Call lpg
Call gps
buttonActive = 0
ElseIf _MouseX >= 303 And _MouseX <= 303 + 191 And _MouseY >= 296 And _MouseY <= 296 + 93 And _MouseButton(1) Then
Sleep 1
Call lpg
buttonActive = 0
ElseIf _MouseX >= 600 And _MouseX <= 600 + 127 And _MouseY >= 476 And _MouseY <= 476 + 66 And _MouseButton(1) = -1 Then
Sleep 1
Call lpg
buttonActive = 0
ElseIf _MouseX >= 70 And _MouseX <= 70 + 133 And _MouseY >= 476 And _MouseY <= 476 + 66 And _MouseButton(1) Then
Sleep 1
Call homepg
buttonActive = 0
End If
Wend
Loop While InKey$ = ""
Do
k$ = InKey$
Loop Until k$ <> ""
buttonActive = 0
End Sub
'-------------------------- GPS Subroutine --------------------------
Sub gps
Screen _NewImage(800, 600, 32)
Randomize Timer
_AutoDisplay
Cls
PSet (0, 0), _RGB(30, 30, 30)
For x = 0 To 800 Step 40
For y = 0 To 600 Step 40
Line (x, y)-(x + 40, y + 40), _RGB(80, 80, 80), B
Next
Next
deliveryX = 40
deliveryY = 40
destX = Int(Rnd * 760) + 40
destY = Int(Rnd * 560) + 40
Do
Cls
PSet (0, 0), _RGB(30, 30, 30)
For x = 0 To 800 Step 40
For y = 0 To 600 Step 40
Line (x, y)-(x + 40, y + 40), _RGB(80, 80, 80), B
Next
Next
Circle (deliveryX, deliveryY), 10, _RGB(255, 0, 0)
Circle (destX, destY), 10, _RGB(0, 255, 0)
If deliveryX < destX Then deliveryX = deliveryX + 1
If deliveryX > destX Then deliveryX = deliveryX - 1
If deliveryY < destY Then deliveryY = deliveryY + 1
If deliveryY > destY Then deliveryY = deliveryY - 1
If deliveryX = destX And deliveryY = destY Then Exit Do
_Display
_Limit 60
Loop
Call gps1
End Sub
'-------------------------- GPS1 Subroutine --------------------------
Sub gps1
Cls
Locate 10, 10
Print "Do you want to navigate again? (Y/N)"
Do
k$ = InKey$
Loop Until k$ = "Y" Or k$ = "N"
If k$ = "Y" Then
Call gps
Else
Call homepg
End If
End Sub
this is only a snippet of my code, for debug purposes only but it does the basic work done. After pressing the button to go to the gps module the gps works fine but after that instead of going gps1 it just freezes. Can some 1 help me here, Thank you
(bplus EDITED code by removing blank lines)