Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include "DragonFireSDK.h"
  2. #include "time.h"
  3.  
  4. // define the variables
  5.  
  6. int PresentView, PresentImage, PresentX, PresentY, PresentStartX, PresentStartY, DestinationX, DestinationY, DestinationHeight, DestinationWidth, TiltX, TiltY;
  7.  
  8. int Sensitivety=100;
  9.  
  10.  
  11.  
  12. void AppMain()
  13. {
  14. RandomSetSeed(time(0));
  15. LandscapeMode();
  16.  
  17. PresentStartX = 300; // X-Psotion of Present appearing
  18. PresentStartY = 160; // Y-Psotion of Present appearing
  19.  
  20. DestinationX = 10; // X-Position of the slidge
  21. DestinationY = 100; // Y-Position of the slidge
  22. DestinationHeight = 50; // Height of your slidge
  23. DestinationWidth = 50; // Width of your slidge
  24.  
  25. PresentImage = ImageAdd("Images/Present.png");
  26.  
  27. PresentView = ViewAdd(PresentImage, PresentStartX , PresentStartY);
  28. }
  29.  
  30. void AppExit()
  31. {
  32. }
  33.  
  34. void OnTimer()
  35. {
  36. TiltX=TiltGetx()/Sensitivety;
  37. TiltY=TiltGety()/Sensitivety;
  38.  
  39. ViewSetxy(PresentView, ViewGetx(PresentView)+TiltX, ViewGety(PresentView)+TiltY); // moving the present
  40.  
  41.  
  42. // checking if the present is in the slidge
  43. if ((ViewGetx(PresentView)>=DestinationX) & (ViewGetx(PresentView)<DestinationX+DestinationWidth) & (ViewGety(PresentView)>=DestinationY) & (ViewGety(PresentView)<DestinationY+DestinationHeight))
  44. {
  45. // moving present back to its start place
  46. // you can randomize the start position simple with the line below
  47. ViewSetxy(PresentView, PresentStartX , PresentStartY);
  48.  
  49. ViewSetxy(PresentView, Random(200)+200 , Random(320));
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement