Need help with this code please.

Blitz3D Forums/Blitz3D Beginners Area/Need help with this code please.

CnfuzedCoder(Posted 2003) [#1]
This is driving me nuts. When my game switches levels (after the last enemy on the screen is gone) the explosion animation carries over into the next level. I think a laser shot from the player blips on there as well.

I would like the game to show the complete explosion of the last enemy dying rather than go to the next level immediately. Here is some code, let me know if you need to see more of it.

This part is in the main loop
 	;If there are no enemies left on screen, player has beaten level. Begin next level.
	If numofenemies = 0 Then
	
		;Make the player's level increment by one
		level = level + 1
		
		;Initalize the new level
		InitializeLevel(level)
	EndIf 


And here is the InitializeLevel() function

 Function InitializeLevel(level)

;Delete every bullet
For i.bullet = Each bullet
	Delete i
Next

;Display intro text
Text screenwidth / 2,screenheight / 2,"NOW ENTERING Level " + level,True,True
Flip

;Delay for a few seconds
Delay 2000

;Reset player's hitcounter
player\hits = 3

;reset player's frame
player\frame = 7   ;(7 is the middle frame)

;Make the total number of enemies a value between 3 and 5 + the current level
numofenemies = level + Rand(3 , 5)    ;Level 1 will have 4-6 enemies, 2 will have 5-7, etc.

;reset health boxes' frame
healthframe = 0

;create the required number of enemies
For e=1 To numofenemies

	CreateNewEnemy(level) 
Next
	
End Function 



jfk EO-11110(Posted 2003) [#2]
maybe you shoulf decrement numofenemies AFTER the Explosions? Or use a second, parallel variable, numofenemiesOnscreen or something?


CnfuzedCoder(Posted 2003) [#3]
I thought the decrementing after the explosions would have done it. I'm lost in my own code! I'll move on to something else and come back to it with a fresh brain.

Thanks for the suggestions.


WolRon(Posted 2003) [#4]
Not sure how you are implementing your explosions but basically just check to make sure none of them are left.

If numofenemies = 0 AND NUMOFEXPLOSIONS = 0 Then ...