[comp.windows.ms] Win3.0 Solitare

swonk@ccicpg.UUCP (Glen Swonk) (06/08/90)

Does anyone know how solitare is implemented?
Specifically how are the cards displayed and moved.

I assume that the cards are drawn from bitmaps, but
i thought that using bitmaps are very device dependant.

Also, any guess on how the "animation" of the cards is done?


thanks,

glenn
-- 
Glenn L. Swonk		CCI Computers 
(714)458-7282		9801 Muirlands Boulevard
			Irvine, CA 92718
uunet!ccicpg!swonk

michaelt@microsoft.UUCP (Michael THURLKILL) (06/14/90)

In article <75404@ccicpg.UUCP> swonk@ccicpg.UUCP (Glen Swonk) writes:
>Does anyone know how solitare is implemented?
>Specifically how are the cards displayed and moved.
>
>I assume that the cards are drawn from bitmaps, but
>i thought that using bitmaps are very device dependant.
>
One new feature of Win3 is Device Independant Bitmaps (DIB).
The display driver now knows how to convert a DIB into it's 
internal format, so if you save bitmaps in DIB format you can
display it with relatively good color rendition on any device.

>Also, any guess on how the "animation" of the cards is done?
>
>
I don't know how Solitare does it, but there are various 
techniques I've used in my personal projects. There are methods
using clip regions and/or memory DCs, which are a bit much to
go into right now. For simple animations like this, I've often
used the following:
You know that the object (card) is rectangular and is always
in front while moving, so you can do the following.
1. Bitblt the object to it's new location.
2. Calculate the difference between it's new area and it's old area.
3. Create a region that is the difference.
4. Call InvalidateRgn with the difference region.
5. The paint procedure redraws all the objects and the background, but
is clipped to the invalid region.

Depending on the speed of the machine and the size of the object,
this method may not be ideal, but it is simple and satisfactory for
many simple things.

Mike Thurlkill

Disclaimer: These are my opinions. They should in no way be 
misconstrued as being correct or in any way related to my employer.