Paint Animation

Miscellaneous Forums/General Discussion/Paint Animation

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here's some code I wrote earlier today for an RPG project. It might be of use to you. Basically its used to create an animated image from single frame image files.

Function CreateIconImage( width, height, num_icons, folderpath$ )
; Creates an image to add icons to.
; Use 'LoadIcon' to load the icons into this image.
; The image handle of the image will be returned.

	; Change to the specified folderpath that will be used by 'LoadIcon'.
	ChangeDir folderpath$
	
	; Create the image to add the icons to.
	Local image = CreateImage( width, height, num_icons )

	LoadIcon( image, frame, filename$ )
	
	Return image
End Function



Function LoadIcon( image, frame, filename$ )
; Loads an image file with the specified filename and adds it to the specified destination image (created using 'CreateIconImage') as the specified frame of that image.
; 'CreateIconImage' should have been called prior to this function to create the destination image and set the folderpath for the icons.

	Local icon = LoadImage( filename$ )
	If icon
		SetBuffer ImageBuffer( image, frame )
		DrawBlock icon, 0, 0
		FreeImage icon
	EndIf	
End Function

; EXAMPLE USAGE

; -- Load item icons.
Global G_num_item_icons = 6
Const C_ITEM_ICON_WIDTH = 32
Const C_ITEM_ICON_BUTTON_WIDTH = C_ITEM_ICON_WIDTH + 2
Global G_item_icon_image = CreateIconImage( C_ITEM_ICON_WIDTH, C_ITEM_ICON_WIDTH, G_num_item_icons, G_appdir$ + "MEDIA\ITEM ICONS" )
LoadIcon( G_item_icon_image, 0, "blank.png" )
LoadIcon( G_item_icon_image, 1, "Secret-icon.PNG" )
LoadIcon( G_item_icon_image, 2, "WoodContainer-icon.PNG" )
LoadIcon( G_item_icon_image, 3, "Skull-icon.PNG" )
LoadIcon( G_item_icon_image, 4, "Bblance-icon.PNG" )
LoadIcon( G_item_icon_image, 5, "Baraka-icon.PNG" )
;^^^^^^