ZoriaRPG

ScrollFix() for std.zh v2.0

Jul 3rd, 2017
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Allows drawing tiles to correct position on Link when scrolling
  2. // Sets drawX/drawY either to Link X/Y when not scrolling, or the visual position when scrolling.
  3. // currently only used by Pegasus Boots (which is also setting drawX/drawY to Link's new x/y as he dashes)
  4.  
  5. const int STD_SCROLLDIR = 100;
  6. const int STD_SCROLL_COUNTER = 101;
  7. const int STD_SCROLL_DRAWX = 102;
  8. const int STD_SCROLL_DRAWY = 103;
  9. void scrollDir(int d){ stdGlobalRAM[STD_SCROLLDIR] = d; }
  10. int scrollDir() { return stdGlobalRAM[STD_SCROLLDIR]; }
  11. void scrollCounter(int v) { stdGlobalRAM[STD_SCROLL_COUNTER] += v; }
  12. int scrollCounter() { return stdGlobalRAM[STD_SCROLL_COUNTER]; }
  13. int scrollDrawX(){ return stdGlobalRAM[STD_SCROLL_DRAWX]; }
  14. void scrollDrawX(int v){ stdGlobalRAM[STD_SCROLL_DRAWX] = v; }
  15. int scrollDrawY(){ return stdGlobalRAM[STD_SCROLL_DRAWY]; }
  16. void scrollDrawY(int v){ stdGlobalRAM[STD_SCROLL_DRAWY] = v; }
  17.  
  18. void ScrollFixInit() { scrollFix(-1); }
  19.  
  20. void ScrollFix() //function by Saffith
  21. {
  22.     if(Link->Action==LA_SCROLLING)
  23.     {
  24.         if(scrollDir()==-1)
  25.         {
  26.             if(Link->Y>160)
  27.             {
  28.                 scrollDir(DIR_UP);
  29.                 scrollCounter(45);
  30.             }
  31.             else if(Link->Y<0)
  32.             {
  33.                 scrollDir(DIR_DOWN);
  34.                 scrollCounter(45);
  35.             }
  36.             else if(Link->X>240)
  37.             {
  38.                 scrollDir(DIR_LEFT);
  39.                 scrollCounter(65);
  40.             }
  41.             else
  42.             {
  43.                 scrollDir(DIR_RIGHT);
  44.                 scrollCounter(65);
  45.             }
  46.         }
  47.    
  48.         if(scrollDir()==DIR_UP && scrollCounte()r<45 && scrollCounter()>4)
  49.             scrollDrawY(scrollDrawY()+4);
  50.         else if(scrollDir()==DIR_DOWN && scrollCounter()<45 && scrollCounter()>4)
  51.             scrollDrawY(scrollDrawY()-4);
  52.         else if(scrollDir()==DIR_LEFT && scrollCounter()<65 && scrollCounter()>4)
  53.             scrollDrawX(scrollDrawX()+4);
  54.         else if(scrollDir()==DIR_RIGHT && scrollCounter()<65 && scrollCounter()>4)
  55.             scrollDrawX(scrollDrawX()-4);
  56.    
  57.         scrollCounter(-1);
  58.     }
  59.     else
  60.     {
  61.         scrollDrawX(Link->X);
  62.         scrollDrawY(Link->Y);
  63.         if(scrollDir()!=-1) scrollDir(-1);
  64.     }
  65. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×