[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!
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.
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....
Re: What is wrong with my code? Make eneies shoot....
I made the right side enemies shoot use:
vb Code:
Dim temparr3
For temparr3 = 0 To enemyrightnum - 1
If EnemyrightStatus(temparr3) = "Alive Right" And enemyright(temparr3) >= 0 And enemyshotstatusr(temparr3) = "" Then
EnemyrightStatus(temparr3) = "Shoot Right"
noes = noes + 1
enemyshotstatusr(temparr3) = "Shoot"
Exit For
End If
Next temparr3
That is replacing:
with
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.
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 :
To:
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....
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.