soy nuevo en esta pagina y estoy aqui para ver si me pueden ayudar
con un problema que tengo con SDL
he estado un tiempo programando con SDL y mayormente haciendo
pruebas, mayormente con pocas imágenes, ahora que estoy haciendo
un nivel estoy colocando mas imágenes y se ve como si tuviera lag
y las imagenes no pesan mucho, entre todas las imagenes pesan unos
4mb
aqui coloco mi codigo aver si me ayudan Porfa!

#include <iostream>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
using namespace std;
#define Ancho 1280
#define Alto 768
#define BPP 24
SDL_Surface *Ventana, *Fondo, *Galaxia, *PlanetaRojo, *LensFlare, *PlanetaAzul, *Plano2Alfa, *Scene, *Jugador;
SDL_Surface *Estrellas[6];
SDL_Rect RectGalaxia, RectPlanetaRojo, RectPlanetaAzul, RectJugador;
SDL_Rect RectScene[3];
SDL_Event Event;
Uint8 *Teclado;
int main(){
bool Salir=false;
int Cont=0, i=0;
atexit(SDL_Quit);
if(SDL_Init(SDL_INIT_VIDEO)<0){
cout<<"Error al iniciar SDL. Error: "<<SDL_GetError();
exit(1);
}
SDL_WM_SetCaption("PruebaNivelPiloto v1",NULL);
Ventana=SDL_SetVideoMode(Ancho, Alto, BPP, SDL_HWSURFACE | SDL_DOUBLEBUF);
if(Ventana==NULL){
cout<<"No se pudo iniciar el modo de video. Error: "<<SDL_GetError();
exit(1);
}
Fondo=IMG_Load("MundoPiloto/Fondo0.png");
if(Fondo==NULL){
cout<<"No se ha podido cargar la imagen 'Fondo0.png'.Error: "<<SDL_GetError();
exit(1);
}
Estrellas[0]=IMG_Load("MundoPiloto/StarsA1.png");
Estrellas[1]=IMG_Load("MundoPiloto/StarsA2.png");
Estrellas[2]=IMG_Load("MundoPiloto/StarsA3.png");
Estrellas[3]=IMG_Load("MundoPiloto/StarsB1.png");
Estrellas[4]=IMG_Load("MundoPiloto/StarsB2.png");
Estrellas[5]=IMG_Load("MundoPiloto/StarsB3.png");
for(int i=0;i<=5;i++){
if(Estrellas[i]==NULL){
cout<<"No se ha podido cargar alguna imagen de las estrellas.Error: "<<SDL_GetError();
exit(1);
}
}
Galaxia=IMG_Load("MundoPiloto/Galaxia.png");
if(Galaxia==NULL){
cout<<"No se ha podico cargar la imagen 'Galaxia.png'. Error: "<<SDL_GetError();
exit(1);
}
PlanetaRojo=IMG_Load("MundoPiloto/PlanetaRojo.png");
if(PlanetaRojo==NULL){
cout<<"No se ha podido cargar 'PlanetaRojo.png'. Error: "<<SDL_GetError()<<endl;
exit(1);
}
LensFlare=IMG_Load("MundoPiloto/LensFlare.png");
if(LensFlare==NULL){
cout<<"No se ha podido cargar la imagen 'LensFlare.png'. Error: "<<SDL_GetError()<<endl;
exit(1);
}
PlanetaAzul=IMG_Load("MundoPiloto/PlanetaAzul.png");
if(PlanetaAzul==NULL){
cout<<"No se ha podido cargar la imagen 'PlanetaAzul.png'. Error: "<<SDL_GetError()<<endl;
exit(1);
}
Plano2Alfa=IMG_Load("MundoPiloto/Plano2Alfa.png");
if(Plano2Alfa==NULL){
cout<<"No se ha podido cargar la imagen 'Plano2Alfa.png'. Error: "<<SDL_GetError()<<endl;
exit(1);
}
Scene=IMG_Load("MundoPiloto/Scene.png");
if(Scene==NULL){
cout<<"No se ha podido cargar 'Scene.png'. Error: "<<SDL_GetError()<<endl;
exit(1);
}
Jugador=IMG_Load("MundoPiloto/Jugador.png");
if(Jugador==NULL){
cout<<"No se ha podido cargar la imagen 'Jugador.png'. Error: "<<SDL_GetError()<<endl;
exit(1);
}
RectGalaxia.x=194;
RectGalaxia.y=45;
RectPlanetaRojo.x=12;
RectPlanetaRojo.y=43;
RectPlanetaAzul.x=818;
RectPlanetaAzul.y=214;
RectScene[0].x=0;
RectScene[0].y=0;
RectScene[0].w=Ancho;
RectScene[0].h=Alto;
RectScene[1].x=0;
RectScene[1].y=0;
RectScene[1].w=0;
RectScene[1].h=Alto;
RectScene[2].x=Ancho;
RectScene[2].y=0;
RectScene[2].h=Alto;
RectScene[2].w=Ancho;
RectJugador.x=20;
RectJugador.y=120;//120
while(Salir==false){
SDL_BlitSurface(Fondo, NULL, Ventana, NULL);
SDL_BlitSurface(Estrellas[Cont], NULL, Ventana, NULL); // Si no muestro
SDL_BlitSurface(Galaxia, NULL, Ventana, &RectGalaxia); // algunas de
SDL_BlitSurface(PlanetaRojo, NULL, Ventana, &RectPlanetaRojo);// estas imagenes
SDL_BlitSurface(LensFlare, NULL, Ventana, NULL); // dejando solamente
SDL_BlitSurface(PlanetaAzul, NULL, Ventana, &RectPlanetaAzul);// a Fondo y Jugador
SDL_BlitSurface(Plano2Alfa, NULL, Ventana, NULL); // el juego corre bien
SDL_BlitSurface(Scene, &RectScene[0], Ventana, NULL);
SDL_BlitSurface(Scene, &RectScene[1], Ventana, &RectScene[2]);
SDL_BlitSurface(Jugador, NULL, Ventana, &RectJugador);
i++;
if(i==2){
if(Cont<5) Cont++;
else Cont=0;
i=0;
}
SDL_Flip(Ventana);
Teclado=SDL_GetKeyState(NULL);
if(Teclado[SDLK_RIGHT] && (RectJugador.x+Jugador->w)<=Ancho){
RectJugador.x+=10;
RectScene[0].x+=10;
RectScene[0].w-=10;
RectScene[1].w=RectScene[0].x;
RectScene[2].x-=10;
if(RectScene[0].x>=Ancho){
RectScene[0].x=0;
RectScene[0].y=0;
RectScene[0].w=Ancho;
RectScene[0].h=Alto;
RectScene[1].x=0;
RectScene[1].y=0;
RectScene[1].w=0;
RectScene[1].h=Alto;
RectScene[2].x=Ancho;
RectScene[2].y=0;
RectScene[2].h=Alto;
RectScene[2].w=Ancho;
}
}
if(Teclado[SDLK_LEFT] && RectJugador.x>=0) {
RectJugador.x-=10;
RectScene[0].x-=10;
RectScene[0].w+=10;
RectScene[1].w=RectScene[0].x;
RectScene[2].x+=10;
}
if(Teclado[SDLK_UP] && (RectJugador.y+Jugador->h>=520)) RectJugador.y-=10;
if(Teclado[SDLK_DOWN] && (RectJugador.y+Jugador->h<=Alto)) RectJugador.y+=10;
if(RectScene[0].x+Scene->w<=0) RectScene[0].x=Ancho;
if(RectScene[1].x+Scene->w<=0) RectScene[1].x=Ancho;
while(SDL_PollEvent(&Event)){
switch(Event.type){
case(SDL_KEYDOWN):{
if(Event.key.keysym.sym==SDLK_ESCAPE) Salir=true;
}
break;
case(SDL_KEYUP):{
if(Event.key.keysym.sym==SDLK_RIGHT) RectJugador.x-=10;
if(Event.key.keysym.sym==SDLK_LEFT) RectJugador.x+=10;
}
break;
case(SDL_QUIT): Salir=true;
break;
}
}
}
SDL_FreeSurface(Fondo);
for(int i=0;i<5;i++){
SDL_FreeSurface(Estrellas[i]);
}
return(0);
}