fade.ags 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #
  2. # fade colour program in avdl
  3. #
  4. # it fades from black to a colour, then back to black
  5. #
  6. (class worldMain dd_world
  7. (group
  8. # tracking timing
  9. (def float counter)
  10. (def int positive)
  11. (def int delay)
  12. (function void create (group))
  13. (function void update (group))
  14. (function void draw (group))
  15. (function void clean (group))
  16. )
  17. )
  18. # initialise data
  19. (class_function worldMain void create (group)
  20. (group
  21. (dd_clearColour 0 0 0 1)
  22. (= this.counter 0)
  23. (= this.positive 1)
  24. (= this.delay 30)
  25. )
  26. )
  27. # update each frame
  28. (class_function worldMain void update (group)
  29. (group
  30. # on delay do nothing
  31. (if (> this.delay 0)
  32. (= this.delay (- this.delay 1))
  33. # else
  34. (group
  35. # update clear colour
  36. (dd_clearColour (* this.counter 0.8) (* this.counter 0.6) (* this.counter 1) 1)
  37. # advance animation
  38. (if this.positive
  39. (group
  40. (= this.counter (+ this.counter 0.02))
  41. (if (>= this.counter 1)
  42. (group
  43. (= this.counter 1)
  44. (= this.positive 0)
  45. (= this.delay 100)
  46. )
  47. )
  48. )
  49. # negative advance of animation
  50. (group
  51. (= this.counter (- this.counter 0.02))
  52. (if (<= this.counter 0)
  53. (group
  54. (= this.counter 0)
  55. (dd_clearColour 0 0 0 1)
  56. )
  57. )
  58. )
  59. )
  60. )
  61. ) # if delay
  62. )
  63. ) # update
  64. (class_function worldMain void draw (group) (group))
  65. (class_function worldMain void clean (group) (group))
  66. (function void dd_gameInit (group)
  67. (group
  68. (dd_setGameTitle "fade - avdl")
  69. (dd_world_set_default worldMain)
  70. )
  71. )