Comunidad PHPeros
Lenguajes => C / C++ => Mensaje iniciado por: javipilo en 16 de Enero de 2011, 23:57:22 pm
-
Buenas pues me dispuse a aprender SDL, después de ver varios sources y tal, me puse a hacer un juego RPG tipo SIMS 2 Náufragos... Entonces me topé con la necesidad de incluir imágenes y poder molerlas, si alguien me puede ayudar me vendría muy bien.
Saludos
-
Conseguí hacer un void para crear un rectángulo pero ¿como le meto una imagen?
Edito: Pongo mi código entero.
#include <SDL/SDL.h>
void new_tile (SDL_Surface *screen, int x, int y)
{
SDL_Rect rect = {x, y, 32, 32};
Uint32 a = SDL_MapRGB(screen->format, 255, 200, 100);
SDL_FillRect(screen, &rect, a);
SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h);
}
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface *buffer;
SDL_WM_SetCaption("Killforce", NULL);
bool fullscreen = false;
if (fullscreen == false)
{
buffer = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);
} else {
buffer = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_FULLSCREEN);
}
new_tile(buffer, 0, 0);
SDL_Event event;
while (event.type != SDL_QUIT)
{
SDL_PollEvent(&event);
SDL_Flip(buffer);
}
SDL_FreeSurface(buffer);
SDL_Quit();
return 0;
}