1. trutwnkl.ex
- Posted by Hawke <mdeland at NWINFO.NET>
Nov 04, 1998
-
Last edited Nov 05, 1998
as per those that wanted truecolor demo's,
and to show that in a very short amount of time
that *many* programs out there written for other
graphic modes can quickly be converted to
truecolor modes now, with very little conversion
needed, i present TrueTwinkle, based upon MJSabal's
recent (today) post of twinkle.ex... ;) enjoy--Hawke'
-----------------CUT LINE---------------------------------
----------------- TruTwnkl.ex --------------
--TrueTwinkle:
--tweaked and adapted to truecolr by Hawke'
--originally Twinkle by M.J.Sabal
--------------------------------------------
----------------------------VAR's AND DECLARE's
-----------------------------------------------
include truecolr.e
constant MAXSTARS = 75
--TWINKLES should range from 1 to about 10 at most...IMO
--in reality, now, it's actually the "speed of fadeout"
--I like this value myself...
constant TWINKLES = 4
--this was the original map...
--constant STAR_IMAGE ={ {1,0,1},
-- {0,1,0},
-- {1,0,1} }
--this is the direct conversion map, substituting a BGR mix
--constant STAR_IMGMAP ={ {{1,1,1},{0,0,0},{1,1,1}},
-- {{0,0,0},{1,1,1},{0,0,0}},
-- {{1,1,1},{0,0,0},{1,1,1}} }
--this next map gives a really nice effect by color blending
--*each pixel* to it's neighbors, something you can't really
--do in other graphic modes... :)
constant STAR_IMGMAP ={ {{0,1,0},{1,1,1},{0,1,0}},
{{1,0,1},{0,1,0},{1,0,1}},
{{0,1,0},{1,1,1},{0,1,0}} }
--this is for speed sake, fast erase
constant CLEAR_IMGMAP={ {{0,0,0},{0,0,0},{0,0,0}},
{{0,0,0},{0,0,0},{0,0,0}},
{{0,0,0},{0,0,0},{0,0,0}} }
constant PINDX = 1, --Position Index
CINDX = 2 --Color Index
sequence vc, stars, current
atom delay
----------------------------------BEGIN FUNCTIONS
-------------------------------------------------
function MakeColor()
--easy on the green, it's "brighter" than red or blue
return { rand(250), rand(175), rand(250) }
end function
function MakeStar()
return { rand(SCR_MAX), MakeColor() }
end function
procedure ShowStar(sequence star)
display_true_image( star[PINDX], star[CINDX]*STAR_IMGMAP )
end procedure
procedure EraseStar(sequence star)
display_true_image( star[PINDX], CLEAR_IMGMAP )
end procedure
function FadeColor(sequence oldclr)
--rand({2,2,2}) - {1,1,1} is the same as choosing 0 or 1
--so we are subtracting either 0 or 1 from oldclr
oldclr = oldclr - ( rand({2,2,2}) - {1,1,1} )
return Max( oldclr, {50,50,50} )
end function
----------------------MAIN
InitDisplay()
--let the display "settle" from the mode switch
delay = time() + 0.7 --seconds
while time()<delay do
--some yawning, stretching, scratching... etc...
end while
--fill em up :)
stars = repeat(0,MAXSTARS)
for i = 1 to MAXSTARS do
stars[i] = MakeStar()
end for
--randomly dim them all a tad, so the first screen isn't a
--flash of a whole buncha really bright stars....
for i = 1 to MAXSTARS do
current = stars[i]
for j = 1 to rand(10) do
current[CINDX] = FadeColor(current[CINDX])
end for
stars[i] = current
end for
while get_key() < 1 do
for a = 1 to TWINKLES do
for b = 1 to MAXSTARS do
current = stars[b]
ShowStar(current) --show a star, then...
current[CINDX] = --fade that star, then...
FadeColor(current[CINDX])
stars[b] = current
end for
end for
EraseStar(stars[PINDX]) --erase 1st star, then...
stars = stars[2..MAXSTARS] --remove 1st star, and...
stars = append(stars, MakeStar()) --tag a new star on end
end while
GoodBye() --go back to text mode, end program
2. Re: trutwnkl.ex
On Wed, 4 Nov 1998, Hawke wrote:
> constant STAR_IMGMAP ={ {{0,1,0},{1,1,1},{0,1,0}},
> {{1,0,1},{0,1,0},{1,0,1}},
> {{0,1,0},{1,1,1},{0,1,0}} }
>
> --this is for speed sake, fast erase
> constant CLEAR_IMGMAP={ {{0,0,0},{0,0,0},{0,0,0}},
> {{0,0,0},{0,0,0},{0,0,0}},
> {{0,0,0},{0,0,0},{0,0,0}} }
>
Save yourself some typing:
constant
CLEAR_IMGMAP = STAR_IMGMAP * 0-- or * BLACK
These kinds of trick are what I like about the Euphoria. If you
don't use them you're programming in another language!
I'd've stuck with QBasic or CBM BASIC V2 on my trusty C64...
--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
URL......: http://www.bigfoot.com/~cyrek/
Ykk rnyllaqur rgiokc cea nyemdok ymc giququezka caysgr -- B.Q.Vgesa