el problema es que al mover el personaje se quedan las imágenes atrás , aunque si aparecen desde su posición y avanza Asia donde se presiona ,pero se queda como un rastro ,abajo esta el código y aquí el link de las imágenes:https://mega.nz/#!RNswjIJB!d9FvXkTBby_cs8zkyXI0nDrsKPaCdGQbCaUi66J9S5E y
https://mega.nz/#!cB9kkQTI!GvtijkRzZXRhXRKLAhZK1pytnN8gsCKYDz8aYH0DPRY #include<stdio.h>
#include<SDL.h>
#include<SDL_image.h>
#include<iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[]) {
cout << "inicializacion....... " << endl;
cout << "creando ventana....." << endl;
cout << "cargando imagenes....." << endl;
cout << "comprobando errores...." << endl;
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window*window = SDL_CreateWindow("juego", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 700, 480, SDL_WINDOW_SHOWN);
SDL_Surface*windowSurface = nullptr;
SDL_Surface*imageSurface = nullptr;
SDL_Surface*bola = nullptr;
SDL_Rect posicion;
SDL_Event tecla;
windowSurface = SDL_GetWindowSurface(window);
imageSurface = SDL_LoadBMP("h.BMP");
bola = SDL_LoadBMP("normal.BMP");
posicion.x = 200;
posicion.y = 300;
posicion.h = bola->h;
posicion.w = bola->w;
SDL_BlitSurface(imageSurface, NULL, windowSurface, NULL);
while (true) {
SDL_BlitSurface(imageSurface, NULL, windowSurface, NULL);
SDL_BlitSurface(bola, NULL, imageSurface, &posicion);
SDL_UpdateWindowSurface(window);
while (SDL_PollEvent(&tecla)) {
if (tecla.type == SDL_QUIT) {
exit(0);
}
if (tecla.type == SDL_KEYDOWN) {
if (tecla.key.keysym.sym == SDLK_RIGHT){
posicion.x++;
posicion.x++;
posicion.x++;
posicion.x++;
posicion.x++;
posicion.x++;
}
if (tecla.key.keysym.sym == SDLK_LEFT) {
posicion.x--;
posicion.x--;
posicion.x--;
posicion.x--;
posicion.x--;
posicion.x--;
}
if (tecla.key.keysym.sym == SDLK_UP) {
posicion.y--;
posicion.y--;
posicion.y--;
posicion.y--;
posicion.y--;
posicion.y--;
}
if (tecla.key.keysym.sym == SDLK_DOWN) {
posicion.y++;
posicion.y++;
posicion.y++;
posicion.y++;
posicion.y++;
posicion.y++;
}
}
}
}
SDL_Delay(4000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}