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