Re: Help

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

------=_NextPart_000_003B_01C00398.C8E5F580
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Asif,

Here is an example which should help you.

Colin

-- start code

include mouse.e         --For mouse availibility, I tried, Phew!
include graphics.e      --For graphics mode 640x480 with 16 colors
clear_screen()          --Would be good
object kyo
kyo =3D graphics_mode(18)
position(7,29)          --For text position
puts(1, "Lets see how it works. ;)")
-- you were okay to here...
mouse_pointer(1)
-- now you have a working mouse pointer

-- if you want to know the mouse state...
object m_event
integer mx, my, lb, rb
mx =3D 0
my =3D 0
lb =3D 0
rb =3D 0
sequence state
state =3D {"no ", "yes"}

position(29, 31)       =20
puts(1, "press a key to exit...")

while 1 do
    m_event =3D get_mouse()
    if sequence(m_event) then
 mx =3D m_event[2]  -- mouse x coordinate
 my =3D m_event[3]  -- mouse y coordinate
 if and_bits(m_event[1], LEFT_DOWN) then  -- left button press
     lb =3D 1
 elsif and_bits(m_event[1], LEFT_UP) then  -- left button release
     lb =3D 0
 end if
 if and_bits(m_event[1], RIGHT_DOWN) then  -- right button press
     rb =3D 1
 elsif and_bits(m_event[1], RIGHT_UP) then  -- right button release
     rb =3D 0
 end if
 -- print out some info
 position(1, 1)
 mouse_pointer(0)  -- its best to turn off the pointer when printing
 printf(1, "mouse x pos =3D %d  \n", mx)
 printf(1, "mouse y pos =3D %d  \n", my)
 printf(1, "left button? %s  \n", {state[lb+1]})
 printf(1, "right button? %s  \n", {state[rb+1]})
 mouse_pointer(1)  -- back on
    end if
    if get_key() !=3D -1 then
 exit  -- if key press then exit from the while loop
    end if
end while

-- end code
  Asif wrote:
  >I tried making the mouse available in graphics_mode but i failed

------=_NextPart_000_003B_01C00398.C8E5F580
        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>Asif,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here is an example which should help=20
you.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Colin</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-- start code</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>include=20
mouse.e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --For mouse=20
availibility, I tried, Phew!<BR>include =
graphics.e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
--For graphics mode 640x480 with 16=20
nbsp;=20
--Would be good<BR>object kyo<BR>kyo =3D=20
bsp;&nbsp;&nbsp;=20
--For text position<BR>puts(1, "Lets see how it works. ;)")<BR>-- you =
were okay=20
to here...<BR>mouse_pointer(1)<BR>-- now you have a working mouse=20
pointer</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-- if you want to know the mouse =
state...<BR>object=20
m_event<BR>integer mx, my, lb, rb<BR>mx =3D 0<BR>my =3D 0<BR>lb =3D =
0<BR>rb =3D=20
0<BR>sequence state<BR>state =3D {"no ", "yes"}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>position(29,=20
31)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>puts(1, "press a key =
to=20
exit...")</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>while 1 do<BR>&nbsp;&nbsp;&nbsp; =
m_event =3D=20
get_mouse()<BR>&nbsp;&nbsp;&nbsp; if sequence(m_event) then<BR>&nbsp;mx =
=3D=20
m_event[2]&nbsp; -- mouse x coordinate<BR>&nbsp;my =3D m_event[3]&nbsp; =
-- mouse y=20
coordinate<BR>&nbsp;if and_bits(m_event[1], LEFT_DOWN) then&nbsp; -- =
left button=20
press<BR>&nbsp;&nbsp;&nbsp;&nbsp; lb =3D 1<BR>&nbsp;elsif =
and_bits(m_event[1],=20
LEFT_UP) then&nbsp; -- left button release<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
lb =3D=20
0<BR>&nbsp;end if<BR>&nbsp;if and_bits(m_event[1], RIGHT_DOWN) =
then&nbsp; --=20
right button press<BR>&nbsp;&nbsp;&nbsp;&nbsp; rb =3D 1<BR>&nbsp;elsif=20
and_bits(m_event[1], RIGHT_UP) then&nbsp; -- right button=20
release<BR>&nbsp;&nbsp;&nbsp;&nbsp; rb =3D 0<BR>&nbsp;end if<BR>&nbsp;-- =
print out=20
some info<BR>&nbsp;position(1, 1)<BR>&nbsp;mouse_pointer(0)&nbsp; -- its =
best to=20
turn off the pointer when printing<BR>&nbsp;printf(1, "mouse x pos =3D =
%d&nbsp;=20
\n", mx)<BR>&nbsp;printf(1, "mouse y pos =3D %d&nbsp; \n", =
my)<BR>&nbsp;printf(1,=20
"left button? %s&nbsp; \n", {state[lb+1]})<BR>&nbsp;printf(1, "right =
button?=20
%s&nbsp; \n", {state[rb+1]})<BR>&nbsp;mouse_pointer(1)&nbsp; -- back=20
on<BR>&nbsp;&nbsp;&nbsp; end if<BR>&nbsp;&nbsp;&nbsp; if get_key() !=3D =
-1=20
then<BR>&nbsp;exit&nbsp; -- if key press then exit from the while=20
loop<BR>&nbsp;&nbsp;&nbsp; end if<BR>end while<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>-- end code</DIV></FONT>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV><FONT face=3DArial size=3D2>
  <DIV><FONT face=3DArial size=3D2>
  <DIV style=3D"FONT: 10pt arial">Asif wrote:</DIV>
  <DIV><FONT face=3DArial size=3D2>&gt;I tried making the mouse =
available in=20
  graphics_mode but i=20

------=_NextPart_000_003B_01C00398.C8E5F580--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu