intro.dd 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # dark dimension intro
  2. (class dd_world_main dd_world
  3. (group
  4. # tracking timing
  5. (def float counter)
  6. (def int positive)
  7. (def int delay)
  8. # dark dimension logo
  9. (def dd_meshColour logo)
  10. (def dd_sound sound)
  11. (def int soundPlayed)
  12. (def float scale)
  13. # constractor
  14. (function create (group)
  15. (group
  16. # initialise animation values
  17. (dd_clearColour 0 0 0 1)
  18. (= this.counter 0)
  19. (= this.positive 1)
  20. (= this.delay 30)
  21. # initialise dd logo
  22. (dd_meshColour_create this.logo)
  23. (this.logo.load "logo.ply")
  24. (this.logo.set_colour 0 0 0)
  25. (dd_sound_create this.sound)
  26. (this.sound.load "dd_theme.wav" 0)
  27. (= this.soundPlayed 0)
  28. (= this.scale 1)
  29. )
  30. )
  31. (function resize (group)
  32. (group
  33. (def float height)
  34. (= height (/ (dd_screen_height_get 5) 3.5)) # 3.0 = height of logo
  35. (def float width)
  36. (= width (/ (dd_screen_width_get 5) 6.3)) # 6.3 = width of logo
  37. (if (< width height)
  38. (= this.scale width)
  39. # else
  40. (= this.scale height)
  41. )
  42. )
  43. )
  44. # update - update animations
  45. (function update (group)
  46. (group
  47. # on delay do nothing
  48. (if (> this.delay 0)
  49. (= this.delay (- this.delay 1))
  50. # else
  51. (group
  52. # update clear colour
  53. (dd_clearColour (* this.counter 0.8) (* this.counter 0.6) (* this.counter 1) 1)
  54. # advance animation
  55. (if this.positive
  56. (group
  57. (= this.counter (+ this.counter 0.01))
  58. (if (&& (> this.counter 0.25) (== this.soundPlayed 0))
  59. (group
  60. (this.sound.play)
  61. (= this.soundPlayed 1)
  62. )
  63. )
  64. (if (>= this.counter 1)
  65. (group
  66. (= this.counter 1)
  67. (= this.positive 0)
  68. (= this.delay 120)
  69. )
  70. )
  71. )
  72. (group
  73. (= this.counter (- this.counter 0.01))
  74. (if (<= this.counter 0)
  75. (group
  76. (= this.counter 0)
  77. (dd_world_set dd_world_menu)
  78. (def (ref dd_world_menu) cmenu cworld)
  79. (= cmenu.fromIntro 1)
  80. (dd_clearColour 0 0 0 1)
  81. )
  82. )
  83. )
  84. )
  85. )
  86. ) # if delay
  87. )
  88. )
  89. # draw
  90. # zoom-out so the world is visible
  91. # rotate the world
  92. # draw the cube
  93. (function draw (group)
  94. (group
  95. (glTranslatef 0 0 -5)
  96. (glScalef this.scale this.scale this.scale)
  97. (this.logo.draw)
  98. )
  99. )
  100. (function key_input (group char key)
  101. (group
  102. )
  103. )
  104. (function clean (group)
  105. (group
  106. (this.sound.clean)
  107. (this.logo.clean)
  108. (dd_world_clean this)
  109. )
  110. )
  111. )
  112. ) # main world