Archived

This topic is now archived and is closed to further replies.

Joppe

Rotation...

Recommended Posts

Anesthesia    122
Well, you shouldn''t have to rotate when you''re building your shapes. Most people make a primitive of a single block and then build up the shapes for it in code. That way, you don''t have to rotate anything, just blit the blocks at different locations.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Use a 3D API such as OpenGL or Direct3d. Make your sprites texture mapped quads. It''s a great way to get started with 3d programming and lot more fun than rotating a bitmaps pixels. :o)

Share this post


Link to post
Share on other sites
Anozireth    122
I recently wrote a tetris clone and found rotating the blocks to be the most challenging part. I ended up with obscure routines different for each shape, that can''t really be gotten into here. If you''d like, send me an email and I''ll be happy to give you the full code, but I really don''t think that my way is the best, or for that matter, even a good way to do it.

Share this post


Link to post
Share on other sites
Oluseyi    2103
Maintain a 4x4 grid in "object space" which indicates which particular cells are filled. The filled cells must be contiguous, have a length no greater that 4 and define the tetrii.

Example cell structure:
0 | 0 | 0 | 0
1 | 1 | 1 | 1
0 | 0 | 0 | 0
0 | 0 | 0 | 0

The above is the familiar 4-in-a-line tetris.

You can then write two simple routines to rotate left and right (since all rotations are by 90 degrees). Presto.

On the other hand, using 3D APIs gives you a lot more possibilities and flexibility in terms of graphical effects and pizzazz. But I suppose this is more of a learning effort anyway...

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites