Re: esc detector wont run -- 'out of scope'
"speartip" <[email protected]> Fri, 17 Mar 2017 22:41:16 +0000
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <[email protected]> |
--===============8627761945086566421==
Content-Type: multipart/alternative;
boundary="=_9ede0bdeabb510580b9faa1c78f3d03a"
--=_9ede0bdeabb510580b9faa1c78f3d03a
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
Thanks! That fixed it so it will compile. No more errors. The code still doesn't do what it is supposed to: abort when you press esc. I flagged it up. It never gets passed flag 1.
Code:
#include<iostream>
#include"SDL.h"
using namespace std;
const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char* WINDOW_TITLE = "SDL Start";
int main(int argc, char **argv)
{ cout<<"flag 0";
SDL_Init( SDL_INIT_VIDEO );
SDL_Event event;
bool gameRunning = true;
while (gameRunning)
{
cout<<"flag 1"<<endl;
if (SDL_PollEvent(&event))
{
cout<<"flag 2";
if (event.type == SDL_QUIT)
{
cout<<"flag 3";
gameRunning = false;
}
if (event.type == SDL_KEYDOWN)
{
SDL_Keycode keyPressed = event.key.keysym.sym;
switch (keyPressed)
{
case SDLK_ESCAPE:
gameRunning = false;
break;
}
}
}
}
SDL_Quit();
cout<<endl<<"end flag";
return 0;
}
--=_9ede0bdeabb510580b9faa1c78f3d03a
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type=3D"text/css">
<!--
/*
The original subSilver Theme for phpBB version 2+
Created by subBlue design
http://www.subBlue.com
NOTE: These CSS definitions are stored within the main page body so that =
you can use the phpBB2
theme administration centre. When you have finalised your style you could=
cut the final CSS code
and place it in an external file, deleting this section to save bandwidth=
.
*/
/* General page style. The scroll bar colours only visible in IE5.5+ */
body {
background-color: #;
font-family: ;
font-size: 11;
color: #;
}
/* General font families for common tags */
font,th,td,p { font-family: }
p, td { font-size : 11; color : #; }
a:link,a:active,a:visited { color : #; }
a:hover { text-decoration: underline; color : #; }
hr { height: 0px; border: solid # 0px; border-top-width: 1px;}
h1,h2 { font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif=
; font-size : 22px; font-weight : bold; text-decoration : none; line-height=
: 120%; color : #000000;}
/* This is the border line & background colour round the entire page */
.bodyline { background-color: #; border: 1px # solid; }
/* General text */
.gen { font-size : 12px; }
.genmed { font-size : 11px; }
.gensmall { font-size : 10px; line-height: 12px}
.gen,.genmed,.gensmall { color : #; }
a.gen,a.genmed,a.gensmall { color: #; text-decoration: none; }
a.gen:hover,a.genmed:hover,a.gensmall:hover { color: #; text-decoration: un=
derline; }
/* Forum title: Text and link to the forums used in: index.php */
.forumlink { font-weight: bold; font-size: 12px; color : #; }
a.forumlink { text-decoration: none; color : #; }
a.forumlink:hover{ text-decoration: underline; color : #; }
/* The content of the posts (body of text) */
.postbody { font-size : 12px; line-height: 18px}
a.postlink:link { text-decoration: none; color : # }
a.postlink:visited { text-decoration: none; color : #; }
a.postlink:hover { text-decoration: underline; color : #}
/* Quote & Code blocks */
.code {
font-family: ; font-size: 11px; color: #3FB753;
background-color: #; border: #; border-style: solid;
border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; bo=
rder-bottom-width: 1px
}
.quote {
font-family: ; font-size: 11px; color: #444444; line-height: 125%;
background-color: #; border: #; border-style: solid;
border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; bo=
rder-bottom-width: 1px
}
-->
</style>
</head>
<body>
<div class=3D"postbody">Thanks! That fixed it so it will compile. No more =
errors. The code still doesn't do what it is supposed to: abort when you pr=
ess esc. I flagged it up. It never gets passed flag 1. <br />
<br />
<div align=3D"center"><table width=3D"90%" align=3D"center" cellspacing=3D"=
1" cellpadding=3D"2" border=3D"0" class=3D"code"><br />=0D<tr> <br />=0D <t=
d class=3D"code_header" align=3D"left">Code:</td><br />=0D</tr><br />=0D<tr=
><br />=0D <td class=3D"code" align=3D"left"><br />
#include<iostream><br />
#include"SDL.h"<br />
using namespace std;<br />
<br />
const int WINDOW_WIDTH =3D 640;<br />
const int WINDOW_HEIGHT =3D 480;<br />
const char* WINDOW_TITLE =3D "SDL Start";<br />
<br />
int main(int argc, char **argv)<br />
{ cout<<"flag 0";<br />
SDL_Init( SDL_INIT_VIDEO );<br />
<br />
SDL_Event event;<br />
<br />
bool gameRunning =3D true;<br />
<br />
while (gameRunning)<br />
{<br />
cout<<"flag 1"<<endl;<br />
if (SDL_PollEvent(&event))<br />
{<br />
cout<<"flag 2";<br />
if (event.type =3D=3D SDL_QUIT)<b=
r />
{<br />
cout<<"flag 3";<br />
gameRunning =3D false;<br />
}<br />
<br />
if (event.type =3D=3D SDL_KEYDOWN)=
;<br />
{<br />
<br />
SDL_Keycode keyPressed =3D event.=
key.keysym.sym;<br />
<br />
switch (keyPressed)<br />
{<br />
case SDLK_ESCAPE:=
;<br />
gameRunning =
=3D false;<br />
break;<br />
}<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
SDL_Quit();<br />
<br />
cout<<endl<<"end flag";<br />
return 0;<br />
<br />
<br />
<br />
}<br />
</td><br />=0D </tr><br />=0D</table></div></div>
</body>
</html>
--=_9ede0bdeabb510580b9faa1c78f3d03a--
--===============8627761945086566421==
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
--===============8627761945086566421==--