Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DragonFireSDK.h"
- #include "time.h"
- // define the variables
- int PresentView, PresentImage, PresentX, PresentY, PresentStartX, PresentStartY, DestinationX, DestinationY, DestinationHeight, DestinationWidth, TiltX, TiltY;
- int Sensitivety=100;
- void AppMain()
- {
- RandomSetSeed(time(0));
- LandscapeMode();
- PresentStartX = 300; // X-Psotion of Present appearing
- PresentStartY = 160; // Y-Psotion of Present appearing
- DestinationX = 10; // X-Position of the slidge
- DestinationY = 100; // Y-Position of the slidge
- DestinationHeight = 50; // Height of your slidge
- DestinationWidth = 50; // Width of your slidge
- PresentImage = ImageAdd("Images/Present.png");
- PresentView = ViewAdd(PresentImage, PresentStartX , PresentStartY);
- }
- void AppExit()
- {
- }
- void OnTimer()
- {
- TiltX=TiltGetx()/Sensitivety;
- TiltY=TiltGety()/Sensitivety;
- ViewSetxy(PresentView, ViewGetx(PresentView)+TiltX, ViewGety(PresentView)+TiltY); // moving the present
- // checking if the present is in the slidge
- if ((ViewGetx(PresentView)>=DestinationX) & (ViewGetx(PresentView)<DestinationX+DestinationWidth) & (ViewGety(PresentView)>=DestinationY) & (ViewGety(PresentView)<DestinationY+DestinationHeight))
- {
- // moving present back to its start place
- // you can randomize the start position simple with the line below
- ViewSetxy(PresentView, PresentStartX , PresentStartY);
- ViewSetxy(PresentView, Random(200)+200 , Random(320));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement