# show demoscript definitions
import demoscript
print "testing module."
print dir(demoscript)
print "ok."

from demoscript import *
import math
print "initing demo system"

# setup texture manager
tm = TextureManagerSingleton_instance()

# setup scheduler
sched = SchedulerSingleton_instance()

#########################
### Demo starts here. ###
#########################


## DER COMMANDER
scn0 = llScene("d:\\head.pck")
scene = Scene()
scene.setScene(scn0)
scene.speed=6000

b0 = Bitmap("d:\\tehrobot.jpg");


class WalkScene(Scene):
	def __init__(self):
		Scene.__init__(self)
		self.offset=FixedSlider(0,0)
		
	def callback(self):
		if getEvent(EC_NOTE_ON,0,0):
			self.offset(7200)
		if getEvent(EC_NOTE_ON,0,1):
			self.nextCamera()
			time=0
			
			
	def __del__(self):	
		Scene.__del__(self)

walkscn=llScene("d:\\robotwalk.pck")
walkscene=WalkScene()
walkscene.setScene(walkscn)



class RobotOverlay(Overlay):
	def __init__(self):
		Overlay.__init__(self)
		self.scale.setDamping(0.96)
		self.opacity=FixedSlider(1.0,1.0)
		self.opacity.setDamping(0.96)
		
	def callback(self):
		if getEvent(EC_NOTE_ON,0,0):
			self.posy.setTargetValue(1)
			
	def __del__(self):	
		Overlay.__del__(self)


robotpic=Bitmap("d:\\watchout.jpg")
roverlay=RobotOverlay()
robotpic.connectOutput(roverlay,"map")




class RobotScene(Scene):
	def __init__(self):
		Scene.__init__(self)
		
	def callback(self):
		if getEvent(EC_NOTE_ON,0,1):
			self.nextCamera()
			self.time=0
			
	def __del__(self):	
		Scene.__del__(self)

## ROBOT (FROM SPACE)
scn1 = llScene("d:\\robot.pck")
scene2 = RobotScene()
scene2.setScene(scn1)

class CustomOverlay(Overlay):
	def __init__(self):
		Overlay.__init__(self)
		self.scale.setDamping(0.96)
		self.opacity=FixedSlider(0.0,0.0)
		self.opacity.setDamping(0.96)
		
	def callback(self):
		if getEvent(EC_NOTE_ON,0,0):
			self.scale.setTargetValue(1.3)
			self.opacity.setTargetValue(1)
			
	def __del__(self):	
		Overlay.__del__(self)


class CustomBlur(Blur):
	def __init__(self):
		Blur.__init__(self)
		self.spread.setDamping(0.96)
	
	def callback(self):
		if getEvent(EC_NOTE_ON,0,1):
			self.spread.setTargetValue(3)
	
	def __del__(self):	
		Blur.__del__(self)


overlay=CustomOverlay()

b0.connectOutput(overlay,"map")

addoverlay = Add();
overlay.connectOutput( addoverlay, "b" );
scene2.connectOutput( addoverlay, "a" );


sched.schedule(0,14,scene,SI_A,0)
sched.schedule(14,20,addoverlay,SI_A,0)

distort=Distort()
roverlay.connectOutput(distort,"in")


sched.schedule(34,10,distort,SI_A,0)
sched.schedule(44,20,walkscene,SI_A,0)

visscn=llScene("d:\\vissen.pck")
visscene=WalkScene()
visscene.speed=6000
visscene.setScene(visscn)


fish=Bitmap("d:\\fish.jpg")
over1=Overlay()
fish.connectOutput(over1,"map")
add1=Add()
over1.connectOutput(add1,"a")
visscene.connectOutput(add1,"b")




sched.schedule(64,20,add1,SI_A,0)


alienscn=llScene("d:\\alien.pck")
alienscene=WalkScene()
alienscene.setScene(alienscn)


enslaved=Bitmap("d:\\enslaved.jpg")
over2=Overlay()
enslaved.connectOutput(over2,"map")


#scn1 = llScene("d:\\robot.pck")
#scene3 = RobotScene()
#scene3.setScene(scn1)

#d2=Distort()
#scene3.connectOutput(d2,"map")


add2=Add()
over2.connectOutput(add2,"a")
alienscene.connectOutput(add2,"b")

sched.schedule(84,23.5,addoverlay,SI_A,0)
sched.schedule(103.5,20,add2,SI_A,0)


 