|
Post by gtoal on Jan 9, 2022 20:40:17 GMT -5
When I wrote a Sokoban game a few years back, it was annoying to me at the time that drawing the outline of abutting block shapes had to be done using single line segments, even if two lines were abutting and could have been drawn with a single vector. So although I don't have a use for it at the moment, I finally got around to writing some code that would join multiple lines together into a single vector before drawing them. The same code could apply to a tetris game or anything that is drawn on a grid, where adjoining shapes are merged. It's not super efficient - the demo shows about as much as can be drawn in a round (compiled with -O) , but maybe it'll serve as a starting point if anyone finds themselves wanting to do something similar. It uses two 32-byte bitmaps to record the presence or absence of a line segment in a 15x15 grid. Empty rows are skipped quite quickly. The grid is 16 vertical or horizontal lines or 15 spaces if you prefer. I share it here because getting the bit twiddling right was a little tricky and it might save someone some time to have some starter code. It's at gtoal.com/vectrex/bitmapgrid/main.cregards G
|
|