Results 1 to 9 of 9

Thread: somthins wrong with this...

  1. #1

    Thread Starter
    Lively Member SmashX's Avatar
    Join Date
    Nov 2002
    Location
    The Space between dreams and reality
    Posts
    86

    somthins wrong with this...

    ok
    I gots a problem and i dono what i did wrong.
    I tryed creating a standalone so that i could upload the program but it tells me theres a varible not defined...

    heres the code, its a bit much but but if you can see somthin that is wrong or needs to be changed i would apresheate it. ill try and upload the file if i can.

    heres the code:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetAsyncKeyState Lib _
    4.                 "user32" _
    5.                 (ByVal vKey As Long) As Integer
    6. Const VK_DOWN = &H28
    7. Const VK_LEFT = &H25
    8. Const VK_RIGHT = &H27
    9. Const VK_UP = &H26
    10.  
    11. Dim intX As Integer
    12. Dim intY As Integer
    13. Dim missile As Integer
    14.  
    15.  
    16.  
    17. Private Sub cmdend_Click()
    18.     End
    19. End Sub
    20.  
    21. Private Sub Form_Load()
    22.     missile = 0
    23.        
    24.     intX = 200
    25.     intY = 200
    26.    
    27.    
    28.     With Me
    29.         .AutoRedraw = True
    30.         .KeyPreview = True
    31.         .PaintPicture imgsuit2.Picture, intX, intY
    32.        
    33.     End With
    34.    
    35.     Timer1.Interval = 10
    36.     Timer1.Enabled = True
    37.     Timer2(missile).Enabled = True
    38.     Timer3.Enabled = True
    39. End Sub
    40.  
    41. Private Sub Timer1_Timer()
    42.  
    43.     If GetAsyncKeyState(VK_RIGHT) <> 0 Then
    44.       intX = intX + 100
    45.       If intX >= 6600 Then
    46.       intX = 2
    47.       End If
    48.     End If
    49.     If GetAsyncKeyState(VK_LEFT) <> 0 Then
    50.       intX = intX - 100
    51.       If intX <= 0 Then
    52.       intX = 6600
    53.       End If
    54.     End If
    55.     If GetAsyncKeyState(VK_UP) <> 0 Then
    56.       intY = intY - 100
    57.     End If
    58.     If intY <= 0 Then
    59.     intY = 6240
    60.     End If
    61.    
    62.     If GetAsyncKeyState(VK_DOWN) <> 0 Then
    63.       intY = intY + 100
    64.       If intY >= 6240 Then
    65.       intY = 2
    66.       End If
    67.      
    68.     End If
    69.     If missile <= 4 Then
    70.    
    71.         If GetAsyncKeyState(65) <> 0 Then
    72.          
    73.             Shape1(missile).Visible = True
    74.         Shape1(missile).Top = intY + 10
    75.         Shape1(missile).Left = intX + 50
    76.    
    77.         Timer2(missile).Enabled = True
    78.         missile = missile + 1
    79.    
    80.         End If
    81.     Else
    82.         Timer2(missile).Enabled = False
    83.     End If
    84.    
    85.    
    86.     Me.Cls
    87.     Me.PaintPicture imgsuit2.Picture, intX, intY
    88.    
    89.        
    90.    
    91. End Sub
    92.  
    93. Private Sub Timer10_Timer()
    94.       imgbot2.Left = imgbot2.Left - 100
    95.     If imgbot2.Left <= 0 Then
    96.         imgbot2.Left = 6960
    97.         Timer11.Enabled = True
    98.         imgbot.Visible = True
    99.         lblmiss.Caption = Val(lblmiss.Caption) + 1
    100.     End If
    101. End Sub
    102.  
    103. Private Sub Timer11_Timer()
    104.     Dim flip2 As Integer
    105.      Randomize
    106.     Label3.Caption = Int(Rnd * (5 - 1) + (1))
    107.     flip2 = Int(Rnd * (5 - 1 + 1) + (1))
    108.     Label3.Caption = flip
    109.     If flip = 1 Then
    110.         imgbot2.Top = 2880
    111.         Timer11.Enabled = False
    112.     End If
    113.     If flip = 2 Then
    114.         imgbot2.Top = 500
    115.         Timer11.Enabled = False
    116.     End If
    117.     If flip = 3 Then
    118.         imgbot2.Top = 5890
    119.         Timer11.Enabled = False
    120.     End If
    121.     If flip = 4 Then
    122.         imgbot2.Top = 3462
    123.         Timer11.Enabled = False
    124.     End If
    125.     If flip = 5 Then
    126.         imgbot2.Top = 280
    127.         Timer11.Enabled = False
    128.     End If
    129. End Sub
    130.  
    131.  
    132.  
    133. Private Sub Timer2_Timer(Index As Integer)
    134.     If missile <= 4 Then
    135.         Shape1(missile).Left = Shape1(missile).Left + 200
    136.     If Shape1(missile).Top + Shape1(missile).Height > imgbot.Top And Shape1(missile).Top < imgbot.Top + imgbot.Height And Shape1(missile).Left + Shape1(missile).Width > imgbot.Left And Shape1(missile).Left < imgbot.Left + imgbot.Width Then
    137.         imgbot.Left = 6960
    138.         Timer9.Enabled = True
    139.         Shape1(missile).Visible = False
    140.         Timer2(missile).Enabled = False
    141.         lblkills.Caption = Val(lblkills.Caption) + 1
    142.     End If
    143.     If Shape1(missile).Top + Shape1(missile).Height > imgbot2.Top And Shape1(missile).Top < imgbot2.Top + imgbot2.Height And Shape1(missile).Left + Shape1(missile).Width > imgbot2.Left And Shape1(missile).Left < imgbot2.Left + imgbot2.Width Then
    144.         imgbot2.Left = 6960
    145.         Timer11.Enabled = True
    146.         Shape1(missile).Visible = False
    147.         Timer2(missile).Enabled = False
    148.         lblkills.Caption = Val(lblkills.Caption) + 1
    149.      End If
    150.     End If
    151. End Sub
    152.  
    153. Private Sub Timer3_Timer()
    154.  
    155.     imgbot.Left = imgbot.Left - 100
    156.     If imgbot.Left <= 0 Then
    157.         imgbot.Left = 6960
    158.         Timer9.Enabled = True
    159.         imgbot.Visible = True
    160.         lblmiss.Caption = Val(lblmiss.Caption) + 1
    161.     End If
    162.  
    163.    
    164.    
    165. End Sub
    166.  
    167. Private Sub Timer4_Timer()
    168.     Line1.X1 = Line1.X1 - 500
    169.     Line1.X2 = Line1.X2 - 500
    170.     If Line1.X2 <= 0 Then
    171.         Line1.X1 = 5400
    172.         Line1.X2 = 6960
    173.     End If
    174.    
    175. End Sub
    176.  
    177. Private Sub Timer5_Timer()
    178.     Line2.X1 = Line2.X1 - 400
    179.     Line2.X2 = Line2.X2 - 400
    180.     If Line2.X1 <= 0 Then
    181.         Line2.X1 = 5640
    182.         Line2.X2 = 6600
    183.     End If
    184.    
    185. End Sub
    186.  
    187. Private Sub Timer6_Timer()
    188.     Line3.X1 = Line3.X1 - 500
    189.     Line3.X2 = Line3.X2 - 500
    190.     If Line3.X2 <= 0 Then
    191.         Line3.X1 = 4320
    192.         Line3.X2 = 5520
    193.     End If
    194. End Sub
    195.  
    196. Private Sub Timer7_Timer()
    197.     Line4.X1 = Line4.X1 - 400
    198.     Line4.X2 = Line4.X2 - 400
    199.     If Line4.X2 <= 0 Then
    200.         Line4.X1 = 4080
    201.         Line4.X2 = 6240
    202.     End If
    203.    
    204. End Sub
    205.  
    206. Private Sub Timer8_Timer()
    207.     Line5.X1 = Line5.X1 - 500
    208.     Line5.X2 = Line5.X2 - 500
    209.     If Line5.X2 <= 0 Then
    210.         Line5.X1 = 4920
    211.         Line5.X2 = 6120
    212.     End If
    213. End Sub
    214.  
    215. Private Sub Timer9_Timer()
    216. Dim flip As Integer
    217.      Randomize
    218.     Label1.Caption = Int(Rnd * (5 - 1) + (1))
    219.     flip = Int(Rnd * (5 - 1 + 1) + (1))
    220.     Label1.Caption = flip
    221.     If flip = 1 Then
    222.         imgbot.Top = 2880
    223.         Timer9.Enabled = False
    224.     End If
    225.     If flip = 2 Then
    226.         imgbot.Top = 840
    227.         Timer9.Enabled = False
    228.     End If
    229.     If flip = 3 Then
    230.         imgbot.Top = 5040
    231.         Timer9.Enabled = False
    232.     End If
    233.     If flip = 4 Then
    234.         imgbot.Top = 3720
    235.         Timer9.Enabled = False
    236.     End If
    237.     If flip = 5 Then
    238.         imgbot.Top = 240
    239.         Timer9.Enabled = False
    240.     End If
    241. End Sub

    all it is is a game where you move your guy around and shoot the bots.
    i tryed to allow shooting multipul missiles by means of an array, but i think i totaly messed it up...
    anyhelp would be great.

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    The best way to have multiple shots is to make an array of UDT...in the UDT put properties for X, Y coordinates, a Vx speed and a Vy speed, and a visible propert...then make an array of that type. Then you need only one timer to move them. Make a loop that loops thru the arrays and moves all the visible shots, and draws them...

  3. #3

    Thread Starter
    Lively Member SmashX's Avatar
    Join Date
    Nov 2002
    Location
    The Space between dreams and reality
    Posts
    86
    I think you forgot who you were talkin to...

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I didn't but wait a sec..and I will see what I can do...

  5. #5
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK look at this code to get an idea...it is bad code...but you should get the idea if you look at it...

    The use of the UDT (userdefined type) in the module may seem a little redundant becuase we are using imageboxes, but when it comes to BitBlt and DX it is a really powerful tool....




    Sorry for this taking so much time, but the girl that I'm living togeter managed to blow a fuse, so my computer wnet down..../

  6. #6
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Hmm, nothing attached to that post.

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Thee like you would have checked out anyway Machaira....just kidding with you ....OK here is the attachment...
    Attached Files Attached Files

  8. #8

    Thread Starter
    Lively Member SmashX's Avatar
    Join Date
    Nov 2002
    Location
    The Space between dreams and reality
    Posts
    86
    your artistic ability rocks!
    wooT!

    *see light at the end of the tunnel*

    thank you.

  9. #9
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Do never underestimate my drawing skills in Paint....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width