ResumeChannel not working?

Blitz3D Forums/Blitz3D Programming/ResumeChannel not working?

Guy Fawkes(Posted 2009) [#1]
What is wrong w/ this if statement, and how can I make it so when my player is invincible, then pause the level's music, and play the invincible music, but if the player is not invincible anymore, then resume the level music?



I don't see why this WON'T work.


BoneStan(Posted 2009) [#2]
Hi,

;What is wrong w/ this If statement,


Make sure the "(IsInvincible = False)" and other events are not all the time false or true, this make the playsound repeating in a loop.


how can I make it so when my player is invincible, Then pause the level's music, and play the invincible music, but If the player is Not invincible anymore, Then resume the level music?


Add a extra variable For the sound file
name it like "ch_stagemusic" Or "channel_stagemusic" ;(found this methode long time ago in a help file)

So can you control your soundfiles as "channels" with ChannelVolume,PauseChannel etc.
Maybe you need To "Global" these variables too.

Here is a little Pause Resume Example, hope this help some.



Guy Fawkes(Posted 2010) [#3]
Thanks, but now how can I control this w/ the IsInvincible variable, instead of the keyhit?


Kev(Posted 2010) [#4]
use a timmer to decide how long IsInvincible should be true, checking for the ammount of time passed then set IsInvincible to false


Guy Fawkes(Posted 2010) [#5]
if i use createtimer and waittimer, wont it lag the game? oO


Kev(Posted 2010) [#6]
use Millisecs() to create your timmer, sorry i did not mean using inbuilt timmer functions


Guy Fawkes(Posted 2010) [#7]
ok. can u show me a small example of how i can do this? i want the invincibility to last for approximately 30 seconds. then switch IsInvincible to = false.

i edited bonestan's code, but i could be wrong.

code:



the lines ur looking for:




Kev(Posted 2010) [#8]
heres some code that handles timed event queues, its based on types and processes each id of the created timmer event. With modifcation ProcessTimedEvents() function its possable to process many timmed events in each literation of the passed type.

its quite basic but shows how to handle multi timmed events and act on the id of the returned timmer event



Type TEvent
	Field ID
	Field EndTime
	Field Time 
End Type

Graphics3D 640,480,16,2
SetBuffer BackBuffer()
 
time_event.TEvent = New TEvent
time_event\ID = 1
time_event\Time = 1000
time_event\EndTime  = MilliSecs() + time_event\Time


time_event.TEvent = New TEvent
time_event\ID = 2
time_event\Time = 5000
time_event\EndTime  = MilliSecs() + time_event\Time

MilliSecs()


While Not KeyDown(1)

	Cls
		
		eventID = ProcessTimedEvents(time_event)
		Select(eventID)
		
			Case 1
				Text 10,20,"Event ID - " + eventID

			Case 2
				Text 10,20,"Event ID - " + eventID
				
		Default
			Text 10,20,"No Event in queue" 
		End Select
		
	Flip
	
	
Wend
End

Function ProcessTimedEvents(e.TEvent)

	If e.TEvent <> Null
		For e.TEvent = Each TEvent
			
			If MilliSecs() > e\EndTime Then
				; remove timer event
				Delete e
				Return False
			Else
				Return e\ID
			EndIf
			
		Next
	EndIf
	
End Function



Guy Fawkes(Posted 2010) [#9]
it only works if the 1st time is lower than the 2nd :S


Guy Fawkes(Posted 2010) [#10]
i dont know why it does this. and i waited for 20 hours to bump, so bump


jfk EO-11110(Posted 2010) [#11]

Repeat
Cls

;Display
Text 5,5,message$

invtime = Millisecs()
invincibletime = Millisecs()*30000

If invtime = invincibletime then IsInvincible = False



Even only "Millisecs()*30000" looks terrible wrong to me.

Here's a simple demo:

invtime = Millisecs()+30000
while keyhit(1)=0
 if millisecs() > invtime then
  IsInvincible = 0
  print "IsInvincible is now Zero"
 endif
wend

Millisecs() returns the number of milliseconds since the latest System Bootup. This may be a very high number. Testing for the diffrence between two Millisecs() (one earlier, one later) is the only theing that makes sense with Millisecs().

You can also do something every 30 Seconds:

invtime = Millisecs()+30000
while keyhit(1)=0
 if millisecs() > invtime then
  IsInvincible = 0
  print "IsInvincible is now Zero"
  invtime = Millisecs()+30000 ; sets the timer for the next task
 endif
wend



Guy Fawkes(Posted 2010) [#12]
ok, now how can i make this work every x amount of seconds that max time equals instead of from time to time playing the invincible sound and waiting for x seconds then pausing?

code:




Matty(Posted 2010) [#13]
Perhaps try to break down your confusing statement:
now how can i make this work every x amount of seconds that max time equals instead of from time to time playing the invincible sound and waiting for x seconds then pausing?


into more manageable, shorter sentences. If you do that you may be able to see for yourself how to work this out.

from Matt


Guy Fawkes(Posted 2010) [#14]
um, matty, i already tried that. if i could figure it out, i wouldnt be asking u. Also, JA2, I KNOW ur going to smart off so go ahead, and I shall continue ignoring u


Kev(Posted 2010) [#15]
this fixes the problem above, i find it much easyer to use types and a function to process timmed events

Type TEvent
	Field ID
	Field EndTime
	Field Time 
End Type

Graphics3D 640,480,16,2
SetBuffer BackBuffer()
 
time_event.TEvent = New TEvent
time_event\ID = 1
time_event\Time = 8000
time_event\EndTime  = MilliSecs() + time_event\Time


time_event.TEvent = New TEvent
time_event\ID = 2
time_event\Time = 5000
time_event\EndTime  = MilliSecs() + time_event\Time

MilliSecs()


While Not KeyDown(1)

	Cls
		time_event.TEvent  = First TEvent
		ProcessTimedEvents(time_event)
	
	Flip
	
	
Wend
End

Function ProcessTimedEvents(e.TEvent)

	If e.TEvent <> Null
		
		For e.TEvent = Each TEvent
			
			If MilliSecs() < e\EndTime Then

				Select(e\ID)
				
					Case 1
						Text 10,20,"Event ID - " + e\ID
		
					Case 2
						Text 10,40,"Event ID - " + e\ID
						
				End Select
			Else
				Delete e
				
				Return False
			EndIf
			
		Next
	EndIf
	
End Function




Guy Fawkes(Posted 2010) [#16]
ok, now how can i fix this code so it doesn't lag the invincibility music? this is basically what i needed the timer for anyway

code:



it works GREAT this way, it just needs to stop lagging the sound


JA2(Posted 2010) [#17]
Also, JA2, I KNOW ur going to smart off so go ahead, and I shall continue ignoring u

I said nothing. You bring me into this and then say you're ignoring me. Stupid...


Guy Fawkes(Posted 2010) [#18]
call me another name, and i will cuss u into last night


JA2(Posted 2010) [#19]
call me another name, and i will cuss u into last night

Instead of starting arguments, why don't you go back to working on 'your code' you ungrateful brat...


Guy Fawkes(Posted 2010) [#20]
So the 'idiot' does have a dark side. why don't u go back to ur deathstar, YOU ungreatful brat. -.-


JA2(Posted 2010) [#21]
So the 'idiot' does have a dark side. why don't u go back to ur deathstar, YOU ungreatful brat. -.-

Awww is that the best you can do, Rez? I thought you were going to cuss me into last night? Hahahahahaha


Ross C(Posted 2010) [#22]
Yes, I too would like to see this "time travel". You really do bring things onto yourself.


Guy Fawkes(Posted 2010) [#23]
Because I'm not going to stoop to 'your' level. And you pressuring me will NEVER get me to speak.


Ross C(Posted 2010) [#24]
What the hell are you talking about? Speak about what? What level? Anyway, i think matt's advise was to break the problem into tiny chunks, and try and address it that way. It may make alot more sense.


JA2(Posted 2010) [#25]
Because I'm not going to stoop to 'your' level. And you pressuring me will NEVER get me to speak.

I'm not pressuring you to do anything, Rez. You're the one who brought me into this yet again.

You keep saying that you'll ignore me and that you're leaving the Blitz forums. I'm wondering at what point are you actually going to STFU and piss off?


Guy Fawkes(Posted 2010) [#26]
BACK THE HELL OFF, JA2! I'm already having enough family problems as it is, I DON'T need YOUR help! :@ Go to hell, and NEVER COME BACK! LEAVE ME ALONE!!!!


Yasha(Posted 2010) [#27]
Rez, here is a little piece of advice I learned a while back:

Every time you catch yourself typing in capitals, remember that your backspace key was included for a reason. There is absolutely no reason to get worked up about text on a forum page. Delete, start again, repeat as necessary. Take a break for ten minutes if the pace of the discussion is getting to you and write your reply later - the forum isn't going anywhere.

Also, if you want people to stay away from you, don't ask them to insult you when they weren't already. Post #14 is really just inviting retribution.


Ginger Tea(Posted 2010) [#28]
So the 'idiot' does have a dark side. why don't u go back to ur deathstar, YOU ungreatful brat. -.-


dont diss the deathstar
im eyeing up the lego one with all the minifigs