1. bloodrain

Hi guys,

Earlier today I came across a nice effect on one of the pascal pages.
Some of you might already be tired of structures and Rob's stubborn silence,
and even enjoy a bit of change... You will need Jacques' ports.e to run this
baby,  but it should be in your include directory anyway. Press Esc to exit,
any other key to cycle through the six colors I thoughtfully selected for
you. Enjoy. jiri

--  file   : rain.ex
--  author : jiri babor
--  date   : 99-02-09
--  email  : jbabor at paradise.net.nz
--  theme  : color rain (bloodrain by Nemesis)

without warning
without type_check

include graphics.e
include ports.e         --  by Jacques Deschenes

constant
    A = #A0000,         -- video memory
    dt = 0.005          -- 200 frames per second
object junk
sequence p,pal
atom n,t,t1,t2
integer a,c,co,dc,key

procedure set_palettes(integer c, sequence s)
    -- set contiguous range of colors
    -- c is starting color index
    -- s is sequence of {r,g,b} palette entries
    -- rgb values 0..63
    Output(c,#3C8)
    for i=1 to length(s) do
        Output(s[i][1],#3C9)
        Output(s[i][2],#3C9)
        Output(s[i][3],#3C9)
    end for
end procedure

--
main ----------------------------------------------------------------------

p = repeat(repeat({0,0,0},128),6)   -- 6 different palettes
for i=1 to 128 do
    p[1][i][1] = floor((i-1)/2)
    p[2][i][2] = floor((i-1)/2)
    p[3][i][3] = floor((i-1)/2)
    p[4][i] = floor({(i-1)/3,(i-1)/3,0})
    p[5][i] = floor({(i-1)/3,0,(i-1)/3})
    p[6][i] = floor({0,(i-1)/3,(i-1)/3})
end for

junk = graphics_mode(19)
co=1
pal=p[co]
set_palettes(128,pal)
for x=0 to 319 do
    a = A+x
    c = 127+rand(128)
    dc = rand(3)
    for y=1 to 200 do
        poke(a,c)
        a += 320
        c += dc
        if c > 255 then c = 128 end if
    end for
end for

tick_rate(200)

n = 0
t = time()
t1 = t
t2 = t1+dt
while 1 do
    pal = prepend(pal[1..127],pal[128])
    set_palettes(128,pal)
    t1 = time()
    while t1 < t2 do t1 = time() end while
    t2 = t1+dt
    n += 1
    key = get_key()
    if key != -1 then
        if key = 27 then exit
        else
            co += 1
            if co > 6 then  co = 1 end if
            pal=p[co]
        end if
    end if
end while
t = time()-t

junk = graphics_mode(-1)
printf(1,"%5.2f fps\n",n/t)

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu