Why is this programme bad

Hi All
I ask me to say what in this it is programme made bad?

She did not happen programme so as it should.Thank you

#include<SDL/SDL.h>

#include

#undef main

const int WYS=600;

const int SZER=800;

const int BPP=32;

SDL_Surface *background;

SDL_Surface *kula;

SDL_Surface *screen;

int x;

int y;

int main()

{

if(SDL_Init(SDL_INIT_EVERYTHING)<0)

std::cerr<<“Jajko z tego”<<SDL_GetError()<<std::endl;

screen=SDL_SetVideoMode(SZER,WYS,BPP,SDL_SWSURFACE|SDL_ANYFORMAT);

kula=SDL_LoadBMP(“kula.bmp”);

SDL_MapRGB(screen->format,0,255,255);

SDL_Event event;

SDL_PollEvent(&event);

SDL_Rect *klaw;

SDL_Rect *clip=NULL;

switch(event.key.keysym.sym)

{

case SDLK_UP:klaw->x=20;break;

case SDLK_LEFT:klaw->y=20;break;

}

SDL_BlitSurface(kula,NULL,screen,NULL);

SDL_Flip(screen);

SDL_Delay(5000);

SDL_Quit();

}–

krzysiek

Do you really speak english?..hey guy, do NOT use auto-translators.
Where is the program loop?..
A while() or do…while() maybe can help you :D…

Greetings.
C ya

2006/8/1, Krzysztof Pos?uszny :>

Hi All
I ask me to say what in this it is programme made bad?

She did not happen programme so as it should.Thank you

#include<SDL/SDL.h>

#include

#undef main

const int WYS=600;

const int SZER=800;

const int BPP=32;

SDL_Surface *background;

SDL_Surface *kula;

SDL_Surface *screen;

int x;

int y;

int main()

{

if(SDL_Init(SDL_INIT_EVERYTHING)<0)

std::cerr<<“Jajko z tego”<<SDL_GetError()<<std::endl;

screen=SDL_SetVideoMode(SZER,WYS,BPP,SDL_SWSURFACE|SDL_ANYFORMAT);

kula=SDL_LoadBMP(“kula.bmp”);

SDL_MapRGB(screen->format,0,255,255);

SDL_Event event;

SDL_PollEvent(&event);

SDL_Rect *klaw;

SDL_Rect *clip=NULL;

switch(event.key.keysym.sym)

{

case SDLK_UP:klaw->x=20;break;

case SDLK_LEFT:klaw->y=20;break;

}

SDL_BlitSurface(kula,NULL,screen,NULL);

SDL_Flip(screen);

SDL_Delay(5000);

SDL_Quit();

}

krzysiek


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Phantom Lord
Caelis Studios —> From Gods Hands To Yours

Krzysztof Pos?uszny wrote:

1/ you use klaw but it is not allocated
2/ you never use it in SDL_BlitSurface
3/ you don’t check if event is a keyboard event

try something like that

bool quit = false;
while( !quit ) {
if ( SDL_PollEvent( &event ) {
if ( event.type == SDL_KEYDOWN ) {
switch(event.key.keysym.sym) {
case SDLK_UP:klaw.x=20;break;
case SDLK_LEFT:klaw.y=20;break;
}
}
}

SDL_BlitSurface(kula,NULL,screen, &klaw );
SDL_Flip(screen);		

}–
Michael Bonfils ( http://www.murlock.org )
membre de http://www.guses.org

oops, forgot to test SDL_QUIT :slight_smile:

	if ( event.type == SDL_KEYDOWN ) {

[…]
} else if ( event.type == SDL_QUIT )
quit=true;–
Michael Bonfils ( http://www.murlock.org )
membre de http://www.guses.org