I have a serious problem about printing a number as a graphic element, i have developed a game using c++, oriented object programming, and when a player wins he receives a certain points, so I want to transform these points in a sequence of a graphic digits.
For example:
Firstly the player has 0 points. He wins the level 1 and gets 100 points so I want to display 4 digits like this:
- Firtly: 0000
- Wins: 100 points to 0100
The game works with integers, What I did was: create a Graphic Array that contains all the graphic numbers from 0 to 9.
gGraphic digits[10];
gGraphic is a class that creates and draws an object.., hence digits[0]
is a graphic element that represents 0, digits[1]
represents 1, digits[2]
represents 2...successively.. for example if I want to draw number 1, like 0001, this is what I do:
digits[0].draw(Xposition, Yposition);
digits[0].draw(Xposition + digits[0].ObtainScaleX(), Yposition);
digits[0].draw(Xposition + digits[0].ObtainScaleX()*2, Yposition);
digits[1].draw(Xposition + digits[0].ObtainScaleX()*3, Yposition);
As you can see I don't change the position Y, but I change the position X so I can get the sequence of digits represented at the X axis, the function ObtainScaleX() returns the width scale of an Object.
The problem is how can I do this for 1000 points, 1234 points or 3409???, the are thousands of possibilities and an if statement or switch case won't work, I really need an explanation, a basic idea, do I have to use pointers?