home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / LipSync / PeterPiper2D.dba < prev    next >
Encoding:
Text File  |  2001-01-23  |  3.3 KB  |  127 lines

  1. `Peter Piper 2D, a lip sync demo
  2. `⌐ 2000, Steve Tiffany, freely distributable
  3. `Basically, you load 7 different face images, each with the mouth in
  4. `a different shape, and you make it talk by changing the image that
  5. `the head-sprite displays.
  6. `The mouth-shape data is made using my program Lip Sync Lab,
  7. `available on my web site at www.stevetiffany.com/vintage.html
  8. `Character modelled in Amorphium.
  9.  
  10. `Click mouse to stop.
  11.  
  12. gosub SetUp
  13.  
  14. do
  15.    `pause for a second before speaking, and between recitations...
  16.    sleep 1000
  17.    restore peterpiper : soundnum=1 : gosub SayIt
  18.    restore picked : soundnum=2 : gosub SayIt
  19.    restore apeckof : soundnum=3 : gosub SayIt
  20.    restore pickledpeppers : soundnum=4 : gosub SayIt
  21.  
  22.    restore apeckof : soundnum=3 : gosub SayIt
  23.    restore pickledpeppers : soundnum=4 : gosub SayIt
  24.    restore did : soundnum=5 : gosub SayIt
  25.    restore peterpiper : soundnum=1 : gosub SayIt
  26.    restore pick : soundnum=6 : gosub SayIt
  27.  
  28.    restore _if : soundnum=7 : gosub SayIt
  29.    restore peterpiper : soundnum=1 : gosub SayIt
  30.    restore picked : soundnum=2 : gosub SayIt
  31.    restore apeckof : soundnum=3 : gosub SayIt
  32.    restore pickledpeppers : soundnum=4 : gosub SayIt
  33.  
  34.    restore howmany : soundnum=8 : gosub SayIt
  35.    restore pickledpeppers : soundnum=4 : gosub SayIt
  36.    restore did : soundnum=5 : gosub SayIt
  37.    restore peterpiper : soundnum=1 : gosub SayIt
  38.    restore pickQ : soundnum=9 : gosub SayIt
  39. loop
  40.  
  41. `play the sound and display the mouth shapes...
  42. SayIt:
  43.    play sound soundnum
  44.    read nummouths
  45.    for k=1 to nummouths
  46.       oldtimer=timer()
  47.       read mouthshape
  48.       read waittime
  49.       sprite 1,255,8,mouthshape
  50.       sync
  51.  
  52.       while timer()<oldtimer+waittime
  53.          if mouseclick()=1 then gosub CleanUp
  54.       endwhile
  55.    next k
  56.  
  57. `wait here if the sound is still playing when you run out of mouths...
  58.    while sound playing(soundnum)
  59.       if mouseclick()=1 then gosub CleanUp
  60.    endwhile
  61. return
  62.  
  63. CleanUp:
  64.    cls 0
  65.    wait 10
  66.    for j=1 to 8
  67.       delete image j
  68.    next j
  69.    delete sprite 1
  70.    for j=1 to 9
  71.       delete sound j
  72.    next j
  73.    cls
  74. end
  75.  
  76. SetUp:
  77.    hide mouse
  78. `load sounds 1-9...
  79.    for j=1 to 9
  80.       read soundname$
  81.       a$="wav\"+soundname$+".wav"
  82.       load sound a$,j
  83.    next j
  84. `body becomes image 8 so images 1-7 are mouths and match the data...
  85.    load bitmap "bmp\torso.bmp",1
  86.    get image 8,0,0,382,307
  87. `load face bitmap...
  88.    create bitmap 1,1302,200
  89.    load bitmap "bmp\7smallfaces.bmp",1
  90. `get faces as images
  91.    for j=0 to 6
  92.       get image 1+j,j*185,0,(j*185)+185,199
  93.    next j
  94.    delete bitmap 1
  95. `display body...
  96.    paste image 8,168,174
  97. `display first face...
  98.    sprite 1,255,7,1
  99.  
  100. `put Sync On down here or you briefly see background without bob
  101. `(when there's a background, that is...)
  102.    sync on
  103. return
  104.  
  105. soundnames:
  106. data "peterpiper","picked","apeckof","pickledpeppers","did"
  107. data "pick","_if","howmany","pickQ"
  108.  
  109. peterpiper:
  110. data 10,1,48,6,64,2,32,3,32,4,96,1,64,3,128,1,48,3,48,4,64
  111. picked:
  112. data 3,1,48,3,80,2,128
  113. apeckof:
  114. data 6,3,176,1,48,3,144,2,128,3,80,7,144
  115. pickledpeppers:
  116. data 11,1,48,3,80,2,32,3,48,2,64,1,48,3,80,1,64,3,64,4,96,2,240
  117. did:
  118. data 3,2,32,3,64,2,80
  119. pick:
  120. data 4,1,64,3,144,2,160,1,80
  121. _if:
  122. data 2,3,96,7,256
  123. howmany:
  124. data 7,2,80,5,64,4,48,1,32,3,32,2,96,6,160
  125. pickQ:
  126. data 4,1,64,3,208,2,160,1,208
  127.