Article View: comp.sys.mac
Article #19200Re: LightSpeed C special effects
From: David Phillip Oster
Date: Wed, 16 Sep 1987 21:14
Date: Wed, 16 Sep 1987 21:14
60 lines
3849 bytes
3849 bytes
In article <3320011@hpcid.HP.COM> tedj@hpcid.HP.COM (Ted Johnson) asks how
to do a few things:
As the author of Stars, I feel qualified to answer.
>1)showing one PICT picture (or a line of text) and then dissolving
> that picture (or text) to show another picture (or text) beneath it.
Think of a picture, say 1000x1000 pixels as consisting of pixels
numbered 0 to 999999. If you replaced each pixel in the original in
order by a pixel from the new picture, the new picture would appear in
scan line bands. Suppose you "shuffled" the numbers from 0 to 999999
and used that shuffleto bring in pixels from the new picture. Since
the human eye has a bad memory for randomness, you only have to
shuffle them once, and you can reuse that shuffle and have it still
look good. The shuffle is encoded as a pseudo-random number generator
that has a non-repitition period longer than the number of pixels in
the picture. The design of such random number generators is given in
Knuth's Art of Computer Programming, Vol 1. Semi-Numerical Algorithms.
In addition, there wave been articles on exactly how to do this
published in MacTutor magazine.
>2)expanding a line of text inside a window, making it seem to
> explode. One way to do this would be to just keep changing the font
> size (10, 12, etc). Is there a better way?
Pre-render the different sized images and save the successive images
as PICTs. Flash the PICTs on the screen with DrawPicture. Pre-load
and HNoPurge() the PICTs from disk before going into your animation
cycle, so that there will be no embarassing disk waits while you are
animating. Remember that DrawPicture will scale its PICT arg to
whatever rectangle you tell it (so you can enlarge something to make
it really big.)
>3)the "Star Trek" effect, like in LightSpeed C's About... box.
This should be "Star Wars Hyperspace" effect.
Start with a "galaxy of stars ": an array of points in 3 space. I use
-4000 < x < 4000, -4000 < y < 4000, 0 < z < 150. Points are initially
randomly distributed within these ranges. You simulate moving through
the space by decrementing the Z coordinates of all the stars. You
project from 3space to 2space with:
x2 = x3/z3
y2 = y3/z3
If, after the decrement, the star has moved on the screen, you erase
it from its old position (a CopyBits in Xor mode) and draw it in its
new position (a CopyBits in Xor mode.) If the "z" of a star goes to
zero, then you've passed it. Create a new star on the horizon (i.e.
with Z = Zmax.)
That gives you your normal space travel effect. Now for HyperSpace:
Save the initial positions of all the stars. Now, animate until you've
passed all the stars, as above, only this time don't do any erasing.
Once you've passed everything, restore the initial state and do it
again, only this time the Xor drawing will erase everything that was
on the screen before. You can use OR and AND if Xor scares you for
this.
--- David Phillip Oster --My Good News: "I'm a perfectionist."
Arpa: oster@dewey.soe.berkeley.edu --My Bad News: "I don't charge by the hour."
Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu
Technical Details
Message-ID:
<20702@ucbvax.BERKELEY.EDU>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!aurora!labrea!jade!ucbvax!dewey.soe.berkeley.edu!osterReferences:
<3320011@hpcid.HP.COM>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!aurora!labrea!jade!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac Subject: Re: LightSpeed C special effects Message-ID: <20702@ucbvax.BERKELEY.EDU> Date: Wed, 16-Sep-87 17:14:07 EDT Article-I.D.: ucbvax.20702 Posted: Wed Sep 16 17:14:07 1987 Date-Received: Sat, 19-Sep-87 11:46:33 EDT References: <3320011@hpcid.HP.COM> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 60