Re: esc detector wont run -- 'out of scope'
Clangray <[email protected]> Sat, 25 Mar 2017 14:23:36 -0400
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <1490466216.1471393.923288528.0835DD4C@webmail.messagingengine.com> |
This is a multi-part message in MIME format. --===============5602294136815712210== Content-Transfer-Encoding: 7bit Content-Type: multipart/alternative; boundary="_----------=_149046621614713930" This is a multi-part message in MIME format. --_----------=_149046621614713930 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" Jonny D is this an appropriate way to handle a keypress and exit the program? -- Gray Family [email protected] On Fri, Mar 24, 2017, at 05:25 PM, Jonathan Dearborn wrote: > Checking scancodes is a different thing than handling events. Unless > necessary to achieve an effect (e.g. holding a key while moving the > mouse), you should only be using the event structure when in the > SDL_PollEvent loop. > > Jonny D > > On Fri, Mar 24, 2017 at 4:57 PM, speartip > <[email protected]> wrote: >> __ >> Thanks every one. In addition to having a window in context I added >> this small code: >> >> >> >> >> >> Code: >> >> >> >> const Uint8 *keys = SDL_GetKeyboardState(NULL); >> SDL_Event e; >> . >> . >> . >> >> while (SDL_PollEvent(&e)){ >> if (e.type == SDL_QUIT){ >> done = SDL_TRUE; >> } >> if (keys[SDL_SCANCODE_ESCAPE]){ >> done = SDL_TRUE;} >> } >> >> >> >> _______________________________________________ >> SDL mailing list >> [email protected] >> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org >> > _________________________________________________ > SDL mailing list > [email protected] > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org --_----------=_149046621614713930 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset="utf-8" <!DOCTYPE html> <html> <head> <title></title> </head> <body><div>Jonny D is this an appropriate way to handle a keypress and exit the program?</div> <div><br></div> <div id="sig43414442"><div class="signature">--<br></div> <div class="signature"> Gray Family<br></div> <div class="signature"> [email protected]<br></div> <div class="signature"><br></div> </div> <div><br></div> <div><br></div> <div>On Fri, Mar 24, 2017, at 05:25 PM, Jonathan Dearborn wrote:<br></div> <blockquote type="cite"><div dir="ltr"><div>Checking scancodes is a different thing than handling events. Unless necessary to achieve an effect (e.g. holding a key while moving the mouse), you should only be using the event structure when in the SDL_PollEvent loop.<br></div> <div><br></div> <div>Jonny D<br></div> </div> <div><div><br></div> <div defang_data-gmailquote="yes"><div>On Fri, Mar 24, 2017 at 4:57 PM, speartip <span dir="ltr"><<a href="mailto:[email protected]">[email protected]</a>></span> wrote:<br></div> <blockquote defang_data-gmailquote="yes" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;"><div><u></u><br></div> <div><div><div>Thanks every one. In addition to having a window in context I added this small code:<br></div> <div> <br></div> <div> <br></div> <div align="center"><div><br></div> <div><br></div> <table width="90%" align="center" cellspacing="1" cellpadding="2" border="0"><tbody><tr><td><br></td></tr><tr><td align="left">Code:<br></td><td><br></td></tr><tr><td><br></td></tr><tr><td align="left"><div><br></div> <div> const Uint8 *keys = SDL_GetKeyboardState(NULL);<br></div> <div> SDL_Event e;<br></div> <div> .<br></div> <div> .<br></div> <div> .<br></div> <div> <br></div> <div> while (SDL_PollEvent(&e)){<br></div> <div> if (e.type == SDL_QUIT){<br></div> <div> done = SDL_TRUE;<br></div> <div> }<br></div> <div> if (keys[SDL_SCANCODE_ESCAPE]){<br></div> <div> done = SDL_TRUE;}<br></div> <div> }<br></div> </td><td><br></td></tr><tr><td><br></td></tr></tbody></table></div> </div> </div> <div><br></div> <div>______________________________<wbr>_________________<br></div> <div> SDL mailing list<br></div> <div> <a href="mailto:[email protected]">[email protected]</a><br></div> <div> <a href="http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org">http://lists.libsdl.org/<wbr>listinfo.cgi/sdl-libsdl.org</a><br></div> <div> <br></div> </blockquote></div> </div> <div><u>_______________________________________________</u><br></div> <div>SDL mailing list<br></div> <div><a href="mailto:[email protected]">[email protected]</a><br></div> <div><a href="http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org">http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org</a><br></div> </blockquote><div><br></div> </body> </html> --_----------=_149046621614713930-- --===============5602294136815712210== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ SDL mailing list [email protected] http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org --===============5602294136815712210==--