import random
import math
import util
import sys
from demoscript import *
sched = SchedulerSingleton_instance() # setup scheduler

joypad1=0
#addMapping(joypad1,0,"taptap")	# map button a 
#addMapping(joypad1,0,"bass")	# map button a 
addMapping(joypad1,0,"noise")	# map button a 
addMapping(joypad1,1,"noise2")	# map button a 
#addMapping(joypad1,1,"butB")	# map button a 
#addMapping(joypad1,2,"butX")	# map button a 
#addMapping(joypad1,3,"butY")	# map button a 
#addMapping(joypad1,1,"next")	# map button a 


kak=util.SimpleScene("d:\\demos\\demo\\kak.pck",noiseEvents=[[2,"butB"]],nextCamera=["butX"],reset=["butY"],colors=[[1,"butA"]])


"""
mos=Mosaic(128,128)
kak.connectOutput(mos,"in")
overflow=util.SimpleOverflow(events=["butB"],colors=[10,10,10])
kak.connectOutput(overflow,"in")
blur=util.SimpleBlur(events=["butB"])
overflow.connectOutput(blur,"in")
"""


blur=Blur()
blur2=Blur()

mos2=Mosaic(16,16)
gammaa=util.FixedGamma(colors=[7,7,7])


blur.setAdditive(1)
blur2.setAdditive(1)


kak.connectOutput(gammaa,"in")
gammaa.connectOutput(blur2,"in")
blur2.connectOutput(blur,"in")
blur.connectOutput(mos2,"in")


kak2=util.SimpleScene("d:\\demos\\demo\\kak2.pck",noiseEvents=[[2,"butB"]],nextCamera=["butX"],reset=["butY"],colors=[[1,"butA"]])
kak3=util.SimpleScene("d:\\demos\\demo\\kak3.pck",noiseEvents=[[2,"butB"]],nextCamera=["butX"],reset=["butY"],colors=[[1,"butA"]])
kak4=util.SimpleScene("d:\\demos\\demo\\kak4.pck",noiseEvents=[[2,"butB"]],nextCamera=["butX"],reset=["butY"],colors=[[1,"butA"]])
kak5=util.SimpleScene("d:\\demos\\demo\\kak5.pck",noiseEvents=[[2,"butB"]],nextCamera=["butX"],reset=["butY"],colors=[[1,"butA"]])
kak4.speed=FixedSlider(32000,32000)



#kak.connectOutput(overflow,"in")


"""
sched.schedule(0,60,blur,SI_A,0)
"""

adder=Add()
mos2.connectOutput(adder,"a")
kak.connectOutput(adder,"b")




sched.schedule(0,53,kak2,SI_A,0)
sched.schedule(53,82.713-53,adder,SI_A,0)
sched.schedule(82.713,118.2-82.713,kak3,SI_A,0)
sched.schedule(118.2,30,kak5,SI_A,0)
sched.schedule(118.2+30,30,kak4,SI_A,0)
sched.schedule(178.2,201.5-178.2,adder,SI_A,0)

overflow=util.RandomOverflow(events=["butB"],colors=[10,10,10])
distort=util.SimpleDistort([[3,"noise"],[43,"noise2"]],distVal=0)

distort.connectOutput(overflow,"in")

noise=util.SimpleNoise(["noise"])

overflow.connectOutput(noise,"in")


sched.schedule(0,201.5,noise,SI_POST,0)

imgseq=util.SimpleImageSeq([Image("d:\\demos\\demo\mfxzijnhomos.tga")],nextImage=["butB"])


sched.schedule(201.5,20,imgseq,SI_SUPER,0)




##############################
playSong("d:\\demos\\demo\\music.wma")
