1. Vertical Problems

------=_NextPart_000_0007_01C0231D.E9897F60
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I've drawn a -smirk- tank at the bottom of the screen and I;m trying to =
get the turret to move. The down (d) movement works but the  up (u) =
movement does not stop. What am I doing wrong? Also, is there a way to =
stop the line from "growing" and simply have it's angle change? Thanks.

include graphics.e
include get.e
integer gmode,desc
gmode=3Dgraphics_mode(19)

atom lengthh,reach,uright,lleft
lengthh=3D20
reach=3D30
uright=3D185
lleft=3D185

draw_line(1,{{lengthh,uright},{reach,lleft}})

desc=3Dwait_key()
while 1 do
    if desc=3D'u' then
        draw_line(0,{{lengthh,uright},{reach,lleft}})
        lleft-=3D100
        draw_line(2,{{lengthh,uright},{reach,lleft}})
        if lleft>185 then
            lleft+=3D1
        draw_line(15,{{lengthh,uright},{reach,lleft}})
        end if
        desc=3Dwait_key()
        elsif desc=3D'd' then
            draw_line(0,{{lengthh,uright},{reach,lleft}})
            lleft+=3D1
            draw_line(1,{{lengthh,uright},{reach,lleft}})
            if lleft>195 then
                lleft-=3D1
                draw_line(5,{{lengthh,uright},{reach,lleft}})
            end if
                desc=3Dwait_key()
                elsif desc=3D'f' then
                abort(1)
    end if
end while



-tank you      =20
-Thomas

P.S.=20

Through the magical process of me messing up I deleted an e-mail in =
reference to the Mr/Mrs thing and someone responded, and it was very =
funny . --> thanks.

------=_NextPart_000_0007_01C0231D.E9897F60
        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.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I've drawn a -smirk- tank at the bottom =
of the=20
screen and I;m trying to get the turret to move. The down (d) movement =
works but=20
the&nbsp; up (u) movement does not stop. What am I doing wrong? Also, is =
there a=20
way to stop the line from "growing" and simply have it's angle change?=20
Thanks.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>include graphics.e<BR>include =
get.e<BR>integer=20
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>atom=20
BR>lleft=3D185</FONT></DIV>
<DIV><FONT face=3DArial=20
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>desc=3Dwait_key()<BR>while 1 =
do<BR>&nbsp;&nbsp;&nbsp;=20
if desc=3D'u' then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;=20
if lleft&gt;185=20
;=20
lleft+=3D1</FONT></DIV>
<DIV><FONT face=3DArial =
;&nbsp;&nbsp;&nbsp;=20
end if<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
desc=3Dwait_key()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif =
desc=3D'd'=20
;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
if lleft&gt;195=20
;&nbsp;&nbsp;&nbsp;&nbsp;=20
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
end=20
nbsp;&nbsp;&nbsp;&nbsp;=20
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
elsif desc=3D'f'=20
;&nbsp;&nbsp;&nbsp;&nbsp;=20
abort(1)<BR>&nbsp;&nbsp;&nbsp; end if<BR>end while<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-tank =
you&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>-Thomas</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>P.S. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Through the magical process of me =
messing up I=20
deleted an e-mail in reference to the Mr/Mrs thing and someone=20
responded,&nbsp;and it was very funny . --&gt;=20

------=_NextPart_000_0007_01C0231D.E9897F60--

new topic     » topic index » view message » categorize

2. Re: Vertical Problems

On Wed, 20 Sep 2000 16:14:54 -0700, Paul Kerslake wrote:

>I've drawn a -smirk- tank at the bottom of the screen and I;m trying to
>get the turret to move. The down (d) movement works but the  up (u)
>movement does not stop. What am I doing wrong? Also, is there a way to
>stop the line from "growing" and simply have it's angle change? Thanks.

The answer to your first question is: check your logic.  (you had a '>'
where you should have had a '<')  but to simplify somewhat, I'd do
something like this:

include graphics.e
include get.e
integer gmode,desc
gmode=graphics_mode(19)

atom lengthh,reach,uright,lleft
  lengthh = 20
  reach   = 30
  uright  = 185
  lleft   = 185

draw_line(1,{{lengthh,uright},{reach,lleft}})

while 1 do
    desc=wait_key()
    if desc='u' then
      if lleft > 175 then
        draw_line(0,{{lengthh,uright},{reach,lleft}})
        lleft -= 1
        draw_line(1,{{lengthh,uright},{reach,lleft}})
      end if
    elsif desc='d' then
      if lleft < 195 then
        draw_line(0,{{lengthh,uright},{reach,lleft}})
        lleft+=1
        draw_line(1,{{lengthh,uright},{reach,lleft}})
      end if
    elsif desc='q' then
        gmode = graphics_mode(-1)
        abort(1)
    end if
end while
-------------------------------------------------------------------

To answer your second question, I'd do something like this:

include graphics.e
include get.e
include misc.e

integer gmode,desc
gmode=graphics_mode(19)

integer angle, radius
  angle = 0
  radius = 10
sequence origin
  origin = { 20, 185 }

function deg2rad( integer angle_deg )
  return angle_deg * PI / 180
end function

procedure draw_turret( integer color, integer angl )
  sequence pt2
  atom rad

  rad = deg2rad( 90 + angl )

  pt2 = { origin[1] + radius*sin( rad ), origin[2] + radius*cos( rad ) }
  draw_line( color, {origin, pt2} )
end procedure

draw_turret( 1, 0 )

while 1 do
    desc=wait_key()
    if desc='d' then
      if angle > -45 then
        draw_turret( 0, angle )
        angle -= 5
        draw_turret( 1, angle )
      end if
    elsif desc='u' then
      if angle < 45 then
        draw_turret( 0, angle )
        angle += 5
        draw_turret( 1, angle )
      end if
    elsif desc='q' then
        gmode = graphics_mode(-1)
        abort(1)
    end if
end while
-----------------------------------------------------------

Good Luck!
 Brian

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

Search



Quick Links

User menu

Not signed in.

Misc Menu