main.dd 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # player
  2. (include "playerClass.dd")
  3. (include "pickup.dd")
  4. # main class
  5. ( class world_main World (group
  6. # stage's paddings
  7. # useful to control everything that moves inside it
  8. # also to make sure the game works the same
  9. # way on different screen sizes, by keeping the
  10. # samem aspect ratio
  11. (def int paddingHorizontal)
  12. (def int paddingVertical )
  13. # player
  14. (def playerClass player)
  15. # pickups
  16. (def Pickup pickup)
  17. # clicking the screen moves to next target
  18. (function input (group) (this.player.slowDown))
  19. # start
  20. (function start (group) (group
  21. (= this.paddingHorizontal 10)
  22. (= this.paddingVertical 10)
  23. # init player
  24. (= this.player (new playerClass))
  25. (this.player.init)
  26. # init pickup
  27. (= this.pickup (new Pickup))
  28. (= this.pickup.limitX this.paddingHorizontal)
  29. (= this.pickup.limitY this.paddingVertical)
  30. (this.pickup.init)
  31. (= this.pickup.player this.player.sprite)
  32. ))
  33. # update
  34. (function update (group) (group
  35. (this.player.update)
  36. (this.pickup.update)
  37. (if (>= this.player.sprite.x this.pickup.sprite.x)
  38. (echo "player is right")
  39. )
  40. ))
  41. (function resize (group) (group
  42. ))
  43. # assets
  44. (function assets(group) (group
  45. (return (array "images/dd_logo.png"))
  46. ))
  47. ))