Guest User

Animation

a guest
Dec 1st, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. @DrawLoop {
  2.  
  3. SetTexture(boss); //tells Danmakufu what image to use
  4. SetRenderState(ALPHA); //how the image is rendered, this shouldn't need to be explained
  5. SetAlpha(255); //how transparent the image is
  6. SetGraphicScale(1,1); //the scale of the image, in this case the default
  7. SetGraphicAngle(0,0,0); //the angle the image is drawn at, in this case the default
  8.  
  9. if(int(GetSpeedX())==0){ //checks if the horizontal speed of the boss is lower than 1 pixel/second. if this is true, the block of code inside is executed
  10. if(f<10){ SetGraphicRect(0,0,64,64); } //if less than ten frames have passed, the contents of the image will be at the coordinates (0,0,64,64)
  11. if(f>=10 && f<20){ SetGraphicRect(64,0,128,64); } //if less than twenty and more than or equal to ten frames have passed, image contents will be between (64,0,128,64)
  12. if(f>=20 && f<30){ SetGraphicRect(128,0,192,64); } etc.
  13. if(f>=30 && f<40){ SetGraphicRect(192,0,256,64); }
  14. f2=0; //the counter for movement is reset here.
  15. }
  16.  
  17. if(GetSpeedX()>0){ //checks if the horizontal speed is bigger than zero (positive). (Moving to the right) if this is true, the code inside is executed
  18. if(f2<5){ SetGraphicRect(0,64,64,128); } //the same as above
  19. if(f2>=5 && f2<10){ SetGraphicRect(64,64,128,128); }
  20. if(f2>=10 && f2<15){ SetGraphicRect(128,64,192,128); }
  21. if(f2>=15){ SetGraphicRect(192,64,256,128); }
  22. f2++; //increases the counter for movement, so that the contents of the drawn image will change, and the animation will play
  23. }
  24.  
  25. if(GetSpeedX()<0){ //checks if the horizontal speed is smaller than zero (negative).(Moving to the left) if this is true, the code inside is executed
  26. SetGraphicAngle(180,0,0); //mirrors the image
  27. if(f2<5){ SetGraphicRect(0,64,64,128); } //this code is the same as in the block of code for moving to the right
  28. if(f2>=5 && f2<10){ SetGraphicRect(64,64,128,128); }
  29. if(f2>=10 && f2<15){ SetGraphicRect(128,64,192,128); }
  30. if(f2>=15){ SetGraphicRect(192,64,256,128); }
  31. f2++;
  32. }
  33.  
  34. DrawGraphic(GetX,GetY); //draws the graphic
  35.  
  36. f++; //increases the counter for the default (idle) animation, so that the animation will play
  37. if(f==40){f=0;} //if the counter for the default animation becomes too big, it is reset
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment