'=========================================================================== ' Subject: SCALE SPRITE Date: 03-18-96 (13:23) ' Author: Eric Carr Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: GRAPHICS.ABC '=========================================================================== 'Ok..Here is a routine (I just made it so...) that scales a sprite on the 'screen. It can scale to ANY size, and it only uses Integers, not floating 'point math, so it runs really smooth on my 486sx when it's compiled..Feel free 'to use or modify this for your own programs, but just give me a little credit 'for it if it's used in a game or somthing.. 'The sprite in here is a 64x64 block of colors..You would have to load in your 'own sprite from the Harddrive and make sure SP is DIMed the correct amount. 'The sprite data is stored in horizontal runs (X) from up to down.. 'For example, a 4x4 sprite would be 16 #'s long - 'sprite> 0/\0 ' //\\ _ ' //\\ _ 0/\0//\\//\\0||0 Except it would be in numbers, ' 0||0 not characters. 'One last thing, this only scales sprite bigger than the original. I haven't 'perfected scaling a sprite smaller yet.. Thats why it starts scaling at the 'orignal size, not smaller. DEFINT A-Z: SCREEN 13: DEF SEG = &HA000: DIM SP(4096) 'Load your sprite into SP. The size is 64x64 but you can change it. FOR T = 1 TO 4096 C = C + 1: IF C > 64 THEN C = 1 SP(T) = C NEXT T 'End of sample sprite making SX = 64: SY = 64 ' Size of original sprite FOR SF = 64 TO 192 '(192 IS 64*3 - scaling to 3x) LX = SF: LY = SF ' LX and LY are the new Sprite sizes GOSUB SCAL.SPRT NEXT: SLEEP: END SCAL.SPRT: CT = 1: ERY = 0 FOR Y = 1 TO LY: ER = 0 FOR x = 1 TO LX: POKE 320 * Y + x, SP(CT) ER = ER + SX: IF ER > LX THEN ER = ER - LX: CT = CT + 1 NEXT x ERY = ERY + SY IF ERY > LY THEN ERY = ERY - LY: CT = CT + 1 ELSE CT = CT - (SX - 1) NEXT Y: RETURN