CodeBase - using sprite to display numbers

Return to the CodeBase listing

Category: 2D Effects

Version: 1.0

0
0

Information

Uploaded: 16th Nov 2003 09:24

Modified: 1st Jan 1970 01:00

Author:  CloseToPerfect

Summary

Have you ever wanted to display a nice mutlicolor score, well you can with a set of number images and this little function? It will convert a integer into a series of sprite images.

Full Description

Ok, very simple.<br /> <br /> preuse setup<br /> Use any size number images but load them in in order.<br /> number 0-9<br /> image 1000-1009<br /> <br /> <br /> usage<br /> x,y - upper left placement position on the screen<br /> Number - is the number to display<br /> SpriteNumber is the starting sprite number to use it will add sequchially to it as needed<br /> <br /> example<br /> Rem Project: sprite numbers<br /> Rem Created: 11/16/03 8:14:48 AM<br /> rem By: John Chase<br /> rem email: Jchase1970@hotmail.com<br /> rem find me on the Dark Basic forums or Blitz Basic forums as CloseToPerfect<br /> <br /> Rem ***** Main Source File *****<br /> <br /> load image &quot;0.bmp&quot;, 1000<br /> load image &quot;1.bmp&quot;, 1001<br /> load image &quot;2.bmp&quot;, 1002<br /> load image &quot;3.bmp&quot;, 1003<br /> load image &quot;4.bmp&quot;, 1004<br /> load image &quot;5.bmp&quot;, 1005<br /> load image &quot;6.bmp&quot;, 1006<br /> load image &quot;7.bmp&quot;, 1007<br /> load image &quot;8.bmp&quot;, 1008<br /> load image &quot;9.bmp&quot;, 1009<br /> <br /> for i = 1000 to 1010<br /> sprite i, -50, -50, 1000<br /> set sprite i, 0, 1<br /> next i<br /> <br /> do<br /> cls<br /> inc score, rnd(100)<br /> display_number(100, 100, score, 1000)<br /> wait 50<br /> loop<br /> <br /> Function display_number(x,y,Number,SpriteNumber)<br /> number$=str$(number)<br /> numberlenght=len(Number$)<br /> for i = 1 to numberlenght<br /> sprite SpriteNumber+i,x+(i*sprite width(SpriteNumber+i)),y,val(mid$(number$,i))+1000<br /> next i<br /> Endfunction<br />

Comments

No comments yet.