TGC Codebase Backup



Draw numbers Atari style v2 by Tanjo Galbi

24th Oct 2011 20:02
Summary

Upgraded more flexible version of MaPo's functions



Description

Upgraded more flexible version of MaPo's functions to draw Atari style numbers. This is just 1 function that does all the numbers 0 to 9. It provides more control by allowing the programmer to give the width and height of the digit.

Of course there is no error checking, it should check to make sure the number is valid in the range 0 to 9.

If wanted, I could easilly create a version that would display all the digits for a large number (multiple digits), like a score display where you just provide the score, where you want it placed and the size. It's retro and retro style games are on an increase again ;)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    set display mode 320,240,32
set text font "terminal",1
set text size 12

cls

ink rgb (142,142,142),0

for n=0 to 9
	drawNumber(n,10+n*25, 10, 15, 15)
next n

wait key

end

function drawNumber(num,left,top,width,height)
	cellWidth = width / 3
	cellHeight = height / 5
	dim cells(3,5)
	restore digitData
	for digit = 0 to num
		for y=0 to 4
			for x=0 to 2
				read cells(x,y)
			next x
		next y
	next digit
	for y=0 to 4
		for x=0 to 2
			if cells(x,y) then box left + x*cellWidth, top+y*cellHeight, left+(x+1)*cellWidth, top+(y+1)*cellHeight
		next x
	next y
endfunction

digitData:
data 1,1,1,1,0,1,1,0,1,1,0,1,1,1,1
data 0,1,0,0,1,0,0,1,0,0,1,0,0,1,0
data 1,1,1,0,0,1,1,1,1,1,0,0,1,1,1
data 1,1,1,0,0,1,1,1,1,0,0,1,1,1,1
data 1,0,1,1,0,1,1,1,1,0,0,1,0,0,1
data 1,1,1,1,0,0,1,1,1,0,0,1,1,1,1
data 1,0,0,1,0,0,1,1,1,1,0,1,1,1,1
data 1,1,1,0,0,1,0,0,1,0,0,1,0,0,1
data 1,1,1,1,0,1,1,1,1,1,0,1,1,1,1
data 1,1,1,1,0,1,1,1,1,0,0,1,0,0,1