Log In  
Follow
Chronosv2

I'm a visually impaired gamer and aspiring game developer. I started out with QBasic, and have gradually grown to coding with Unity. I've been tinkering with PICO-8 for awhile and decided to start my game development journey over using it. Most of what I've learned is completely self-taught.


Hey there! I wrote a small library to make drawing numbers using sprites quick and easy using the output from string.format.
It can technically be used for non-integer values but any symbol that can't be drawn as a number will just be skipped over and a digit-wide space will be left. I wrote it this way so that you can draw a number with either leading zeroes or leading spaces.

There's also a version that allows you to have leading zeroes displayed as sprites too.

--sprite_num.lua
--[[
Description: Implements a function for drawing numbers out of sprites.
	Useful for non-text numbers, like scores for arcade games.
	Best used with numbers formatted with 'string.format'
Requirements:
	Number sprites need to be stored in contiguous order from 0-9 (0123456789)
Optional:
	A 'const' table containing the following:
	const.sprite_0 : Integer value holding the sprite ID of the 0 digit.
	const.number_width : Integer value holding the width of each number sprite.
	const.lz_sprite : Integer value holding the "Leading Zero" sprite for
		sprite_number_lz
	If the const table isn't used, this function call requires its optional arguments.
Usage: sprite_number(input,x,y,[sprite_0,sprite_w])

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=144069#p)
4
0 comments