first grass tile
Posted: Tue May 04, 2010 10:30 pm
This is my first attempt at a tile, I used gimp to create this, what are your thoughts about this tile? alright for a first try, or should I quit while I'm ahead, and how do I make it so that it doesn't look like there are diagonal lines down the screen when I render it?
code I used to display image
code I used to display image
Code: Select all
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
int main (int argc, char *argv[])
{
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
SDL_Surface *buffer = NULL;//creates the buffer
SDL_Surface *grass = NULL;//creates the buffer
SDL_Init(SDL_INIT_VIDEO);
buffer = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE);
bool done = false;
SDL_Event event;
SDL_WM_SetCaption("Window", NULL);
grass = IMG_Load("grass1.png");
while(!done)
{
SDL_FillRect(buffer,NULL,0x000000);
for (int y = 0; y < SCREEN_HEIGHT; y+=32)
{
for (int x = 0; x<SCREEN_WIDTH; x+=32)
{
SDL_Rect area = { x, y,32,32};
SDL_BlitSurface( grass, NULL,buffer , &area );
}
}
SDL_Flip(buffer);
while(SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
done = true;
}
}
}
SDL_FreeSurface(grass);
SDL_Quit();
return 0;
}