1. starfield demo

For those without a UUencoder/decoder, here it is in text. copy and paste
--*******************************************************************\
--File: Star.ex                                                      |
--Author: Vikas B. Patel, 1997                                       |
--Description: Starfield demo                                        |
--Comments: I saw some horizontal star scrollers, but not a 3-d one. |
--          This isn't as good as many others out there, but it works|
--          and it is flexible.  A Euphoria version of the Pascal    |
--          starfield written by Denthor.  Found in Denthor's VGA    |
--          Tutorial #13 (can be found at almost any graphics progra-|
--          mming site, or at the address below).                    |
--                                                                   |
--File downloaded from: The Programmers' Guild                       |
--http://www.geocities.com/SiliconValley/Way/7272/main.html          |
--*******************************************************************/

--bof

without type_check
without warning
include graphics.e

constant num=200 --max number of stars, there can be less on the screen but
no more
                 --does not work very well
constant speed=2 --higher=faster
constant message="EUPHORIA!"
constant X=1
constant Y=2
constant Z=3
integer XX,YY
XX=320
YY=240

sequence star,pos, stars,clear --info on star; it's x,y pos;
star=repeat(0,3)
pos=repeat(0,2)
stars=repeat(repeat(0,3),num)
clear=repeat(repeat(repeat(0,2),num),2)


procedure init()
  for loop1=1 to num do
      stars[loop1][X]=rand(640)-320
      stars[loop1][Y]=rand(480)-240
      stars[loop1][3]=loop1
  end for
end procedure

procedure calc()
integer x,y
  for loop1=1 to num do
    x=floor(((stars[loop1][X])/stars[loop1][3])+XX)
    y=floor(((stars[loop1][Y])/stars[loop1][3])+YY)
    clear[1][loop1][X]=x
    clear[1][loop1][Y]=y
  end for
end procedure

procedure drawstars()
integer x,y
  for loop1=1 to num do
    x=clear[1][loop1][X]
    y=clear[1][loop1][Y]
    if (x>20) and (x<640) and (y>20) and (y<480) then
     if stars[loop1][Z]>15 then
          --pixel(19,{x,y})
      else pixel(BRIGHT_WHITE,{x,y}) pixel(BRIGHT_WHITE,{x+1,y}) end if
    end if
  end for
end procedure

procedure clearstars()
integer x,y
  for loop1=1 to num do
    x=clear[2][loop1][X]
    y=clear[2][loop1][Y]
    if (x>20) and (x<640) and (y>20) and (y<480) then
      pixel(BLACK,{x,y}) pixel(BLACK,{x+1,y}) end if
  end for
end procedure

procedure movestars(integer towards)
  if towards then
    for loop1=1 to num do
      stars[loop1][Z]=stars[loop1][Z]-speed
      if stars[loop1][Z]<1 then stars[loop1][Z]=stars[loop1][Z]+num end if
    end for
    else
    for loop1=1 to num do
      stars[loop1][Z]=stars[loop1][Z]+speed
      if stars[loop1][Z]>num then stars[loop1][Z]=stars[loop1][Z]-num end if
    end for
  end if
end procedure

procedure main()
integer key
 key=get_key()
  calc()
  drawstars()
  while key !=27 do
      key=get_key()
      position(1,1)
      puts(1,message)
    clear[2]=clear[1]
    calc()
    clearstars()
    drawstars()
  if key='A' or key='a' then
    movestars(1)
  end if
  if key='z' or key='Z' then
    movestars(0)
  end if
  if key=331 then
    XX=XX-3
  end if
  if key=333 then
    XX=XX+3
  end if
  if key=328 then
    YY=YY-3
  end if
  if key=336 then
    YY=YY+3
  end if
  end while
end procedure

if graphics_mode(18) then end if
init()
main()
if graphics_mode(-1) then end if
--eof
*******************************************************************
\*The Programmers' Guild:For the Amatuer and Hardcore Programmers*/
\\*  http://www.geocities.com/SiliconValley/Way/7272/main.html  *//
\\\*OM            http://home.onestop.net/tpg                OM*///
\\\\*OM         |Maintained by Vikas B. Patel|              OM*////
\\\\\*OM               Mera Bharat Mahaan                  OM*/////
*******************************************************************

new topic     » topic index » view message » categorize

2. Re: starfield demo

> For those without a UUencoder/decoder, here it is in text. copy and paste
<etc.....>

Thanks for sharing your code with us Vicas, but it would be better if
you just post it just once (please note i'm not angry).

I suggest we make a deal in the listserver (for all of us):

1.- Any Euphoria code smaller than 2-3K is posted as ASCII text.
2.- Any Euphoria source code larger than 3K is posted as MIME64
encoded ZIP file attachement. This should be also done for any other
kind of binary data. MIME64 encoding should be preffered over
Uuencode or BinHex.

Regards,
  Daniel Berstein
  danielberstein at usa.net
  http://www.geocities.com/SiliconValley/Heights/9316

new topic     » goto parent     » topic index » view message » categorize

3. Re: starfield demo

On Wed, 13 Aug 1997 00:29:04 +0000 Daniel Berstein
<danielberstein at usa.net> writes:
>
>> For those without a UUencoder/decoder, here it is in text. copy and
>paste
><etc.....>
>
>Thanks for sharing your code with us Vicas, but it would be better if
>you just post it just once (please note i'm not angry).

Agreed here.

>I suggest we make a deal in the listserver (for all of us):
>
>1.- Any Euphoria code smaller than 2-3K is posted as ASCII text.

This doesn't work all that well.
If the a comment or STRING passes the email
line length limit then the code will be corrupted.
PLUS all those dang equal signs and =3D things that
sometimes pop-up corrupt the code.

>2.- Any Euphoria source code larger than 3K is posted as MIME64
>encoded ZIP file attachement. This should be also done for any other
>kind of binary data. MIME64 encoding should be preffered over
>Uuencode or BinHex.

I can understand your MIME64 preference.
I have one problem with that. JUNO JUNO JUNO I have no choice
but send my files either "text" or "uuencoded".

>Regards,
>  Daniel Berstein
>  danielberstein at usa.net
>  http://www.geocities.com/SiliconValley/Heights/9316

        Sincerely, Lucius Lamar Hilley III

--  E-mail at luciuslhilleyiii at juno.com
--  JUNO JUNO JUNO.  I use JUNO and
--  I support transferring of files less than 60K.
--  I can Decode both UU and Base64 format.

new topic     » goto parent     » topic index » view message » categorize

4. Re: starfield demo

On Wed, 13 Aug 1997 00:29:04 +0000, Daniel Berstein wrote:

>I suggest we make a deal in the listserver (for all of us):
>
>1.- Any Euphoria code smaller than 2-3K is posted as ASCII text.
>2.- Any Euphoria source code larger than 3K is posted as MIME64
>encoded ZIP file attachement. This should be also done for any other
>kind of binary data. MIME64 encoding should be preffered over
>Uuencode or BinHex.
>
I prefer uuencoding, since my newsreader won't decode MIME64.  I have to
save the post in question, then run it through WinCode.

Regards,

Warren

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu