[comp.sys.amiga.programmer] Bobs, mouse tracking, and stuff

mpierce@ewu.UUCP (Mathew Pierce) (03/04/91)

I'm about to try my hand at games programming and need lots of
help.  I want to make a few board games and need to know how to 
handle game pieces.  I need to be able to grab the pieces with the 
mouse, move them around tha  play area, rotate them, then drop them
in place.  Now I've read up on bobs and sprites in the RKM's, so I 
have an idea of how to program them, but how about rotating them on 
screen?  

Say I have a triangle piece and want to rotata it in one of eight
directions, is there a command that will let me do that, or do I 
need to make an image of it in each direction and redisplay it at
each rotation?  Also, how do I get it to follow the mouse pointer
when I hit the left mouse button?  One last question - when the piece
gets rotated, do I have to figure out all the aspect ratios, or will
the bob commands do that for me?

Thanks alot,

Matt Pierce

ccplumb@rose.uwaterloo.ca (Colin Plumb) (03/07/91)

mpierce@ewu.UUCP (Mathew Pierce) wrote:
>I'm about to try my hand at games programming and need lots of
>help.  I want to make a few board games and need to know how to 
>handle game pieces.  I need to be able to grab the pieces with the 
>mouse, move them around tha  play area, rotate them, then drop them
>in place.  Now I've read up on bobs and sprites in the RKM's, so I 
>have an idea of how to program them, but how about rotating them on 
>screen?  

You can't.  You can cleverly program the blitter to do simple rotation
(example in the hardware manual under line drawing), and do tricks with
the modulo to flip something top-for-bottom, but rotation is generally
hard, and the best way is to store multiple bitmaps for the various
orientations.  If you have shadows or highlights, or your pieces are
otherwise not completely symmetrical, you want that, anyway.

>Say I have a triangle piece and want to rotata it in one of eight
>directions, is there a command that will let me do that, or do I 
>need to make an image of it in each direction and redisplay it at
>each rotation?  Also, how do I get it to follow the mouse pointer
>when I hit the left mouse button?  One last question - when the piece
>gets rotated, do I have to figure out all the aspect ratios, or will
>the bob commands do that for me?

See above.  There is no built-in bitmap rotation.  The aspect ratio isn't
exactly square, so 90 degree rotations don't look perfect, and automated 45
degree rotations don't look wonderful.

To track the mouse, talk to intuition to get MOUSEMOVE messages (usually
only when the button is held down - making the whole window a gadget is
one way to do that) and respond to them by moving/rotating/whatever the Bob.

To avoid drowning in MOUSEMOVE messages, every time though your move-bob
loop, suck the Intuition message port dry and move directly to the last
position specified.
-- 
	-Colin