Advertisement
Guest User

somefuncs

a guest
Jul 2nd, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. function int fx_px(int x, int scale)
  3. {
  4. return (FixedMul(x,scale<<16)>>16)<<16;
  5. }
  6.  
  7.  
  8. function int scalerange(int oldmin, int oldmax, int newmin, int newmax, int oldvalue)
  9. {
  10. int OldRange = (OldMax - OldMin);
  11. int NewRange = (NewMax - NewMin) ;
  12. int newvalue = fixeddiv(fixedmul((oldvalue -oldmin),newrange),oldrange)+newmin;
  13. return newvalue;
  14. }
  15.  
  16. function int MagicRatioX (void)
  17. {
  18. int ratio_current = itof(getscreenwidth()) / getscreenheight();
  19. int ratio_43 = 0.75;
  20. int ret = fixedmul(ratio_current,ratio_43);
  21. ret -=1.0;
  22. ret = ret/2;
  23.  
  24. return ret;
  25. }
  26.  
  27.  
  28. script "testprint"
  29. {
  30.  
  31. int hudx= 640;
  32. int hudy = 480;
  33. int xpos = 0.15; //anything from 0.0 to 1.0
  34. int ypos = 0.10; //anything from 0.0 to 1.0
  35. sethudsize(hudx,hudy,0);
  36.  
  37. while(true)
  38. {
  39. HudMessage(s:"A"; HUDMSG_PLAIN 4, CR_UNTRANSLATED, fx_px(scalerange(0.0,1.0,-magicratiox() ,1.0 + magicratiox(),xpos),hudx), fx_px(ypos,hudy), 1.0/35);
  40. delay(1);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement