Results 1 to 6 of 6

Thread: [RESOLVED] What is wrong with my code? Make eneies shoot....

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Resolved [RESOLVED] What is wrong with my code? Make eneies shoot....

    Okay. I got only the left side to shoot.... But, the code i have set up should make both the left and right side shoot.... Also, only one enemy should shoot when it starts, but all 6 do! Here is my code:

    Code:
        If sn = 20 And noes <> Difficulty + 1 And noes <> 12 And noes < Difficulty + 1 Then
            Dim temparr2
        For temparr2 = 0 To enemyleftnum - 1
            If noes >= Difficulty + 1 Or noes = 12 Then
                Exit For
            End If
            
            If enemyleftstatus(temparr2) = "Alive Left" And enemyleft(temparr2) >= 0 And enemyshotstatusl(temparr2) = "" Then
                enemyleftstatus(temparr2) = "Shoot Left"
                noes = noes + 1
                enemyshotstatusl(temparr2) = "Shoot"
            End If
                
            If noes >= Difficulty + 1 Or noes = 12 Then
                Exit For
            End If
            
                Dim temparr3
                For temparr3 = 0 To enemyrightnum - 1
                    If EnemyrightStatus(temparr3) = "Alive Right" And enemyright(temparr3) <= 269 And enemyshotstatusr(temparr3) = "" Then
                        EnemyrightStatus(temparr3) = "Shoot Right"
                        noes = noes + 1
                        enemyshotstatusr(temparr3) = "Shoot"
                        Exit For
                    End If
                Next temparr3
        Next temparr2
        End If
    I also attached the project as well... Please help me!
    Last edited by Gamemaster1494; May 22nd, 2010 at 07:44 PM.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  2. #2
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: What is wrong with my code? Make eneies shoot....

    I would think you'd want to unnest the second for/next loop.

    I don't see why you'd want to loop the right enemies while inside the loop for the left enemies.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: What is wrong with my code? Make eneies shoot....

    becuase if a shot for the left enemy is made, then make sure if there is room for a shot by the right....
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: What is wrong with my code? Make eneies shoot....

    I made the right side enemies shoot use:

    vb Code:
    1. Dim temparr3
    2.             For temparr3 = 0 To enemyrightnum - 1
    3.                 If EnemyrightStatus(temparr3) = "Alive Right" And enemyright(temparr3) >= 0 And enemyshotstatusr(temparr3) = "" Then
    4.                     EnemyrightStatus(temparr3) = "Shoot Right"
    5.                     noes = noes + 1
    6.                     enemyshotstatusr(temparr3) = "Shoot"
    7.                     Exit For
    8.                 End If
    9.             Next temparr3

    That is replacing:

    vb Code:
    1. (temparr3) <= 269

    with

    vb Code:
    1. (temparr3) >= 0

    Is that what you want?

    Edit:

    I am currently seeing how to solve the other issue you mentioned above. Although, I'm having a difficult time knowing which code does what. It would be a good idea to significantly increase the amount of comments in your code so that people helping you know what does what in your program.
    Last edited by Nightwalker83; May 22nd, 2010 at 03:04 AM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: What is wrong with my code? Make eneies shoot....

    XD I found one problem... This is for the right:

    Code:
            Dim temparr3
            For temparr3 = 0 To enemyrightnum - 1
                If EnemyrightStatus(temparr3) = "Alive Right" And enemyright(temparr3) <= 296 And enemyshotstatusr(temparr3) = "" Then
                    EnemyrightStatus(temparr3) = "Shoot Right"
                    noes = noes + 1
                    enemyshotstatusr(temparr3) = "Shoot"
                    Exit For
                End If
            Next temparr3
    By changing this :

    Code:
    (temparr3) <= 269
    To:
    Code:
    (temparr3) <= 296
    xD
    Now all that is left is to have it stop shooting 12 all the time.... only 2 at first, then 3 for level 2, then 4 for 3, then 5 for 4, and so on, till level 13 and on its always 12....
    Last edited by Gamemaster1494; May 22nd, 2010 at 11:31 AM.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: What is wrong with my code? Make eneies shoot....

    lol. i found out what was wrong. for some odd reason, it was making noes = -72 and such. XD thanks though.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

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