intro.dd 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. (include "intro.ddh")
  2. # Init intro
  3. (class_function world_intro void create (group)
  4. (group
  5. # initialise animation values
  6. (dd_clearColour 0 0 0 1)
  7. (= this.counter 0)
  8. (= this.positive 1)
  9. (= this.delay 30)
  10. # initialise dd logo
  11. #(this.logo.load (asset "assets/logo.ply" DD_PLY))
  12. (this.logo.load (asset "assets/logo.asset" DD_PLY))
  13. (this.logo.set_colour 0 0 0)
  14. # initialise dd sound
  15. (this.sound.load (asset "assets/dd_theme.asset" DD_PLY) 0)
  16. (= this.soundPlayed 0)
  17. # used for resizing
  18. (= this.scale 1)
  19. (this.font.setAlign DD_STRING3D_ALIGN_CENTER)
  20. (this.font.setColorFront 0.0 0.0 0.0)
  21. (this.font.setColorBack 0.0 0.0 0.0)
  22. )
  23. ) # create
  24. (class_function world_intro void onload (group)
  25. (group
  26. )
  27. )
  28. # Resize to keep the logo constantly visible
  29. (class_function world_intro void resize (group)
  30. (group
  31. (def float height)
  32. (= height (/ (dd_screen_height_get 5) 3.5)) # height of logo
  33. (def float width)
  34. (= width (/ (dd_screen_width_get 5) 6.3)) # width of logo
  35. (if (< width height)
  36. (= this.scale width)
  37. # else
  38. (= this.scale height)
  39. )
  40. )
  41. ) # resize
  42. # update - update animations
  43. (class_function world_intro void update (group)
  44. (group
  45. # on delay do nothing
  46. (if (> this.delay 0)
  47. (= this.delay (- this.delay 1))
  48. # else
  49. (group
  50. # update clear colour
  51. (dd_clearColour (* this.counter 0.8) (* this.counter 0.6) (* this.counter 1) 1)
  52. # advance animation
  53. (if this.positive
  54. (group
  55. (= this.counter (+ this.counter 0.02))
  56. (if (&& (> this.counter 0.25) (== this.soundPlayed 0))
  57. (group
  58. #(this.sound.play)
  59. (= this.soundPlayed 1)
  60. )
  61. )
  62. (if (>= this.counter 1)
  63. (group
  64. (= this.counter 1)
  65. (= this.positive 0)
  66. (= this.delay 100)
  67. )
  68. )
  69. )
  70. # negative advance of animation
  71. (group
  72. (= this.counter (- this.counter 0.02))
  73. (if (<= this.counter 0)
  74. (group
  75. (= this.counter 0)
  76. (dd_world_prepareReady world_intro 1)
  77. (dd_clearColour 0 0 0 1)
  78. )
  79. )
  80. )
  81. )
  82. )
  83. ) # if delay
  84. )
  85. ) # update
  86. # draw
  87. # zoom-out so the world is visible
  88. # rotate the world
  89. # draw the cube
  90. (class_function world_intro void draw (group)
  91. (group
  92. (dd_translatef 0 0 -5)
  93. (dd_scalef this.scale this.scale this.scale)
  94. (dd_translatef 0 0.5 0)
  95. (this.logo.draw)
  96. (dd_translatef 0 -1.5 0)
  97. (dd_scalef 0.8 0.8 0.1)
  98. (this.font.draw "dark dimension")
  99. )
  100. )
  101. (class_function world_intro void key_input (group char key)
  102. (group
  103. (if (== key 27)
  104. (= dd_flag_exit 1) # exit game
  105. )
  106. )
  107. )
  108. # Clean intro world
  109. (class_function world_intro void clean (group)
  110. (group
  111. )
  112. )