home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22017 < prev    next >
Encoding:
Internet Message Format  |  1993-01-23  |  2.9 KB

  1. Path: sparky!uunet!usc!sol.ctr.columbia.edu!hamblin.math.byu.edu!yvax.byu.edu!physc1.byu.edu!seth
  2. Newsgroups: comp.sys.mac.programmer
  3. Subject: Several specific questions...
  4. Message-ID: <1993Jan23.011024.365@physc1.byu.edu>
  5. From: seth@physc1.byu.edu
  6. Date: 23 Jan 93 01:10:24 -0700
  7. Distribution: world
  8. Organization: Brigham Young University
  9. Lines: 42
  10.  
  11. Hi. I am fairly inexperienced yet, and I have run into something I don't know
  12. how to improve. Here goes:
  13. I am writing one of those types of programs where lots of complex calculations
  14. need to be going on all continuously, and yet still allow an event loop to be
  15. going on so that I can react to user input in menus. My program is calculating
  16. the orbit of a planet the whole time. user input can change the planet's
  17. location and scale of the screen at any time, thus also changing where the 
  18. planet is displayed on the screen. The way I have done it so far is to just
  19. include a statement where I enter my calculation procedure, calculate the
  20. position in maybe 30 time increments, leave the procedure, enter a procedure
  21. where I update the screen to reflect the planet's movement, then go continue
  22. on with WaitNextEvent. I set the SLEEP value to zero for the time being, 
  23. because to do otherwise slowed the planet down a lot. Now the question is, is
  24. there a better way to have something going on during the event loop that does
  25. not result in much of a slowdown? I would LIKE to allow other things a LITTLE
  26. time in the background, but I recognise that to be any decent speed, my
  27. program needs to hog most all of the cpu time.
  28. Another question I have concerns drawing the planet. I have heard stuff about
  29. using small cursor icons and the CopyBits function to sort of animate this
  30. movement. Currently I just move the pen to where I start out, and then when 
  31. I update the position I simply DrawTo the currently x and y coordinates of
  32. the planet. This is fine for getting the program to work, but I really want to
  33. do the animation. Can anyone point me to some simple example code that does
  34. this sort of animation? I have never seen any, and despite what I have read
  35. about it, I am still somewhat confused at just how it is done, and I would
  36. like to look at some code. 
  37. My final question: I am currently using floating-point numbers to represent the
  38. x and y coordinates, and I have the 68882 option on in THINK Pascal. I have
  39. been told that I can speed up my calculations a lot if I change it all to
  40. fixed-point math. I would like to learn how this works, but I haven't been
  41. able to find any reference stuff on it. I don't have the Apple Numerics Man.
  42.  
  43. By the way, this is only a learning experience for me, and yes, it is in fact
  44. inspired by the program "Gravitation" by Jeff Rommereide. I wanted to do a
  45. project that would allow me to get my feet wet in mac programming, so I 
  46. decided to write my own solar-system simulator.
  47.  
  48.  
  49. Thanks a million for any hints you can give me!
  50. Seth Leigh
  51. BYU Physics Dept.
  52.  
  53.