numbers(which number, number Type, number X, number Y, number value)

From pinHeck Wiki
Jump to: navigation, search

Places a number on the screen, usually on a video. This can be used as a progress indicator, number of X needed, points scored for a mode, etc.

Numbers and progress bars are considered "graphics". You can have up to (8) graphic objects active at the same time.

Example to put 2 different numbers on same screen:

numbers(0, 1, 0, 0, 42); //Put a large "42" in upper left corner

numbers(7, 2, 64, 16, 65535); //Put a small "65535" in center


Valid X and Y positions:

X 0-127 : Left margin of number, going to the right

X 128  : Automatically places number justified to right edge of display.

X 255  : Automatically centers number

Y 0-31  : Top edge of number. Smallest numbers are 5 pixels high so 26 is highest value you should use here.


numberType Parameter

The second parameter, numberType, is important. Like video attribute, you set individual bits to control what your number does. These bits are pre-defined in the pins.h file to make them easier to use. The 4 leftmost bits set the number's function as follows:

- Define - - Bit - - Function

numberScore B01000000 Automatically insert this number as player's score

numberFlash B00100000 The number will flash

numberStay B00010000 The number will stay active even when video ends (good for timers)

returnPixels B00100000 Graphic object returns collision data (used for video modes)


numberScore

Let's say you have a pop bumper animation, but also want the player's score to be shown in your custom display.

video('B', '0', 'Z', allowSmall, 0, 255); //A video that allows small numbers

numbers(0, numberScore | 2, 0, 0, player); //Show current player's score.

In my game "player" is a variable of which player is active. Let's say it's player=3. In the above example, we're saying Graphic #0 is a number based off Player 3's score, using small numbers (the 2 OR'd with numberscore)

You can add up to 8 objects, so to show a video with player's score, # of pops, and a progress bar:

video('B', '0', 'Z', allowSmall | allowBar, 0, 255);

numbers(0, numberScore | 2, 0, 0, player);

showProgressBar(1, 15, 0, 26, fortProgress[player] * 4, 4);

numbers(2, numberFlash | 2, 64, 0, pops);

I also use numberScore in my Match animation, it displays all 4 player scores on the screen. You could use this to build a custom Score display if you don't want to use the default.


numberFlash

Pretty simple, set this flag and a number will flash on and off every other frame. This is a good example of how tied into video everything is - there must be a video playing for the number flashing to work. See example above for this in action.


numberStay

When a video starts or ends it terminates any active numbers UNLESS that number has the numberStay bit set. This make the number a "timer" number since that's usually what it's for. The only way to terminate a timer number that has this bit set is to call killTimer(which Object)


returnPixels

Returns value of pixels that were written over when drawing a character (sprite) to the screen.



Number Type

Those pre-defined bits represent the leftmost bits of the numberType parameter. The lower 4 bits set what the number actually looks like:

0 = Numbers off. Used to "kill" a number by other functions

1 = Large number at X Y position.

2 = Small number at X Y position.

3 = The same small number on upper left and right corners (XY ignored) - Good for timers!

4 = The same small number on lower left and right corners (XY ignored) - Good for timers!

5 = The same small number in all four corners. - Good for timers!

6 = A small single number with double 0's if zero (good for scores)

7 = Flag that makes this number show up after a video ends.

8 = Show all 4 scores on right hand side of screen for match animation (last 2 digits will blink for match)


Example:

numbers(0, numberStay | 5, 0, 0, 99);


The number 99 will appear in all four corners, and stay there until you call killTimer(0). You would call this function every second and decrement the number to create a timer.

Note: numberStay numbers are the only type that will be shown on the default score display. If such a number is active, only the current player's score will be shown (as opposed to all players) Ball # will move, and the corners will be kept clear for the timer number.

killTimer(x) is usually called when a timed event is complete or a mode fails.