Home Button News Button About & FAQ Button Members Button In.Dev Button Play Button Forum Button Resources Button Links Button Contact Button
Main Logo
Resources
 

ARTICLE ARTICLE
Written by BBaller BBaller
Posted on 12/Oct/2005
Version 1.1
Drawing Sprite Based Numbers

Version 1.1:  Fixed an error in the code.  The script should work correctly now.

I hope this is of some help to someone.  I'm sure that there are other ways to do it, but I picked up this method and I've used (and modified) it ever since.

The script draws a number on screen using a sprite with sub-images from 0 to 9 in that order.

To call the script, you would use a function in this manner (similar to drawing a sprite):

:
scr_draw_numb(spr_numb,x,y,score)


:

///////////////////////////////
// scr_draw_numb             //
// Draw #'s using a sprite   //
//                           //
// argument0: number sprite  //
// argument1: x position     //
// argument2: y position     //
// argument3: numb to draw   //
///////////////////////////////

// rounds number and turns it into a string
numb_str=string(ceil(argument3));

// records the width of the number sprite
my_width=sprite_get_width(argument0)-1;

// determines how many characters in number
numb_length=string_length(numb_str);

for (i=1;i<=numb_length;i+=1)

{

// determines the sub-image
img_numb=floor(real(string_copy(numb_str,i,1)));

// draws the sprite
draw_sprite(argument0,img_numb,argument1+(i-1)*my_width,argument2);

}

 

Eo Logo   Link to Us | Feeds
2004 - 2018 © Eo
Website by House of Ninzha & Simon Donkers