Difference between revisions of "Source:Hack 1.0/hack.track.c"
Jump to navigation
Jump to search
m (Automated source code upload) |
Kernigh bot (talk | contribs) m (Hack 1.0/hack.track.c moved to Source:Hack 1.0/hack.track.c: Robot: moved page) |
(No difference)
|
Latest revision as of 22:41, 3 March 2008
Below is the full text to hack.track.c from the source code of Hack 1.0. To link to a particular line, write [[Hack 1.0/hack.track.c#line123]], for example.
Warning! This is the source code from an old release. For the latest release, see Source code
Screenshots and source code from Hack are used under the CWI license.
1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ 2. 3. #include "hack.h" 4. #ifdef TRACK 5. #define UTSZ 50 6. 7. coord utrack[UTSZ]; 8. int utcnt = 0; 9. int utpnt = 0; 10. 11. initrack(){ 12. utcnt = utpnt = 0; 13. } 14. 15. /* add to track */ 16. settrack(){ 17. if(utcnt < UTSZ) utcnt++; 18. if(utpnt == UTSZ) utpnt = 0; 19. utrack[utpnt].x = u.ux; 20. utrack[utpnt].y = u.uy; 21. utpnt++; 22. } 23. 24. coord * 25. gettrack(x,y) register x,y; { 26. register int i,cnt; 27. coord tc; 28. cnt = utcnt; 29. for(i = utpnt-1; cnt--; i--){ 30. if(i == -1) i = UTSZ-1; 31. tc = utrack[i]; 32. if((x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y) < 3) 33. return(&(utrack[i])); 34. } 35. return(0); 36. } 37. #endif TRACK