'FFFFF RRR OOO M M OOO EEEEE 'F R R O O MM MM O O E 'F R R O O M MM M O O EEE 'FFF RRR O O M M O O E 'F R R O O M M O O E 'F R R OOO M M OOO EEEEE ' 'TTTTT U U TTTTT OOO RRR ' T U U T O O R R ' T U U T O O R R ' T U U T O O RRR ' T U U T O O R R ' T UUU T OOO R R 'Game Programming Series: '---Palette 'What is the Palette? The Palette is a set of colors that you can 'use when printing text and graphics up on the screen. 'When you use COLOR 15 to print white text up on the screen, you 'are using a color of the palette (color 15, he he). 'What this tutorial is going to show you is how to manipulate the 'colors of the palette. For example, say you want the color 0 to 'be white instead of black (for some reason...) You can change the 'attributes of that color and make it white with a few qbasic 'commands, but that is slow and involves math.(And we all hate to 'use math). This tutorial will show you how to change the palette 'quickly and without the use of math! 'First we use screen 13 because it has 256 color attributes (0 - '255), is fast, and is compatible with the type of palette changing 'we are going to be using. 'What we will do is use OUT to tell the computer the new rgb color 'values for any specific attribute, using the following syntaxt: 'OUT &H3C8, attribute% 'OUT &HC39, red% 'OUT &HC39, green% 'OUT &HC39, blue% 'red%, green%, and blue% are values between 0 and 63, 63 being the 'most and 0 being the least of that color. If all the color values 'are 63, the resulting color is white, and if all the color values 'are 0, the resulting color is black. The following code would 'change color 0 to white: 'OUT &H3C8, 0 'OUT &HC39, 63 'OUT &HC39, 63 'OUT &HC39, 63 'You can also use INP to find out the rgb values for a certain 'attribute using the following syntaxt: 'OUT &H3C7, attribute% 'red% = INP(&HC39) 'green% = INP(&HC39) 'blue% = INP(&HC39) 'Knowing this, you can make a fader for a game by decrementing the 'values for each attribute. The following is an example: 'This is by no means an optimal fader, but it does get the job done SCREEN 13 DIM N AS INTEGER, Z AS INTEGER DIM R AS INTEGER, G AS INTEGER, B AS INTEGER DIM X AS INTEGER, Y AS INTEGER DIM T AS SINGLE 'First we will fill the screen with color! FOR N = 1 TO 200 X = INT(RND * 320) Y = INT(RND * 200) CIRCLE (X, Y), 10, N PAINT (X, Y), N NEXT 'Now we will fade the screen FOR Z = 0 TO 63 FOR N = 0 TO 255 OUT &H3C7, N R = INP(&H3C9) G = INP(&H3C9) B = INP(&H3C9) R = R - 1: G = G - 1: B = B - 1 'decrement all the values IF R < 0 THEN R = 0 IF G < 0 THEN G = 0 'keep values from going below zero IF B < 0 THEN B = 0 OUT &H3C8, N OUT &H3C9, R OUT &H3C9, G OUT &H3C9, B NEXT T = TIMER DO WHILE TIMER - T <= .0001 LOOP NEXT 'Now we will restore all of the colors PALETTE 'this command restores all of the colors to their defaults END