'palette_effect.bas
option explicit
#include "allegro.bi"
'Simple variable to draw the shape
dim i as integer
'Create a color object using Allegro's RGB struct
dim color_rgb as RGB
'Initialise Allegro routines
allegro_init
install_keyboard
'Set colour depth to 8-bit
set_color_depth 8
'Set graphics mode to 320x240 with error checking
if set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0) < 0 then
'If windowed fails, go win
if set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 320, 240, 0, 0) < 0 then
allegro_message "Unable to set any graphic mode" + chr(13) + allegro_error + chr(13)
end 1
end if
end if
'Set window title
set_window_title "Palette magic"
'Make the screen black
set_palette @black_palette
'Clear everything off the screen
clear_bitmap screen
for i = 160 to 0 step -1
circlefill screen, SCREEN_W / 2, SCREEN_H / 2, i, i / 10
next i
while key(KEY_ESC) = 0
'Randomly change the colors of the palette
for i = 16 to 0 step -1
color_rgb.r = int(rnd * 64)
color_rgb.g = int(rnd * 64)
color_rgb.b = int(rnd * 64)
'Wait for vertical retrace
vsync
'Assin the random color to i
set_color i, @color_rgb
next i
wend
'De-initialise allegro
remove_keyboard
allegro_exit
end 0
'palette_effect.bas
option explicit
#include "allegro.bi"
'Simple variable to draw the shape
dim i as integer
'Create a color object using Allegro's RGB struct
dim color_rgb as RGB
'Initialise Allegro routines
allegro_init
install_keyboard
'Set colour depth to 8-bit
set_color_depth 8
'Set graphics mode to 320x240 with error checking
if set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0) < 0 then
'If windowed fails, go fullscreen
if set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 320, 240, 0, 0) < 0 then
allegro_message "Unable to set any graphic mode" + chr(13) + allegro_error + chr(13)
end 1
end if
end if
'Set window title
set_window_title "Palette magic"
'Clear everything off the screen
clear_bitmap screen
for i = 160 to 0 step -1
circlefill screen, SCREEN_W / 2, SCREEN_H / 2, i, i / 10
next i
while key(KEY_ESC) = 0
'Randomly change the colors of the palette
for i = 16 to 0 step -1
color_rgb.r = int(rnd * 64)
color_rgb.g = int(rnd * 64)
color_rgb.b = int(rnd * 64)
'Wait for vertical retrace
vsync
'Assin the random color to i
set_color i, @color_rgb
next i
wend
'De-initialise allegro
remove_keyboard
allegro_exit
end 0