I want my movie to start later in the game

BlitzPlus Forums/BlitzPlus Beginners Area/I want my movie to start later in the game

En929(Posted 2011) [#1]
I uploaded a movie into my game and I want my movie to start after an enemy has been defeated. But, with the "OpenMovie" command it keeps starting at the beginning. Thus, what do I add to my game program to make it so that my game movie starts later?

Below is a simplified code example of my game. I wrote notes with arrows below pertaining to the movie and what I'm trying to do with it, so that the things pertaining to what I'm trying to do can be easy to find. Thanks.



Graphics 1640, 1000 
SetBuffer BackBuffer()
GameTimer = CreateTimer(60)


Global HENRYIMAGE = LoadAnimImage ("HenryMoveAroundIII.PNG",400,370,0,14)
Global GAS_STATION = LoadImage ("Shell-gas-station-forSale[1].jpg")
Global ENEMYPICTURE = LoadImage ("Enemy1.png")
Global ENEMY1
Global ENEMY1APPEAR = True 









Global Movie = OpenMovie ("HE.avi") ;<--------- (I'm trying to get this movie to start after ENEMY1 is defeated,
		;Thus, I want it to start later in the game and not at the beginning. More notes are below) -------------------------------->







Type HENRY
	Field x,y	
	Field frame
	Field image 
	Field Time
End Type 

Type Film
	Field x,y,w,h
	Field image
	Field Start
End Type 


Type ENEMY1
	Field x,y
	Field image
End Type 

Type BACKGROUND
	Field x,y
	Field image
End Type



Global h.HENRY = New HENRY
h\x = 500
h\y = 300
h\image = HENRYIMAGE
h\frame = 1


Global B.BACKGROUND = New BACKGROUND
b\x = 100
b\y = -40
b\image = GAS_STATION






 
Global f.Film = New Film
f\x = 550
f\y = 300
f\w = 400
f\h = 300
f\image = Movie ;  <------------------------------(I made the film as an "image" variable here if this is ok)---------->


 





Global Movement = 3
  

While Not KeyDown(1)


Cls








DrawMovie f\image, f\x,f\y,f\w,f\h ;<---------(This is the movie drawn to the screen. I don't know if this is in the right place).-------------->










DrawImage (b\image, b\x,b\y)

	

WaitTimer(GameTimer)

HenryCharacteristics()
EnemyCharacteristics()

Collisions()



Flip

Wend  




Function HenryCharacteristics()


If h\frame = 13 Then

	h\frame = 1
EndIf 


If h\y <= 450 Then 

	h\y = h\y + 5
	
EndIf 


		
			
DrawImage (h\image,h\x,h\y,h\frame)
			
			
If KeyDown (205) Then 	

  	If h\time<MilliSecs()

		h\x = h\x + 10
	
		h\frame = h\frame + 1
	
	 	h\time = MilliSecs()+100
	
	
		 	If h\frame > 2 Then
	
			   h\frame = 1
		
		    EndIf	
	
 	EndIf 	
	
EndIf 

If KeyDown (203) Then 	

  	If h\time<MilliSecs()

		h\x = h\x - 10
	
		h\frame = h\frame + 1
	
	 	h\time = MilliSecs()+80
	
	
		 	If h\frame > 5 Then
	
			   h\frame = 4
		
		    EndIf	
	
 	EndIf 	
	
EndIf 



If KeyDown (200) Then 	

  	If h\time<MilliSecs()

		

			h\y = h\y - 10
	
			h\frame = h\frame + 1
	
	 		h\time = MilliSecs()+80
	
			
		 	If h\frame > 2 Then
	
			   h\frame = 1
		
		    EndIf	
	
 	EndIf 	
	
EndIf 

If KeyDown (208) Then 	

  	If h\time<MilliSecs()

		

			h\y = h\y + 10
	
			h\frame = h\frame + 1
	
	 		h\time = MilliSecs()+80
	
			
		 	If h\frame > 5 Then
	
			   h\frame = 4
		
		    EndIf	
	
 	EndIf 	
	
EndIf 


If KeyDown (25) Then
				
	If h\time< MilliSecs()	
		
		h\frame = 7
		
		h\time = MilliSecs()+30
				
			If Not KeyHit (25) Then 
					
				h\frame = 6
						
					 		
					
			EndIf 
					
				
	EndIf 
				
EndIf 

			
				
End Function 


Function EnemyCharacteristics()



e1.ENEMY1 = New ENEMY1
e1\x = 400
e1\y = 425
e1\image = ENEMYPICTURE

If ENEMY1APPEAR = True Then 

For e1.ENEMY1 = Each ENEMY1



DrawImage (e1\image,e1\x,e1\y)




e1\x = e1\x + MOVEMENT 
			


If e1\x > 700 Then MOVEMENT = -MOVEMENT 
If e1\x < 400 Then MOVEMENT = 3  




Exit
Next 

EndIf 




End Function 












Function Collisions();<---------- (This is the only collision in this example and after this collision I want the movie to start)------------------>







For e1.ENEMY1 = Each ENEMY1
If KeyDown (25) Then
			






        If ImagesCollide (e1\image,e1\x,e1\y,0,h\image,h\x,h\y,7) And ENEMY1APPEAR Then    <---------- (again, after this collision occurs, it is 

when I want the movie to start).----------------->
	
							ENEMY1APPEAR = False 
							Delete e1
							 
							b\x = 10000
							h\x = 100000
							
						
							
			

       EndIf 
EndIf 



Exit
Next 


End Function 










;--------------------------------------------------That's all for now. Thank you --------------------------------



Last edited 2011


Midimaster(Posted 2011) [#2]
You should combine this with a flag NowDefeated%, which switches to 1, when the enemy ist defeated:

While Not KeyDown(1)
      Cls
      If NowDefeated=1
          DrawMovie f\image, f\x,f\y,f\w,f\h 
      Endif
       .....
Wend

.....

Function Collisions()
	For e1.ENEMY1 = Each ENEMY1
		If KeyDown (25) Then
			If ImagesCollide (e1\image,e1\x,e1\y,0,h\image,h\x,h\y,7) And ENEMY1APPEAR Then	
				ENEMY1APPEAR = False
				NowDefeated=1
				.....





En929(Posted 2011) [#3]
MidiMaster, thanks. It worked in the order that I wanted. But the audio in the movie still starts before I want it to. Thus how do I get the movie and audio from the movie to start at the same time after the collision and without getting an error that says “Invalid Movie Graphics Handle?”

Last edited 2011


Midimaster(Posted 2011) [#4]
Oh! I did not know that: the movie will already start when you use the command OPENMOVIE().

This means that you cannot pre-load the movie, but must load it in the moment of collision:

....
			If ImagesCollide (e1\image,e1\x,e1\y,0,h\image,h\x,h\y,7) And ENEMY1APPEAR Then	
				ENEMY1APPEAR = False
				NowDefeated=1
				e1\Image=OpenMovie ("HE.avi")
....



En929(Posted 2011) [#5]
Thanks again, Midimaster. I got it to work.