How do you rotate sprites placed with BGPUT?
Root / Programming Questions / [.]
ResetReloadCreated:
The example given won't work.
BGROT rotates the layer.Do you know how I can do this for a specific tile and not the entire layer?BGROT <layer>,<angle in degrees>
If you use BGROT you are rotating the entire layer, not just a single tile. If you use SPROT you are rotating a single sprite, but not a background tile.
However, if you are OK with only rotating at 90% increments you can do a bit of math to get that. You can vertically and horizontally flip a tile too. Bits 12 and 13 are for tile rotation, with those two bits you can rotate as follows: 0 = 0 degrees, 1, = 90 degrees, 2 = 180 degrees, and finally 3 = 270 degrees (or 00, 01, 10, 11 in binary)
Hopefully the following code can help.
OPTION STRICT VAR TILE% = 6 BGSCREEN 0, 20, 15 'ROTATE A BG TILE IN 90 DEGREE INCREMENTS BGPUT 0, 5, 5, TILE% '0 BGPUT 0, 8, 5, TILE% OR (1 << 12) '90 BGPUT 0, 11, 5, TILE% OR (2 << 12) '180 BGPUT 0, 14, 5, TILE% OR (3 << 12) '270 'HORIZONTAL AND VERTICAL FLIP TOO BGPUT 0, 5, 10, TILE% 'NORMAL BGPUT 0, 8, 10, TILE% OR (1 << 14) 'HORIZONTAL FLIP BGPUT 0, 11, 10, TILE% OR (1 << 15) 'VERTICAL FLIP BGPUT 0, 14, 10, TILE% OR (1 << 14) OR (1 << 15) 'HORIZONTAL AND VERTICAL FLIP