Re: Help
- Posted by Colin Taylor <ctaylor at RACSA.CO.CR> Aug 11, 2000
- 552 views
------=_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> </DIV> <DIV><FONT face=3DArial size=3D2>Here is an example which should help=20 you.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Colin</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- start code</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>include=20 mouse.e --For mouse=20 availibility, I tried, Phew!<BR>include = graphics.e =20 --For graphics mode 640x480 with 16=20 nbsp;=20 --Would be good<BR>object kyo<BR>kyo =3D=20 bsp; =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> </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> </DIV> <DIV><FONT face=3DArial size=3D2>position(29,=20 31) <BR>puts(1, "press a key = to=20 exit...")</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>while 1 do<BR> = m_event =3D=20 get_mouse()<BR> if sequence(m_event) then<BR> mx = =3D=20 m_event[2] -- mouse x coordinate<BR> my =3D m_event[3] = -- mouse y=20 coordinate<BR> if and_bits(m_event[1], LEFT_DOWN) then -- = left button=20 press<BR> lb =3D 1<BR> elsif = and_bits(m_event[1],=20 LEFT_UP) then -- left button release<BR> = lb =3D=20 0<BR> end if<BR> if and_bits(m_event[1], RIGHT_DOWN) = then --=20 right button press<BR> rb =3D 1<BR> elsif=20 and_bits(m_event[1], RIGHT_UP) then -- right button=20 release<BR> rb =3D 0<BR> end if<BR> -- = print out=20 some info<BR> position(1, 1)<BR> mouse_pointer(0) -- its = best to=20 turn off the pointer when printing<BR> printf(1, "mouse x pos =3D = %d =20 \n", mx)<BR> printf(1, "mouse y pos =3D %d \n", = my)<BR> printf(1,=20 "left button? %s \n", {state[lb+1]})<BR> printf(1, "right = button?=20 %s \n", {state[rb+1]})<BR> mouse_pointer(1) -- back=20 on<BR> end if<BR> if get_key() !=3D = -1=20 then<BR> exit -- if key press then exit from the while=20 loop<BR> 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>>I tried making the mouse = available in=20 graphics_mode but i=20 ------=_NextPart_000_003B_01C00398.C8E5F580--