Level Editor in SDL
Posted: Sat Nov 01, 2008 2:13 pm
Hey there,
I am new here on the forum but an old watcher of the "Adventures in Game Development", and a big fan of the game and team xD.
Well, I am making a "mario type" of game, and I am needing help with the level editor. I followed the lazyfoo's tutorial, and I have done some modifications to it, but I am having problem on selecting the tile.
I am using C and SDL, and what I am basic doing so far is:
-I load everything up and display the tiles on the right side of my window.
-Each one of the tiles have a "code"
-This code is used to render just that "square tile" from the whole tilesheet
My problem is that when the program reaches the end of the "render tiles" loop the 'tile' variable is only located at the last tile rendered... all the other tiles doesnt have a 'tile' value, then when I try to read that from my selectTile() function, it can select only the last tile.
I tried rendering the tilesheet of many ways, but everyone of them produces the same problem!!
How should I do to do this : render all the tiles and when I select them it returns the 'tile' value!?
Sorry if I was confusing, please ask if you need more details!
Thanks in advance!
I am new here on the forum but an old watcher of the "Adventures in Game Development", and a big fan of the game and team xD.
Well, I am making a "mario type" of game, and I am needing help with the level editor. I followed the lazyfoo's tutorial, and I have done some modifications to it, but I am having problem on selecting the tile.
I am using C and SDL, and what I am basic doing so far is:
-I load everything up and display the tiles on the right side of my window.
-Each one of the tiles have a "code"
-This code is used to render just that "square tile" from the whole tilesheet
Code: Select all
const int TILE_GRASS = 0;
const int TILE_SAND = 1;
bool clipTiles()
{
clips[ TILE_GRASS ].x = 0;
clips[ TILE_GRASS ].y = 0;
clips[ TILE_GRASS ].w = TILE_WIDTH;
clips[ TILE_GRASS ].h = TILE_HEIGHT;
clips[ TILE_SAND ].x = TILE_WIDTH * 1;
clips[ TILE_SAND ].y = 0;
clips[ TILE_SAND ].w = TILE_WIDTH;
clips[ TILE_SAND ].h = TILE_HEIGHT;
.
.
.
}
int setTileSheet()
{
DrawIMG(938, 50, grid, screen, NULL);
offX = 943;
offY = 55;
tile = 0;
z = 1;
i = 1;
for( z = 1; z <= TILE_SHEET_Y; z++ )
{
tileCellY = offY;
if(z > 1)
tileCellY = offY + (38 * (z-1));
for( i = 1; i <= TILE_SHEET_X; i++ )
{
tileCellX = offX;
if(i > 1)
tileCellX = offX + (40 * (i-1));
[b]DrawIMG(tileCellX, tileCellY, tileSheet, screen, &clips[ tile ]);[/b]
tile++;
}
}
SDL_Flip(screen);
}
I tried rendering the tilesheet of many ways, but everyone of them produces the same problem!!
How should I do to do this : render all the tiles and when I select them it returns the 'tile' value!?
Sorry if I was confusing, please ask if you need more details!
Thanks in advance!