new topic     » goto parent     » topic index » view thread      » older message » newer message

------=_NextPart_000_004F_01BFCE5A.8F868700
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm a beginner and this is my first program. Anybody want to pick at it =
and help me do better? I also want to use the EX02.EXW example in Dave's =
Winlib to port this code in to so it'll run in winders[8*9 As of yet I =
don't know how. I'm also interested in using sprite graphics for dice.

            -- Dice version 3 by
            -- Joe Schwenk jschwenk at hsonline.net
            -- Alvin Koffman ka9qlq at hotmail.com
                  -- with trace
                  -- trace(1)

   include graphics.e -- include graphics
   include get.e      -- include keyboard imput

   integer d1, d2, t, z, y, k  -- declair some integers

   procedure winner()  -- CALL FOR WINNER
    text_color(10)     -- change text color
    puts (1, "\n\t*****WINNER!!*****\n\t*****WINNER!!*****") -- display =
winner
    y =3D 0          -- set loop to off
    text_color (7) -- Set color back to normal
    puts (1, "\n")

    end procedure

   procedure throw_dice() -- call this to throw dice

    d1 =3D rand (6)         -- throw dice
    d2 =3D rand (6)
    t =3D d1 + d2           -- total dice
    text_color (12)       -- change text color
    puts (1, "\nDice 1 is: ") -- display results
    print (1, d1)
    puts (1, "\tDice 2 is: ")
    print (1, d2)
    puts (1, "\tDice total is: ")
    print (1, t)

    end procedure

   procedure looser()  -- call for looser
    text_color (14)     -- change text color
    if                 -- is it snake eyes?
     t =3D 2
      then
       puts (1, "\n\t*****SNAKE EYES TURKEY!!*****\n\t*****SNAKE EYES =
TURKEY!!*****")
      else
    text_color (5)
       puts (1, "\n\t*****YAH BIG LOOSER!!*****\n\t*****YAH BIG =
LOOSER!!*****")
    end if
    y =3D 0              -- set loop to off
    text_color (7)     -- Set color back to normal
    puts (1, "\n")

   end procedure

   procedure other_throws() -- keep trowing the dice

   while                  -- multipel throw loop
    y > 0
     do

    throw_dice()          -- next throw

    if                    -- check total for loose
     t =3D 2
      then
       looser()
    end if

    if t =3D z  -- check total for winner
     then
       winner()
    end if

    if            -- check total for loose
     t =3D 7
      then
       looser()
    end if

    if            --check total for loose
     t =3D 11
      then
       looser()
    end if

   end while      -- end multipel throw loop
   end procedure  -- end next throw

   procedure game()-- start game
   throw_dice()

    z =3D t         -- keep to compair first throw with others
    if            -- did you win?
     t =3D 7
      then
       winner()
    end if

    if            -- did you win?
     t =3D 11
      then
      winner()
    end if

    if            -- did you loose?
     t =3D 2
      then
       looser()
    end if

   other_throws() -- no 7 or 11? throw on

   end procedure

   =
----------------------------------------------------------------------
   -- start program.
   =
----------------------------------------------------------------------

   y =3D 1          -- set other_throw loop to on
   k =3D 121        -- set while play loop to on

   while          -- loop to check if you want to play
    k =3D 121       -- ASCII for y
     do
    puts (1, "Play?") -- ask question
    k =3D wait_key()    -- wait for answer
    if                -- if not "y" then end program
     k !=3D 121
      then            --set y to quit game
    y =3D 0
    else              -- if "y" then start a game
     y =3D 1            -- reset y and z for new game
     z =3D 0
       game()         -- start game
    end if
    end while         -- end check           =20
http://ka9qlq.tripod.com/

------=_NextPart_000_004F_01BFCE5A.8F868700
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3401" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#a8c8f0>
<DIV><FONT face=3DArial size=3D2>I'm a beginner and this is my first =
program.=20
Anybody want to pick at it and help me do better? I also want to use the =

EX02.EXW example in Dave's Winlib to port this code in to so it'll run =
in=20
winders[8*9 As of yet I don't know how. I'm also interested in using =
sprite=20
graphics for dice.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
p; --=20
Dice version 3=20
by<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
-- Joe=20
Schwenk <A=20
-- Alvin Koffman <A=20
nbsp;&nbsp;&nbsp;=20
-- with=20
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- trace(1)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; include graphics.e -- =
include=20
graphics<BR>&nbsp;&nbsp; include get.e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
include=20
keyboard imput</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; integer d1, d2, t, z, y, =
k&nbsp; --=20
declair some integers</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; procedure winner()&nbsp; =
-- CALL FOR=20
WINNER<BR>&nbsp;&nbsp;&nbsp; text_color(10)&nbsp;&nbsp;&nbsp;&nbsp; -- =
change=20
text color<BR>&nbsp;&nbsp;&nbsp; puts (1,=20
"\n\t*****WINNER!!*****\n\t*****WINNER!!*****") -- display=20
winner<BR>&nbsp;&nbsp;&nbsp; y =3D=20
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- set loop to=20
off<BR>&nbsp;&nbsp;&nbsp; text_color (7) -- Set color back to=20
normal<BR>&nbsp;&nbsp;&nbsp; puts (1, "\n")</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; end =
procedure</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; procedure throw_dice() -- =
call this to=20
throw dice</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; d1 =3D rand=20
(6)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- throw=20
dice<BR>&nbsp;&nbsp;&nbsp; d2 =3D rand (6)<BR>&nbsp;&nbsp;&nbsp; t =3D =
d1 +=20
d2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- total=20
dice<BR>&nbsp;&nbsp;&nbsp; text_color =
(12)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- change text color<BR>&nbsp;&nbsp;&nbsp; puts (1, "\nDice 1 is: ") -- =
display=20
results<BR>&nbsp;&nbsp;&nbsp; print (1, d1)<BR>&nbsp;&nbsp;&nbsp; puts =
(1,=20
"\tDice 2 is: ")<BR>&nbsp;&nbsp;&nbsp; print (1, =
d2)<BR>&nbsp;&nbsp;&nbsp; puts=20
(1, "\tDice total is: ")<BR>&nbsp;&nbsp;&nbsp; print (1, t)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; end =
procedure</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; procedure looser()&nbsp; =
-- call for=20
looser<BR>&nbsp;&nbsp;&nbsp; text_color (14)&nbsp;&nbsp;&nbsp;&nbsp; -- =
change=20
text color<BR>&nbsp;&nbsp;&nbsp;=20
;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- is it snake eyes?<BR>&nbsp;&nbsp;&nbsp;&nbsp; t =3D=20
2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
puts (1, "\n\t*****SNAKE EYES TURKEY!!*****\n\t*****SNAKE EYES=20
TURKEY!!*****")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
else<BR>&nbsp;&nbsp;&nbsp;=20
text_color (5)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts (1, =
"\n\t*****YAH=20
BIG LOOSER!!*****\n\t*****YAH BIG LOOSER!!*****")<BR>&nbsp;&nbsp;&nbsp; =
end=20
if<BR>&nbsp;&nbsp;&nbsp; y =3D=20
&nbsp;=20
-- set loop to off<BR>&nbsp;&nbsp;&nbsp; text_color =
(7)&nbsp;&nbsp;&nbsp;&nbsp;=20
-- Set color back to normal<BR>&nbsp;&nbsp;&nbsp; puts (1, =
"\n")</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; end procedure</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; procedure other_throws() =
-- keep=20
trowing the dice</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;=20
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- multipel throw loop<BR>&nbsp;&nbsp;&nbsp; y &gt;=20
0<BR>&nbsp;&nbsp;&nbsp;&nbsp; do</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
throw_dice()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
next=20
throw</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
-- check total for loose<BR>&nbsp;&nbsp;&nbsp;&nbsp; t =3D=20
2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
looser()<BR>&nbsp;&nbsp;&nbsp; end if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; if t =3D z&nbsp; -- =
check total=20
for winner<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
winner()<BR>&nbsp;&nbsp;&nbsp; end=20
if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
check=20
total for loose<BR>&nbsp;&nbsp;&nbsp;&nbsp; t =3D=20
7<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
looser()<BR>&nbsp;&nbsp;&nbsp; end if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
--check=20
total for loose<BR>&nbsp;&nbsp;&nbsp;&nbsp; t =3D=20
11<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
looser()<BR>&nbsp;&nbsp;&nbsp; end=20
if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; end=20
while&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- end multipel throw =
loop<BR>&nbsp;&nbsp;=20
end procedure&nbsp; -- end next throw</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; procedure game()-- start=20
game<BR>&nbsp;&nbsp; throw_dice()</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; z =3D=20
t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- keep to compair =
first throw=20
with others<BR>&nbsp;&nbsp;&nbsp;=20
if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
did you=20
win?<BR>&nbsp;&nbsp;&nbsp;&nbsp; t =3D =
7<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
winner()<BR>&nbsp;&nbsp;&nbsp; end=20
if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
did you=20
win?<BR>&nbsp;&nbsp;&nbsp;&nbsp; t =3D =
11<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; winner()<BR>&nbsp;&nbsp;&nbsp; =
end=20
if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
did you=20
loose?<BR>&nbsp;&nbsp;&nbsp;&nbsp; t =3D =
2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
looser()<BR>&nbsp;&nbsp;&nbsp; end=20
if</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; other_throws() -- no 7 or =
11? throw=20
on</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; end procedure</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;=20
----------------------------------------------------------------------<BR=
>&nbsp;&nbsp;=20
-- start program.<BR>&nbsp;&nbsp;=20
----------------------------------------------------------------------</F=
ONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; y =3D=20
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- set =
other_throw loop=20
to on<BR>&nbsp;&nbsp; k =3D =
121&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- set=20
while play loop to on</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;=20
while&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- loop to =
check if=20
you want to play<BR>&nbsp;&nbsp;&nbsp; k =3D=20
121&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- ASCII for=20
y<BR>&nbsp;&nbsp;&nbsp;&nbsp; do<BR>&nbsp;&nbsp;&nbsp; puts (1, "Play?") =
-- ask=20
question<BR>&nbsp;&nbsp;&nbsp; k =3D wait_key()&nbsp;&nbsp;&nbsp; -- =
wait for=20
answer<BR>&nbsp;&nbsp;&nbsp;=20
;&nbsp;&nbsp;&nbsp;=20
-- if not "y" then end program<BR>&nbsp;&nbsp;&nbsp;&nbsp; k !=3D=20
121<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
--set y=20
to quit game<BR>&nbsp;&nbsp;&nbsp; y =3D 0<BR>&nbsp;&nbsp;&nbsp;=20
sp;&nbsp;=20
-- if "y" then start a game<BR>&nbsp;&nbsp;&nbsp;&nbsp; y =3D=20
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- =
reset y=20
and z for new game<BR>&nbsp;&nbsp;&nbsp;&nbsp; z =3D=20
0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
game()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- start=20
game<BR>&nbsp;&nbsp;&nbsp; end if<BR>&nbsp;&nbsp;&nbsp; end=20
while&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- end=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20

------=_NextPart_000_004F_01BFCE5A.8F868700--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu