1. palette animation experiments
Tonight I did my first experiments with palette animation. I sent it here
hoping that
people more artist than I am could do something good with. I'm not sure if
I'm right
to post my code examples like that to the list. But by reading the messages
I see that
there is beginners to programming that it could be helpfull to. For those
who know
better than me I hope it doesn`t bother you to much. I try to limit the
size any way.
Merry Chrismass to all.
P.S. I tried space invader of Peter Blue, I'm not strong on video game but
is coding
is interesting. Even if you're not a video game amateur, you should look at
it`s coding. His source code is as clean as usual.
Thanks to you Peter.
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com
2. palette animation experiments
--=====================_851168125==_
Whoops, forgot to attach pal_anim.ex
--=====================_851168125==_
-- some experiments in palette animation.
-- December 21th, 1996
include graphics.e
-- check library ref. and didn't find it.
function get_palette()
sequence Pal
object junk
Pal = repeat({0,0,0},64)
junk = Pal[1]
for i = 1 to 64 do
junk = palette(i-1,junk)
if atom(junk) then
all_palette(Pal[1..i-1])
return Pal[1..i-1]
else
Pal[i] = junk
end if
end for
all_palette(Pal) -- restore it.
return Pal
end function -- get_palette()
procedure delay(atom t)
atom s
s = time()
while time()-s < t do
end while
end procedure
-- draw a thick line ellipse
procedure ThickEllipse(integer color, -- color of ellipse
integer ThickNess, -- thickness of the line
sequence ul, -- up left corner
sequence dr -- down right corner
)
for i = 0 to ThickNess - 1 do
ellipse(color,0,{ul[1]+i,ul[2]+i},{dr[1]-i,dr[2]-i})
end for
end procedure
sequence SavePalette, RotatePal
object junk
junk = graphics_mode(256) -- 640X480, 256 colors
SavePalette = get_palette()
-- TEST 1 range scanning
-- affecting same palette to many entries and scanning a second color in
-- that range
sequence tmp,wave
RotatePal = SavePalette
RotatePal[4] = RotatePal[8]
junk = palette(3,RotatePal[8])
wave = RotatePal[16]
RotatePal[5] = RotatePal[8]
junk = palette(4,RotatePal[8])
tmp = RotatePal[8]
for i = 1 to length(SavePalette) do -- draw palette
polygon(i,1,{{10*i,0},{10+10*i,0},{10+10*i,10},{10*i,10}})
end for
position(3,1)
puts(1,"TEST 1: animation by range scanning.\n")
puts(1,"Press a key for next experiment.")
for i = 0 to 15 do
ThickEllipse(2+remainder(i,3),8,{319-8*i,239-8*i},{321+8*i,241+8*i})
end for
while get_key() = -1 do
for i = 3 to 5 do
junk = palette(i-1,wave)
delay(.2)
junk = palette(i-1,tmp)
end for
end while
-- TEST 2 rotating a range
-- rotating a range of entries in a loop
-- rotating colors 16 to 31 (gray scale)
-- twinning palette entries so that same colors can be fixed and animated at the
-- same time. ( windows 95 opening banner trick)
clear_screen()
position(2,1)
puts(1," fixed twin animated twin\n")
puts(1,"Animation by palette rotation.\n")
puts(1,"Press a key to end.")
RotatePal = SavePalette
RotatePal[1..16] = RotatePal[17..32]
all_palette(RotatePal)
for i = 0 to 15 do
polygon(i,1,{{10*i,0},{10+10*i,0},{10+10*i,10},{10*i,10}})--fixed colors bar
polygon(16+i,1,{{10*(16+i),0},{10+10*(16+i),0}, -- animated colors bar
{10+10*(16+i),10},{10*(16+i),10}})
ThickEllipse(16+i,8,{319-8*i,239-8*i},{321+8*i,241+8*i}) -- animated circles
end for
while get_key() = -1 do
for l = 1 to 16 do -- rotate one way thrue
tmp = RotatePal[17]
for i = 17 to 31 do
RotatePal[i] = RotatePal[i+1]
end for
RotatePal[32] = tmp
all_palette(RotatePal)
delay(.06)
end for
for l = 1 to 16 do -- rotate the other way thrue
tmp = RotatePal[32]
for i = 32 to 18 by -1 do
RotatePal[i] = RotatePal[i-1]
end for
RotatePal[17] = tmp
all_palette(RotatePal)
delay(.06)
end for
end while
---------------------
all_palette(SavePalette)
junk = graphics_mode(-1)
--=====================_851168125==_
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com
--=====================_851168125==_--