🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
4 messages
4 total messages Started by David Strout Tue, 11 Aug 1992 14:42
Animating lots of small bitmaps
#533
Author: David Strout
Date: Tue, 11 Aug 1992 14:42
11 lines
999 bytes
I need to animate many (up to 40) small (48>x>20) bitmaps in a view
under 3.0.  (Think what the X game netrek looks like)  I tried doing
it with a subview per bitmap, but that flashed badly.  I tried putting
them all in the drawSelf:: of the main view, but that makes the whole
view flash.  Current idea is to define a Type 3 font with my bitmaps,
then use xyshow to draw them.  This seems really gross.  If I wanted
to do graphics with fonts, I'd program (pick one: X, TI99/4a, IBM PCs)
etc.  Does anyone have a better method?  Ideas welcome, example code 
even better.

dave.
Re: Animating lots of small bitmaps
#1107
Author: Andrew Loewenstern
Date: Wed, 12 Aug 1992 04:09
21 lines
1462 bytes
In article <22171@venera.isi.edu> dstrout@darpa.mil (David Strout) writes:
>I need to animate many (up to 40) small (48>x>20) bitmaps in a view
>under 3.0.  (Think what the X game netrek looks like)  I tried doing
>it with a subview per bitmap, but that flashed badly.  I tried putting
>them all in the drawSelf:: of the main view, but that makes the whole
>view flash.  Current idea is to define a Type 3 font with my bitmaps,
>then use xyshow to draw them.  This seems really gross.  If I wanted
>to do graphics with fonts, I'd program (pick one: X, TI99/4a, IBM PCs)
>etc.  Does anyone have a better method?  Ideas welcome, example code 
>even better.

turning flushWindow off before drawing will hide the flashing, but
compositing may be too slow...  Fonts are really fast though.


andrew
-- 
andrew@cubetech.com     | "We shall not cease from exploration
Andrew Loewenstern      |  And the end of our exploring
Cube Technologies, Inc. |  Will be to arrive where we started
                        |  And know the place for the first time." -T.S. Eliot
Re: Animating lots of small bitmaps
#1162
Author: Sam Streeper
Date: Thu, 13 Aug 1992 01:20
49 lines
2470 bytes
In article <22171@venera.isi.edu> dstrout@isi.edu (David Strout) writes:
> I need to animate many (up to 40) small (48>x>20) bitmaps in a view
> under 3.0.  (Think what the X game netrek looks like)  

Use NXImages to store your sprites, and then lockFocus on the appropriate
View or NXImage to composite them in.  Also note whether your window
is retained or buffered; if it's buffered you may need to flush frequently
to prevent the dirty rect from getting too big; when this happens, flushing
will become slower than necessary.  If it's retained you may need to pull
some tricks so that the display doesn't flicker.

For an interesting experiment, run BoinkOut from the command line like this:

BoinkOut -NXShowAllWindows

This unsupported feature will show you what how the window server is cacheing
all the images an app uses, and can be very edifying.  In the case
of BoinkOut, I use a retained window and buffer everything myself in an
NXImage.  Once the buffer is fully constructed, I can output the changed
pieces of it without worrying about accumulating a large dirty rect.
(This probably won't make any sense until you program something like it)
You can get BoinkOut via ftp from (nova.cc.purdue.edu) or on the 3.0
NeXTSTEP release.

> I tried doing
> it with a subview per bitmap, but that flashed badly.

No doubt.  Not a good approach for fast animation.

> I tried putting
> them all in the drawSelf:: of the main view, but that makes the whole
> view flash.  

I recommend using your own optimized animation display methods that
draw as little as possible.

> Current idea is to define a Type 3 font with my bitmaps,
> then use xyshow to draw them.  This seems really gross.  If I wanted
> to do graphics with fonts, I'd program (pick one: X, TI99/4a, IBM PCs)

This is fast, but is a big pain, and you can only output 1 color at a time.
NXImage is much more appropriate.

-sam


--
Opinions are not those of my employer.  They're not even mine.  They're
probably wrong besides.  How did they get in here, anyway?
Summary: Animating lots of small bitmaps
#1124
Author: David Strout
Date: Thu, 13 Aug 1992 12:07
31 lines
1312 bytes
Well, I got several responses from people (Thank you one and all!).
For my particular problem(bad flicker when animating a bunch of
bitmaps, each in a subview, in a large main view), turns out the the 
flashing was due to the way I was erasing my bitmaps before
re-drawing.  
I was doing it like this:

- drawSelf:(NXRect *)rects :(int)rectCount 
{

	PSsetgray(0);
	NXRectFill(rects);

	[self moveBy: 7 :0];

	[ship composite:NX_SOVER toPoint:&bounds.origin]; 

	return self;
}

where ship is an NXImage.  When I replaced the PSsetgray and
NXRectFill calls with [backGround composite:NX_SOVER
toPoint:&bounds.origin] where backGround is an NXImage the same size
as ship, initialized to the background, the flicker went away.  Better
examples of this are in BackSpace, by Sam Streeper, and PacMan, by Don
Yacktman.

Thanks again for the helpful suggestions.

dave.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads